From 49d3b50f8ee9e4ff7fe05fa25c1cb8813fe534c8 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 25 Oct 2002 21:58:42 +0000 Subject: [PATCH] Implementing editor features of Memory view. --- .../ui/views/memory/MemoryPresentation.java | 36 +++++++++++++------ .../internal/ui/views/memory/MemoryText.java | 6 ++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java index ae1f99e8e85..b7f209bfbb9 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryPresentation.java @@ -13,7 +13,9 @@ import java.util.List; import org.eclipse.cdt.debug.core.ICMemoryManager; import org.eclipse.cdt.debug.core.IFormattedMemoryBlock; 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.debug.core.DebugException; import org.eclipse.swt.graphics.Point; /** @@ -35,7 +37,7 @@ public class MemoryPresentation private List fAddressZones; private List fChangedZones; private List fDirtyZones; - + private boolean fDisplayAscii = true; /** @@ -78,15 +80,6 @@ public class MemoryPresentation return sb.toString(); } - public int getItemSize( int offset ) - { - return -1; - } - - public void setItem( int offset, String item ) - { - } - public String[] getText( Point[] zones ) { return new String[0]; @@ -453,4 +446,27 @@ public class MemoryPresentation return getMemoryBlock().displayASCII(); return false; } + + protected void textChanged( int offset, char newChar, char[] replacedText ) + { + byte b = 0; + if ( isInDataArea( offset ) ) + { + } + if ( isInAsciiArea( offset ) ) + { + b = CDebugUtils.charToByte( newChar ); + } + if ( getMemoryBlock() != null ) + { + try + { + getMemoryBlock().setValue( offset, new byte[] { b } ); + } + catch( DebugException e ) + { + // ignore + } + } + } } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java index 51cb5c4ae62..84a2efd4bac 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryText.java @@ -83,9 +83,9 @@ public class MemoryText { if ( event.length != 1 ) return; - int offset = fText.getCaretOffset() - 1; - int size = fPresentation.getItemSize( offset ); - fPresentation.setItem( offset, fText.getText().substring( offset, offset + size ) ); + fPresentation.textChanged( event.start, + fText.getText().charAt( event.start ), + event.replacedText.toCharArray() ); Point[] zones = fPresentation.getDirtyZones(); refresh( zones, fPresentation.getText( zones ) ); }