Mercurial > projects > dwt-addons
diff dwtx/jface/text/DefaultUndoManager.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 3678e4f1a766 |
children | c3583c6ec027 |
line wrap: on
line diff
--- a/dwtx/jface/text/DefaultUndoManager.d Wed Aug 27 14:49:30 2008 +0200 +++ b/dwtx/jface/text/DefaultUndoManager.d Mon Sep 08 00:51:37 2008 +0200 @@ -167,6 +167,7 @@ import dwt.events.KeyListener; import dwt.events.MouseEvent; import dwt.events.MouseListener; +import dwt.widgets.Event; import dwt.widgets.Display; import dwt.widgets.Shell; import dwtx.core.commands.ExecutionException; @@ -453,9 +454,9 @@ protected void updateCommand() { fText= fTextBuffer.toString(); - fTextBuffer.setLength(0); + fTextBuffer.truncate(0); fPreservedText= fPreservedTextBuffer.toString(); - fPreservedTextBuffer.setLength(0); + fPreservedTextBuffer.truncate(0); } /** @@ -535,7 +536,7 @@ String delimiter= ", "; //$NON-NLS-1$ StringBuffer text= new StringBuffer(super.toString()); text.append("\n"); //$NON-NLS-1$ - text.append(this.getClass().getName()); + text.append(this.classinfo.name); text.append(" undo modification stamp: "); //$NON-NLS-1$ text.append(fUndoModificationStamp); text.append(" redo modification stamp: "); //$NON-NLS-1$ @@ -584,7 +585,7 @@ class CompoundTextCommand : TextCommand { /** The list of individual commands */ - private List fCommands= new ArrayList(); + private List fCommands; /** * Creates a new compound text command. @@ -594,6 +595,7 @@ */ this(IUndoContext context) { super(context); + fCommands= new ArrayList(); } /** @@ -882,12 +884,12 @@ case OperationHistoryEvent.ABOUT_TO_REDO: // if this is one of our operations if (event.getOperation().hasContext(fUndoContext)) { - fTextViewer.getTextWidget().getDisplay().syncExec(dgRunnable((Event event_, int type_ ) { + fTextViewer.getTextWidget().getDisplay().syncExec(dgRunnable((OperationHistoryEvent event_, int type_ ) { // if we are undoing/redoing a command we generated, then ignore // the document changes associated with this undo or redo. - if (cast(TextCommand)event_.getOperation() ) { + if (event_.getOperation() ) { if ( cast(TextViewer)fTextViewer ) - (cast(TextViewer)fTextViewer).ignoreAutoEditStrategies(true); + (cast(TextViewer)fTextViewer).ignoreAutoEditStrategies_package(true); listenToTextChanges(false); // in the undo case only, make sure compounds are closed @@ -916,7 +918,7 @@ listenToTextChanges(true); fOperation= null; if ( cast(TextViewer)fTextViewer ) - (cast(TextViewer)fTextViewer).ignoreAutoEditStrategies(false); + (cast(TextViewer)fTextViewer).ignoreAutoEditStrategies_package(false); } }); } @@ -927,9 +929,9 @@ } /** Text buffer to collect text which is inserted into the viewer */ - private StringBuffer fTextBuffer= new StringBuffer(); + private StringBuffer fTextBuffer; /** Text buffer to collect viewer content which has been replaced */ - private StringBuffer fPreservedTextBuffer= new StringBuffer(); + private StringBuffer fPreservedTextBuffer; /** The document modification stamp for undo. */ protected long fPreservedUndoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; /** The document modification stamp for redo. */ @@ -989,6 +991,9 @@ * @param undoLevel the length of this manager's history */ public this(int undoLevel) { + fTextBuffer= new StringBuffer(); + fPreservedTextBuffer= new StringBuffer(); + fHistoryListener= new HistoryListener(); fHistory= OperationHistoryFactory.getOperationHistory(); setMaximalUndoLevel(undoLevel); @@ -1157,7 +1162,7 @@ if (index > -1) { char c; int length= text.length(); - for (int i= delimiters[index].length(); i < length; i++) { + for (int i= delimiters[index].length; i < length; i++) { c= text.charAt(i); if (c !is ' ' && c !is '\t') return false; @@ -1220,7 +1225,7 @@ } else { if (length is 0) { // text will be deleted by backspace or DEL key or empty clipboard - length= replacedText.length(); + length= replacedText.length; String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters(); if ((length is 1) || TextUtilities.equals(delimiters, replacedText) > -1) { @@ -1243,7 +1248,8 @@ // repeated backspace // insert in buffer and extend command range - fPreservedTextBuffer.insert(0, replacedText); + fPreservedTextBuffer.select(0, 0); + fPreservedTextBuffer.replace(replacedText); fCurrent.fStart= modelStart; } else { @@ -1275,7 +1281,7 @@ // text will be replaced if (length is 1) { - length= replacedText.length(); + length= replacedText.length; String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters(); if ((length is 1) || TextUtilities.equals(delimiters, replacedText) > -1) { @@ -1328,7 +1334,7 @@ shell= st.getShell(); } if (Display.getCurrent() !is null) - MessageDialog.openError(shell, title, ex.getLocalizedMessage()); + MessageDialog.openError(shell, title, ex.msg/+getLocalizedMessage()+/); else { Display display; Shell finalShell= shell; @@ -1337,7 +1343,7 @@ else display= Display.getDefault(); display.syncExec(dgRunnable( { - MessageDialog.openError(finalShell, title, ex.getLocalizedMessage()); + MessageDialog.openError(finalShell, title, ex.msg/+getLocalizedMessage()+/); })); } } @@ -1384,8 +1390,8 @@ fCurrent= null; fTextViewer= null; disposeCommandStack(); - fTextBuffer= null; - fPreservedTextBuffer= null; + fTextBuffer.clear(); + fPreservedTextBuffer.clear(); fUndoContext= null; } } @@ -1400,8 +1406,8 @@ fFoldingIntoCompoundChange= false; fInserting= false; fOverwriting= false; - fTextBuffer.setLength(0); - fPreservedTextBuffer.setLength(0); + fTextBuffer.truncate(0); + fPreservedTextBuffer.truncate(0); fPreservedUndoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; fPreservedRedoModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP; }