mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-06 14:09:42 -06:00
GP-6263 - Listing - Fixed bug when copying text fro memory block fields
This commit is contained in:
@@ -62,9 +62,6 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {
|
||||
super(FIELD_NAME, model, hlProvider, displayOptions, fieldOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ghidra.app.util.viewer.field.FieldFactory#getField(ProxyObj, int)
|
||||
*/
|
||||
@Override
|
||||
public ListingField getField(ProxyObj<?> proxy, int varWidth) {
|
||||
|
||||
@@ -206,13 +203,13 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {
|
||||
String type = "";
|
||||
if (blockType != MemoryBlockType.DEFAULT) {
|
||||
if (block.isMapped()) {
|
||||
type = "(" + block.getSourceInfos().get(0).getDescription() + ")";
|
||||
type = " (" + block.getSourceInfos().get(0).getDescription() + ")";
|
||||
}
|
||||
else {
|
||||
type = "(" + blockType + ")";
|
||||
type = " (" + blockType + ")";
|
||||
}
|
||||
}
|
||||
String line1 = block.getName() + " " + type;
|
||||
String line1 = block.getName() + type;
|
||||
String line2 = block.getComment();
|
||||
String line3 = block.getStart().toString(true) + "-" + block.getEnd().toString(true);
|
||||
Color color = ListingColors.BLOCK_START;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@@ -513,12 +513,18 @@ public class VerticalLayoutTextField implements TextField {
|
||||
return getText().length();
|
||||
}
|
||||
int extraSpace = rowSeparator.length();
|
||||
int len = 0;
|
||||
int offset = 0;
|
||||
for (int i = 0; i < row; i++) {
|
||||
len += lines.get(i).length() + extraSpace;
|
||||
String line = lines.get(i);
|
||||
int len = line.length();
|
||||
if (!line.endsWith(rowSeparator)) {
|
||||
len += extraSpace; // getText() performs this same check; be consistent
|
||||
}
|
||||
|
||||
offset += len;
|
||||
}
|
||||
len += Math.min(col, lines.get(row).length());
|
||||
return len;
|
||||
offset += Math.min(col, lines.get(row).length());
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -527,11 +533,15 @@ public class VerticalLayoutTextField implements TextField {
|
||||
int extraSpace = rowSeparator.length();
|
||||
int n = subFields.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
int len = lines.get(i).length();
|
||||
if (absoluteOffset < len + extraSpace) {
|
||||
String line = lines.get(i);
|
||||
int len = line.length();
|
||||
if (!line.endsWith(rowSeparator)) {
|
||||
len += extraSpace; // getText() performs this same check; be consistent
|
||||
}
|
||||
if (absoluteOffset < len) {
|
||||
return new RowColLocation(i, absoluteOffset);
|
||||
}
|
||||
absoluteOffset -= len + extraSpace;
|
||||
absoluteOffset -= len;
|
||||
}
|
||||
|
||||
int lastRow = n - 1;
|
||||
@@ -572,6 +582,7 @@ public class VerticalLayoutTextField implements TextField {
|
||||
private class FieldRow {
|
||||
private TextField field;
|
||||
private int dataRow;
|
||||
@SuppressWarnings("unused") // used by Json
|
||||
private int screenRow;
|
||||
|
||||
FieldRow(TextField field, int dataRow, int screenRow) {
|
||||
|
||||
Reference in New Issue
Block a user