Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2012-08-17 13:55:59 +0000
committerChris Recoskie2012-08-17 13:55:59 +0000
commit1a96cdb2e64d8f5515a04f850a5c2fbffb7691c8 (patch)
treeebefa86bf95b3ddd8aee710678d65cbfacf87d03
parent25d4725359e6957e33cd054e5c420305329b7783 (diff)
downloadorg.eclipse.cdt-1a96cdb2e64d8f5515a04f850a5c2fbffb7691c8.tar.gz
org.eclipse.cdt-1a96cdb2e64d8f5515a04f850a5c2fbffb7691c8.tar.xz
org.eclipse.cdt-1a96cdb2e64d8f5515a04f850a5c2fbffb7691c8.zip
Bug 386600 - backport for Bug 346129 StackOverflowError in
Traditional rendering
-rw-r--r--memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/AbstractPane.java66
1 files changed, 43 insertions, 23 deletions
diff --git a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/AbstractPane.java b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/AbstractPane.java
index e79f246b6a3..243eb2696ca 100644
--- a/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/AbstractPane.java
+++ b/memory/org.eclipse.cdt.debug.ui.memory.traditional/src/org/eclipse/cdt/debug/ui/memory/traditional/AbstractPane.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2012 Wind River Systems, Inc. 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Ted R Williams (Wind River Systems, Inc.) - initial implementation
+ * IBM Corporation
*******************************************************************************/
package org.eclipse.cdt.debug.ui.memory.traditional;
@@ -398,7 +399,7 @@ public abstract class AbstractPane extends Canvas
* (fRendering.getRowCount() - 1)));
setCaretAddress(newCaretAddress);
-
+ fRendering.setViewportStartAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
@@ -410,7 +411,7 @@ public abstract class AbstractPane extends Canvas
.valueOf(fRendering.getAddressableCellsPerRow()
* (fRendering.getRowCount() - 1)));
setCaretAddress(newCaretAddress);
-
+ fRendering.setViewportStartAddress(newCaretAddress);
updateCaret();
ensureCaretWithinViewport();
}
@@ -520,20 +521,20 @@ public abstract class AbstractPane extends Canvas
protected void ensureCaretWithinViewport() // TODO getAddressableSize() > 1 ?
{
BigInteger vpStart = fRendering.getViewportStartAddress();
- BigInteger vpEnd = fRendering.getViewportEndAddress();
+ BigInteger vpEnd = fRendering.getViewportEndAddress();
- Rectangle vpBounds = fRendering.getBounds();
- Rectangle apBounds = fRendering.fAddressPane.getBounds();
- Rectangle dpBounds = fRendering.fBinaryPane.getBounds();
- Rectangle tpBounds = fRendering.fTextPane.getBounds();
+ Rectangle vpBounds = fRendering.getBounds();
+ Rectangle apBounds = fRendering.fAddressPane.getBounds();
+ Rectangle dpBounds = fRendering.fBinaryPane.getBounds();
+ Rectangle tpBounds = fRendering.fTextPane.getBounds();
ScrollBar hBar = fRendering.getHorizontalBar();
- Point adjustedCaret = null;
+ Point adjustedCaret = null;
int leftPaneEdge = 0;
int rightPaneEdge = 0;
- int eolComparison = 0;
+ int eolLocation = 0;
int bolSelection = 0;
int eolSelection = 0;
@@ -549,7 +550,7 @@ public abstract class AbstractPane extends Canvas
rightPaneEdge = vpBounds.x + vpBounds.width;
bolSelection = hBar.getMinimum();
eolSelection = apBounds.width + dpBounds.width - (vpBounds.width/2);
- eolComparison = apBounds.width + dpBounds.width - 10;
+ eolLocation = apBounds.width + dpBounds.width - 10;
adjustedCaret = new Point(fCaret.getLocation().x + dpBounds.x + 16, fCaret.getLocation().y);
}
else if (this instanceof TextPane)
@@ -558,7 +559,7 @@ public abstract class AbstractPane extends Canvas
rightPaneEdge = leftPaneEdge + (vpBounds.width - tpBounds.x);
bolSelection = apBounds.width + dpBounds.width - 36;
eolSelection = hBar.getMaximum();
- eolComparison = apBounds.width + dpBounds.width + tpBounds.width - 22;
+ eolLocation = apBounds.width + dpBounds.width + tpBounds.width - 22;
adjustedCaret = new Point(fCaret.getLocation().x + apBounds.width + dpBounds.width, fCaret.getLocation().y);
}
else
@@ -566,18 +567,37 @@ public abstract class AbstractPane extends Canvas
if (fCaretAddress.compareTo(vpStart) < 0 || fCaretAddress.compareTo(vpEnd) >= 0)
{
- // Up or Down arrow: Scroll the viewport up or down by one row.
+ // The caret was moved outside the viewport bounds: Scroll the
+ // viewport up or down by a row, depending on where the caret is
+
+ boolean upArrow = fCaretAddress.compareTo(vpStart) <= 0;
+ ScrollBar vBar = fRendering.getVerticalBar();
+ vBar.setSelection(vBar.getSelection() + (upArrow ? -1 : 1));
+ vBar.notifyListeners(SWT.Selection, new Event());
+
+ // Check to see if we're at the beginning or end of a line, and
+ // move the scrollbar, if necessary, to keep the caret in view.
+
+ int currentCaretLocation = fCaret.getLocation().x + dpBounds.x + 16;
+ int lowEolLimit = eolLocation - 1;
+ int highEolLimit = eolLocation + 1;
- ScrollBar vBar = fRendering.getVerticalBar();
- vBar.setSelection(vBar.getSelection() + (fCaretAddress.compareTo(vpStart) <= 0 ? -1 : 1));
- vBar.notifyListeners(SWT.Selection, new Event());
- ensureCaretWithinViewport();
+ if (fCaret.getLocation().x == 2)
+ {
+ hBar.setSelection(bolSelection);
+ hBar.notifyListeners(SWT.Selection, new Event());
+ }
+ else if (upArrow && ((currentCaretLocation >= lowEolLimit && currentCaretLocation <= highEolLimit)))
+ {
+ hBar.setSelection(eolSelection);
+ hBar.notifyListeners(SWT.Selection, new Event());
+ }
}
else if (!vpBounds.contains(adjustedCaret))
{
// Left or Right arrow: The caret is now outside the viewport and beyond the pane. Calculate
- // a new pane position at [up to] 33% left or right in the viewport, to center the caret; use a
- // positive or negative offset depending on which direction we're scrolling.
+ // a new pane position at [up to] 33% left or right in the viewport, to center the caret; use a
+ // positive or negative offset depending on which direction we're scrolling.
int hBarOffset = (rightPaneEdge - leftPaneEdge) / 3;
int newHBarSel = hBar.getSelection() + (adjustedCaret.x > rightPaneEdge ? hBarOffset : -hBarOffset);
@@ -587,10 +607,10 @@ public abstract class AbstractPane extends Canvas
// Beginning of a line
hBar.setSelection(bolSelection);
}
- else if (adjustedCaret.x == eolComparison)
+ else if (adjustedCaret.x == eolLocation)
{
- // End of a line
- hBar.setSelection(eolSelection);
+ // End of a line
+ hBar.setSelection(eolSelection);
}
else if (adjustedCaret.x > rightPaneEdge)
{
@@ -609,7 +629,7 @@ public abstract class AbstractPane extends Canvas
}
else
{
- // Caret is inside the viewport
+ // Caret is inside the viewport
return;
}

Back to the top