1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

[219009] TraditionalRendering.getSelectedBytes() ignores selection

This commit is contained in:
Ted Williams 2008-03-11 05:02:05 +00:00
parent 5d2e5b52e0
commit 8f63cc5bbf
3 changed files with 37 additions and 5 deletions

View file

@ -12,6 +12,8 @@ public interface IMemorySelection
public BigInteger getEnd();
public BigInteger getStartLow();
public void setStart(BigInteger high, BigInteger low);
public void setEnd(BigInteger high, BigInteger low);

View file

@ -1237,6 +1237,10 @@ public class Rendering extends Composite implements IDebugEventSetListener
return fStartLow;
}
public BigInteger getStartLow() {
return fStartLow;
}
public BigInteger getEnd()
{
// if there is no end, return null

View file

@ -20,6 +20,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.dd.debug.memory.renderings.traditional.Rendering.Selection;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IMemoryBlockExtension;
@ -982,20 +983,45 @@ public class TraditionalRendering extends AbstractMemoryRendering implements IRe
// selection is terminology for caret position
public BigInteger getSelectedAddress() {
return fRendering.getCaretAddress();
IMemorySelection selection = fRendering.getSelection();
if (selection == null || selection.getStart() == null)
return fRendering.getCaretAddress();
return selection.getStartLow();
}
public MemoryByte[] getSelectedAsBytes() {
try
try
{
return fRendering.getViewportCache().getBytes(
fRendering.getCaretAddress(), fRendering.getBytesPerColumn());
// default to the caret address and the cell count size
BigInteger startAddr = fRendering.getCaretAddress();
int byteCount = fRendering.getBytesPerColumn();
// Now see if there's a selection
IMemorySelection selection = fRendering.getSelection();
if (selection != null && selection.getStart() != null)
{
// The implementation is such that just having a caret somewhere
// (without multiple cells being selected) constitutes a selection,
// except for when the rendering is in its initial state. I.e.,
// just because we get here doesn't mean the user has selected more
// than one cell.
startAddr = getSelectedAddress();
if (selection.getHigh() != null)
{
byteCount = selection.getHigh().subtract(selection.getLow()).intValue() * fRendering.getAddressableSize();
}
}
return fRendering.getViewportCache().getBytes(startAddr, byteCount);
}
catch(DebugException de)
{
// FIXME log?
return null;
}
}
}
public void goToAddress(final BigInteger address) throws DebugException {