Merge remote-tracking branch 'origin/GP-6263-dragonmacher-copy-text-fix'

into patch (Closes #8797)
This commit is contained in:
Ryan Kurtz
2025-12-23 12:45:42 -05:00
2 changed files with 23 additions and 15 deletions
@@ -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) {
@@ -212,7 +209,7 @@ public class MemoryBlockStartFieldFactory extends FieldFactory {
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;
@@ -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
}
len += Math.min(col, lines.get(row).length());
return len;
offset += 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) {