Skip to main content
summaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorAnton Leherbauer2011-04-15 04:15:28 -0400
committerAnton Leherbauer2011-04-15 04:15:28 -0400
commit7f659622446f5b6306440fb594757ff6dd0b47c4 (patch)
tree0606ff0ac13f184e69ffe4c37837600309aa5889 /dsf
parent6945632db0f6ec6a7dd7a8b16c6c641d34c22494 (diff)
downloadorg.eclipse.cdt-7f659622446f5b6306440fb594757ff6dd0b47c4.tar.gz
org.eclipse.cdt-7f659622446f5b6306440fb594757ff6dd0b47c4.tar.xz
org.eclipse.cdt-7f659622446f5b6306440fb594757ff6dd0b47c4.zip
Bug 331629 - [disassembly] pageUp/pageDown scrolling jumps over unknown sections unexpectedlyv201104150807
In cooperation with Kirk Beitz
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java59
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java27
2 files changed, 76 insertions, 10 deletions
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
index ebb53ddc17..f613f655fc 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java
@@ -658,7 +658,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
parent.setLayout(layout);
fVerticalRuler = createVerticalRuler();
int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
- fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles);
+ fViewer = new DisassemblyViewer(this, parent, fVerticalRuler, getOverviewRuler(), true, styles);
SourceViewerConfiguration sourceViewerConfig = new DisassemblyViewerConfiguration(this);
fViewer.addTextPresentationListener(this);
fViewer.configure(sourceViewerConfig);
@@ -1439,15 +1439,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fBackend.gotoSymbol(symbol);
}
- private void gotoPosition(Position pos, boolean select) {
+ private void gotoPosition(Position pos, boolean onTop) {
if (fViewer == null) {
return;
}
setFocusPosition(pos);
- fViewer.setSelectedRange(pos.offset, select ? Math.max(pos.length-1, 0) : 0);
+ fViewer.setSelectedRange(pos.offset, 0);
int revealOffset = pos.offset;
- boolean onTop = false;
- if (/* !fUpdateBeforeFocus && */ pos.offset > 0) {
+ if (pos.offset > 0) {
try {
AddressRangePosition previousPos = fDocument.getModelPosition(pos.offset - 1);
if (previousPos instanceof LabelPosition) {
@@ -3086,4 +3085,54 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
private static boolean isGuiThread() {
return Display.getCurrent() != null;
}
+
+ boolean keyScroll(int keyCode) {
+ BigInteger topAddress = getTopAddress();
+ BigInteger bottomAddress = getBottomAddress();
+ BigInteger addressRange = bottomAddress.subtract(topAddress);
+ StyledText styledText = fViewer.getTextWidget();
+ Rectangle clientArea = styledText.getClientArea();
+ int lineRange;
+ if (SWT.PAGE_UP == keyCode || SWT.PAGE_DOWN == keyCode) {
+ lineRange = clientArea.height / styledText.getLineHeight();
+ } else {
+ lineRange = 1;
+ }
+ addressRange = addressRange.min(BigInteger.valueOf(lineRange * fDocument.getMeanSizeOfInstructions()));
+ BigInteger scrollToAddress;
+ switch (keyCode) {
+ case SWT.PAGE_UP:
+ case SWT.ARROW_UP:
+ scrollToAddress = topAddress.subtract(addressRange).max(fStartAddress);
+ break;
+ case SWT.PAGE_DOWN:
+ scrollToAddress = topAddress.add(addressRange).min(bottomAddress);
+ break;
+ case SWT.ARROW_DOWN:
+ scrollToAddress = bottomAddress.add(addressRange).min(bottomAddress);
+ break;
+ default:
+ assert false; // invalid keycode passed
+ scrollToAddress = fFocusAddress;
+ }
+ AddressRangePosition pos = getPositionOfAddress(scrollToAddress);
+ if (pos != null && pos.fValid) {
+ if (SWT.ARROW_DOWN == keyCode && pos.fAddressOffset.compareTo(bottomAddress) <= 0
+ || SWT.ARROW_UP == keyCode && pos.fAddressOffset.compareTo(topAddress) >= 0) {
+ return false;
+ }
+ gotoPosition(pos, SWT.ARROW_DOWN != keyCode);
+ } else {
+ gotoAddress(scrollToAddress);
+ }
+ return true;
+ }
+
+ private BigInteger getBottomAddress() {
+ BigInteger bottomAddress = getAddressOfLine(fViewer.getBottomIndex());
+ if (bottomAddress == null || bottomAddress.equals(PC_UNKNOWN)) {
+ bottomAddress = fEndAddress.subtract(BigInteger.ONE);
+ }
+ return bottomAddress;
+ }
}
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java
index d5863dc512..7d4a4e4300 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems and others.
+ * Copyright (c) 2007, 2011 Wind River Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,12 +24,15 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerColumn;
import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Composite;
@@ -52,13 +55,14 @@ public class DisassemblyViewer extends SourceViewer {
public void controlMoved(ControlEvent e) {
}
}
-
+
private boolean fUserTriggeredScrolling;
private int fCachedLastTopPixel;
// extra resize listener to workaround bug 171018
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018
private ResizeListener fResizeListener;
+ private DisassemblyPart fPart;
/**
* Create a new DisassemblyViewer.
@@ -68,8 +72,9 @@ public class DisassemblyViewer extends SourceViewer {
* @param showsAnnotationOverview
* @param styles
*/
- public DisassemblyViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
+ public DisassemblyViewer(DisassemblyPart part, Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) {
super(parent, ruler, overviewRuler, showsAnnotationOverview, styles);
+ fPart = part;
// always readonly
setEditable(false);
}
@@ -80,8 +85,20 @@ public class DisassemblyViewer extends SourceViewer {
@Override
protected void createControl(Composite parent, int styles) {
super.createControl(parent, styles);
+ StyledText textWidget = getTextWidget();
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018
- getTextWidget().addControlListener(fResizeListener= new ResizeListener());
+ textWidget.addControlListener(fResizeListener= new ResizeListener());
+ textWidget.addVerifyKeyListener(new VerifyKeyListener() {
+ public void verifyKey(VerifyEvent event) {
+ switch (event.keyCode) {
+ case SWT.PAGE_UP:
+ case SWT.PAGE_DOWN:
+ case SWT.ARROW_UP:
+ case SWT.ARROW_DOWN:
+ event.doit = !fPart.keyScroll(event.keyCode);
+ }
+ }
+ });
}
/*
@@ -231,7 +248,7 @@ public class DisassemblyViewer extends SourceViewer {
if (!onTop && focusLine >= top && focusLine <= bottom - bottomBuffer) {
// do not scroll at all as it is already visible
} else {
- if (focusLine > bottom - bottomBuffer && focusLine <= bottom) {
+ if (!onTop && focusLine > bottom - bottomBuffer && focusLine <= bottom) {
// focusLine is already in bottom bufferZone
// scroll to top of bottom bufferzone - for smooth down-scrolling
int scrollDelta = focusLine - (bottom - bottomBuffer);

Back to the top