mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-21 16:05:25 +02:00
Implementing editing features of the memory view.
This commit is contained in:
parent
347a692269
commit
e4a57a52b7
7 changed files with 107 additions and 33 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2002-10-28 Mikhail Khodjaiants
|
||||||
|
Implementing editing features of the memory view.
|
||||||
|
* IFormattedMemoryBlockRow.java
|
||||||
|
* CFormattedMemoryBlock.java
|
||||||
|
|
||||||
2002-10-27 Mikhail Khodjaiants
|
2002-10-27 Mikhail Khodjaiants
|
||||||
* IFormattedMemoryBlock.java: added the 'setItemValue' method.
|
* IFormattedMemoryBlock.java: added the 'setItemValue' method.
|
||||||
* CFormattedMemoryBlock.java: implementation of the 'setItemValue' method.
|
* CFormattedMemoryBlock.java: implementation of the 'setItemValue' method.
|
||||||
|
|
|
@ -34,4 +34,6 @@ public interface IFormattedMemoryBlockRow
|
||||||
* @return the ASCII dump for this row
|
* @return the ASCII dump for this row
|
||||||
*/
|
*/
|
||||||
String getASCII();
|
String getASCII();
|
||||||
|
|
||||||
|
Integer[] getDirtyItems();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
package org.eclipse.cdt.debug.internal.core.model;
|
package org.eclipse.cdt.debug.internal.core.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
@ -38,6 +38,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
private long fAddress;
|
private long fAddress;
|
||||||
private String[] fData;
|
private String[] fData;
|
||||||
private String fAscii;
|
private String fAscii;
|
||||||
|
private boolean[] fDirtyItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CFormattedMemoryBlockRow.
|
* Constructor for CFormattedMemoryBlockRow.
|
||||||
|
@ -47,6 +48,8 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
fAddress = address;
|
fAddress = address;
|
||||||
fData = data;
|
fData = data;
|
||||||
fAscii = ascii;
|
fAscii = ascii;
|
||||||
|
fDirtyItems = new boolean[fData.length];
|
||||||
|
Arrays.fill( fDirtyItems, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -72,6 +75,26 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
{
|
{
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setData( int colIndex, String newValue )
|
||||||
|
{
|
||||||
|
if ( colIndex < fData.length )
|
||||||
|
{
|
||||||
|
fData[colIndex] = newValue;
|
||||||
|
fDirtyItems[colIndex] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer[] getDirtyItems()
|
||||||
|
{
|
||||||
|
ArrayList list = new ArrayList( fDirtyItems.length );
|
||||||
|
for ( int i = 0; i < fDirtyItems.length; ++i )
|
||||||
|
{
|
||||||
|
if ( fDirtyItems[i] )
|
||||||
|
list.add( new Integer( i ) );
|
||||||
|
}
|
||||||
|
return (Integer[])list.toArray( new Integer[list.size()] );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String fAddressExpression;
|
private String fAddressExpression;
|
||||||
|
@ -84,7 +107,6 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
private char fPaddingChar = '.';
|
private char fPaddingChar = '.';
|
||||||
private List fRows = null;
|
private List fRows = null;
|
||||||
private Long[] fChangedAddresses = new Long[0];
|
private Long[] fChangedAddresses = new Long[0];
|
||||||
private HashSet fDirtyBytes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CFormattedMemoryBlock.
|
* Constructor for CFormattedMemoryBlock.
|
||||||
|
@ -123,7 +145,6 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
fNumberOfColumns = numberOfColumns;
|
fNumberOfColumns = numberOfColumns;
|
||||||
fDisplayAscii = true;
|
fDisplayAscii = true;
|
||||||
fPaddingChar = paddingChar;
|
fPaddingChar = paddingChar;
|
||||||
fDirtyBytes = new HashSet();
|
|
||||||
getCDISession().getEventManager().addEventListener( this );
|
getCDISession().getEventManager().addEventListener( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +185,7 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public boolean displayASCII()
|
public boolean displayASCII()
|
||||||
{
|
{
|
||||||
return fDisplayAscii;
|
return ( getWordSize() == IFormattedMemoryBlock.MEMORY_SIZE_BYTE && fDisplayAscii );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -347,8 +368,6 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
fCDIMemoryBlock = null;
|
fCDIMemoryBlock = null;
|
||||||
}
|
}
|
||||||
getCDISession().getEventManager().removeEventListener( this );
|
getCDISession().getEventManager().removeEventListener( this );
|
||||||
fDirtyBytes.clear();
|
|
||||||
fDirtyBytes = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -436,7 +455,6 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
private void handleChangedEvent( ICDIMemoryChangedEvent event )
|
private void handleChangedEvent( ICDIMemoryChangedEvent event )
|
||||||
{
|
{
|
||||||
resetRows();
|
resetRows();
|
||||||
resetDirtyBytes();
|
|
||||||
setChangedAddresses( event.getAddresses() );
|
setChangedAddresses( event.getAddresses() );
|
||||||
fireChangeEvent( DebugEvent.CONTENT );
|
fireChangeEvent( DebugEvent.CONTENT );
|
||||||
}
|
}
|
||||||
|
@ -477,10 +495,15 @@ public class CFormattedMemoryBlock extends CDebugElement
|
||||||
*/
|
*/
|
||||||
public void setItemValue( int index, String newValue ) throws DebugException
|
public void setItemValue( int index, String newValue ) throws DebugException
|
||||||
{
|
{
|
||||||
}
|
int rowIndex = index / getNumberOfColumns();
|
||||||
|
if ( rowIndex < getRows().length )
|
||||||
private void resetDirtyBytes()
|
{
|
||||||
{
|
CFormattedMemoryBlockRow row = (CFormattedMemoryBlockRow)getRows()[rowIndex];
|
||||||
fDirtyBytes.clear();
|
int colIndex = index % getNumberOfColumns();
|
||||||
|
if ( colIndex < row.getData().length )
|
||||||
|
{
|
||||||
|
row.setData( colIndex, newValue );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2002-10-28 Mikhail Khodjaiants
|
||||||
|
Implementing editing features of the memory view.
|
||||||
|
* MemoryPresentation.java
|
||||||
|
* MemoryControlArea.java
|
||||||
|
* MemoryText.java
|
||||||
|
|
||||||
2002-10-27 Mikhail Khodjaiants
|
2002-10-27 Mikhail Khodjaiants
|
||||||
* MemoryPresentation.java: adding editing features to the memory view.
|
* MemoryPresentation.java: adding editing features to the memory view.
|
||||||
|
|
||||||
|
|
|
@ -181,6 +181,7 @@ public class MemoryControlArea extends Composite
|
||||||
{
|
{
|
||||||
fAddressText.setText( ( getPresentation() != null ) ? getPresentation().getAddressExpression() : "" );
|
fAddressText.setText( ( getPresentation() != null ) ? getPresentation().getAddressExpression() : "" );
|
||||||
fMemoryText.refresh();
|
fMemoryText.refresh();
|
||||||
|
fMemoryView.updateObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setMemoryManager( ICMemoryManager mm )
|
protected void setMemoryManager( ICMemoryManager mm )
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,6 +14,7 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
import org.eclipse.cdt.debug.core.ICMemoryManager;
|
||||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
||||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow;
|
import org.eclipse.cdt.debug.core.IFormattedMemoryBlockRow;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.CDebugUtils;
|
||||||
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.swt.graphics.Point;
|
import org.eclipse.swt.graphics.Point;
|
||||||
|
@ -35,7 +37,6 @@ public class MemoryPresentation
|
||||||
|
|
||||||
private List fAddressZones;
|
private List fAddressZones;
|
||||||
private List fChangedZones;
|
private List fChangedZones;
|
||||||
private List fDirtyZones;
|
|
||||||
|
|
||||||
private boolean fDisplayAscii = true;
|
private boolean fDisplayAscii = true;
|
||||||
|
|
||||||
|
@ -46,7 +47,6 @@ public class MemoryPresentation
|
||||||
{
|
{
|
||||||
fAddressZones = new LinkedList();
|
fAddressZones = new LinkedList();
|
||||||
fChangedZones = new LinkedList();
|
fChangedZones = new LinkedList();
|
||||||
fDirtyZones = new LinkedList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFormattedMemoryBlock getMemoryBlock()
|
public IFormattedMemoryBlock getMemoryBlock()
|
||||||
|
@ -123,7 +123,31 @@ public class MemoryPresentation
|
||||||
|
|
||||||
public Point[] getDirtyZones()
|
public Point[] getDirtyZones()
|
||||||
{
|
{
|
||||||
return (Point[])fDirtyZones.toArray( new Point[fDirtyZones.size()] );
|
ArrayList dirtyZones = new ArrayList();
|
||||||
|
if ( fBlock != null )
|
||||||
|
{
|
||||||
|
IFormattedMemoryBlockRow[] rows = fBlock.getRows();
|
||||||
|
for ( int i = 0; i < rows.length; ++i )
|
||||||
|
{
|
||||||
|
int rowOffset = i * getRowLength();
|
||||||
|
Integer[] dirtyItems = rows[i].getDirtyItems();
|
||||||
|
for ( int j = 0; j < dirtyItems.length; ++j )
|
||||||
|
{
|
||||||
|
int offset = rowOffset +
|
||||||
|
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
||||||
|
dirtyItems[j].intValue() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS);
|
||||||
|
dirtyZones.add( new Point( offset, offset + getDataItemLength() ) );
|
||||||
|
if ( displayASCII() )
|
||||||
|
{
|
||||||
|
offset = rowOffset +
|
||||||
|
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
||||||
|
getNumberOfDataItemsInRow() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS);
|
||||||
|
dirtyZones.add( new Point( offset, offset + (getDataItemLength() / 2) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (Point[])dirtyZones.toArray( new Point[dirtyZones.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getStartAddress()
|
public String getStartAddress()
|
||||||
|
@ -159,9 +183,9 @@ public class MemoryPresentation
|
||||||
result.append( items[i] );
|
result.append( items[i] );
|
||||||
result.append( getInterval( INTERVAL_BETWEEN_DATA_ITEMS ) );
|
result.append( getInterval( INTERVAL_BETWEEN_DATA_ITEMS ) );
|
||||||
}
|
}
|
||||||
result.append( getInterval( INTERVAL_BETWEEN_DATA_AND_ASCII ) );
|
|
||||||
if ( displayASCII() )
|
if ( displayASCII() )
|
||||||
{
|
{
|
||||||
|
result.append( getInterval( INTERVAL_BETWEEN_DATA_AND_ASCII ) );
|
||||||
result.append( row.getASCII() );
|
result.append( row.getASCII() );
|
||||||
}
|
}
|
||||||
result.append( '\n' );
|
result.append( '\n' );
|
||||||
|
@ -450,20 +474,19 @@ public class MemoryPresentation
|
||||||
{
|
{
|
||||||
if ( getMemoryBlock() != null )
|
if ( getMemoryBlock() != null )
|
||||||
{
|
{
|
||||||
int index = -1;
|
int index = getDataItemIndex( offset );
|
||||||
if ( isInDataArea( offset ) )
|
|
||||||
{
|
|
||||||
index = getDataItemIndex( offset );
|
|
||||||
}
|
|
||||||
if ( isInAsciiArea( offset ) )
|
|
||||||
{
|
|
||||||
index = offset;
|
|
||||||
}
|
|
||||||
if ( index != -1 )
|
if ( index != -1 )
|
||||||
{
|
{
|
||||||
char[] chars = getDataItemChars( index );
|
char[] chars = getDataItemChars( index );
|
||||||
int itemOffset = getDataItemOffset( index );
|
if ( isInDataArea( offset ) )
|
||||||
chars[offset - itemOffset] = newChar;
|
{
|
||||||
|
int charIndex = getOffsetInDataItem( offset, index );
|
||||||
|
chars[charIndex] = newChar;
|
||||||
|
}
|
||||||
|
if ( isInAsciiArea( offset ) )
|
||||||
|
{
|
||||||
|
chars = CDebugUtils.getByteText( (byte)newChar );
|
||||||
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getMemoryBlock().setItemValue( index, new String( chars ) );
|
getMemoryBlock().setItemValue( index, new String( chars ) );
|
||||||
|
@ -479,7 +502,7 @@ public class MemoryPresentation
|
||||||
private int getDataItemIndex( int offset )
|
private int getDataItemIndex( int offset )
|
||||||
{
|
{
|
||||||
int row = offset / getRowLength();
|
int row = offset / getRowLength();
|
||||||
int pos = offset % getRowLength();
|
int pos = offset % getRowLength() - getAddressLength() - INTERVAL_BETWEEN_ADDRESS_AND_DATA;
|
||||||
for ( int i = 0; i < getNumberOfDataItemsInRow(); ++i )
|
for ( int i = 0; i < getNumberOfDataItemsInRow(); ++i )
|
||||||
{
|
{
|
||||||
if ( pos < i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) )
|
if ( pos < i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) )
|
||||||
|
@ -488,13 +511,17 @@ public class MemoryPresentation
|
||||||
pos < (i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getDataItemLength() )
|
pos < (i * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS)) + getDataItemLength() )
|
||||||
return i + (row * getNumberOfDataItemsInRow());
|
return i + (row * getNumberOfDataItemsInRow());
|
||||||
}
|
}
|
||||||
|
if ( displayASCII() && pos >= getNumberOfDataItemsInRow() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) + INTERVAL_BETWEEN_DATA_AND_ASCII )
|
||||||
|
{
|
||||||
|
return ((pos - ((getNumberOfDataItemsInRow() * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS) + INTERVAL_BETWEEN_DATA_AND_ASCII))) * 2 / getDataItemLength()) + row * getNumberOfDataItemsInRow();
|
||||||
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getDataItemOffset( int index )
|
private int getDataItemOffset( int index )
|
||||||
{
|
{
|
||||||
int row = index / getNumberOfDataItemsInRow();
|
int row = index / getNumberOfDataItemsInRow();
|
||||||
int pos = index % getDataItemLength();
|
int pos = index % getNumberOfDataItemsInRow();
|
||||||
return row * getRowLength() +
|
return row * getRowLength() +
|
||||||
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
getAddressLength() + INTERVAL_BETWEEN_ADDRESS_AND_DATA +
|
||||||
pos * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS);
|
pos * (getDataItemLength() + INTERVAL_BETWEEN_DATA_ITEMS);
|
||||||
|
@ -504,8 +531,8 @@ public class MemoryPresentation
|
||||||
{
|
{
|
||||||
if ( getMemoryBlock() != null )
|
if ( getMemoryBlock() != null )
|
||||||
{
|
{
|
||||||
int rowNumber = index / (getMemoryBlock().getNumberOfColumns() * getMemoryBlock().getWordSize());
|
int rowNumber = index / getMemoryBlock().getNumberOfColumns();
|
||||||
int pos = index % (getMemoryBlock().getNumberOfColumns() * getMemoryBlock().getWordSize());
|
int pos = index % getMemoryBlock().getNumberOfColumns();
|
||||||
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
|
IFormattedMemoryBlockRow[] rows = getMemoryBlock().getRows();
|
||||||
if ( rowNumber < rows.length )
|
if ( rowNumber < rows.length )
|
||||||
{
|
{
|
||||||
|
@ -518,4 +545,13 @@ public class MemoryPresentation
|
||||||
}
|
}
|
||||||
return new char[0];
|
return new char[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getOffsetInDataItem( int offset, int index )
|
||||||
|
{
|
||||||
|
if ( isInDataArea( offset ) )
|
||||||
|
{
|
||||||
|
return offset - getDataItemOffset( index );
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,11 +83,12 @@ public class MemoryText
|
||||||
{
|
{
|
||||||
if ( event.length != 1 )
|
if ( event.length != 1 )
|
||||||
return;
|
return;
|
||||||
|
int caretOffset = fText.getCaretOffset();
|
||||||
fPresentation.textChanged( event.start,
|
fPresentation.textChanged( event.start,
|
||||||
fText.getText().charAt( event.start ),
|
fText.getText().charAt( event.start ),
|
||||||
event.replacedText.toCharArray() );
|
event.replacedText.toCharArray() );
|
||||||
Point[] zones = fPresentation.getDirtyZones();
|
refresh();
|
||||||
refresh( zones, fPresentation.getText( zones ) );
|
fText.setCaretOffset( caretOffset );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void refresh()
|
public void refresh()
|
||||||
|
|
Loading…
Add table
Reference in a new issue