Merge remote-tracking branch 'origin/GP-6178_ghidragon_byteviewer_cant_select_last_byte_in_program--SQUASHED'

This commit is contained in:
Ryan Kurtz
2026-01-22 20:27:01 -05:00
2 changed files with 19 additions and 14 deletions
@@ -762,7 +762,7 @@ public class ByteViewerComponent extends FieldPanel
// if the selection ends on a separator line, go back to the end of the previous line
if (indexMap.isBlockSeparatorIndex(lineIndex)) {
lineIndex = lineIndex.subtract(BigInteger.ONE);
fieldNum = fieldFactories.length - 1; // set to end of line factory
fieldNum = fieldFactories.length; // set to end of line factory
}
// if the selection is before the characters in this field, the selection doesn't include
@@ -1836,7 +1836,6 @@ public class FieldPanel extends JPanel
private int mouseDownY;
private boolean didDrag;
private int timerScrollAmount;
private FieldLocation timerPoint;
MouseHandler() {
scrollTimer = new Timer(100, this);
@@ -1850,13 +1849,15 @@ public class FieldPanel extends JPanel
public void actionPerformed(ActionEvent e) {
try {
scrollView(timerScrollAmount);
if (timerScrollAmount > 0) {
timerPoint.setIndex(layouts.get(layouts.size() - 1).getIndex());
FieldLocation selectToLocation = new FieldLocation();
if (timerScrollAmount >= 0) {
BigInteger lastIndex = layouts.get(layouts.size() - 1).getIndex();
selectToLocation.setIndex(lastIndex.add(BigInteger.ONE));
}
else {
timerPoint.setIndex(layouts.get(0).getIndex());
selectToLocation.setIndex(layouts.get(0).getIndex());
}
selectionHandler.updateSelectionSequence(timerPoint);
selectionHandler.updateSelectionSequence(selectToLocation);
}
catch (Exception ex) {
// don't care
@@ -1912,15 +1913,23 @@ public class FieldPanel extends JPanel
if (((Math.abs(x - mouseDownX) > 3) || (Math.abs(y - mouseDownY) > 3))) {
didDrag = true;
if (selectionHandler.isInProgress()) {
if (y < 0 || y > getHeight()) {
if (y < 0 || y >= getHeight()) {
timerScrollAmount = y < 0 ? y : y - getHeight();
timerPoint = new FieldLocation(cursorPosition);
scrollTimer.start();
}
else {
scrollTimer.stop();
cursorHandler.setCursorPos(x, y, null); // null means don't notify listeners
selectionHandler.updateSelectionSequence(cursorPosition);
FieldLocation selectionEnd = cursorPosition;
// if the mouse is to the right of the last field, make the selection
// include the last field
Layout layout = getLayoutModel().getLayout(selectionEnd.getIndex());
int width = layout.getCompressableWidth();
if (x > width) {
selectionEnd =
new FieldLocation(selectionEnd.getIndex().add(BigInteger.ONE));
}
selectionHandler.updateSelectionSequence(selectionEnd);
repaint();
}
}
@@ -2199,11 +2208,7 @@ public class FieldPanel extends JPanel
currentField = null;
// delegate to the appropriate layout to do the work
Layout layout = findLayoutAt(y);
if (layout == null) {
x = 0;
y = 0;
layout = findLayoutAt(y);
}
if (layout != null) {
FieldLocation newCursorPosition = new FieldLocation();
lastX = layout.setCursor(newCursorPosition, x, y);