# HG changeset patch # User Frank Benoit # Date 1218143044 -7200 # Node ID 7248e4c09c4f0a9ec88fcbc978580ce3c2a8b9d0 # Parent 42c3056512ba3f257c45d522ee87aecdd8a1762d Fix: make TextEditor not using the tango.util.collection diff -r 42c3056512ba -r 7248e4c09c4f examples/texteditor/Images.d --- a/examples/texteditor/Images.d Thu Aug 07 22:21:50 2008 +0200 +++ b/examples/texteditor/Images.d Thu Aug 07 23:04:04 2008 +0200 @@ -10,7 +10,7 @@ * Port to the D programming language: * Thomas Graber *******************************************************************************/ -module examples.texteditor.Images; +module texteditor.Images; import dwt.dwthelper.InputStream; diff -r 42c3056512ba -r 7248e4c09c4f examples/texteditor/TextEditor.d --- a/examples/texteditor/TextEditor.d Thu Aug 07 22:21:50 2008 +0200 +++ b/examples/texteditor/TextEditor.d Thu Aug 07 23:04:04 2008 +0200 @@ -10,7 +10,7 @@ * Port to the D programming language: * Thomas Graber *******************************************************************************/ -module examples.texteditor.TextEditor; +module texteditor.TextEditor; import dwt.DWT; import dwt.custom.ExtendedModifyEvent; @@ -39,9 +39,7 @@ import dwt.dwthelper.ResourceBundle; import dwt.dwthelper.utils; -import tango.util.collection.ArraySeq; - -import examples.texteditor.Images; +import texteditor.Images; version( JIVE ){ import jive.stacktrace; @@ -54,8 +52,7 @@ ToolBar toolBar; StyledText text; Images images; - alias ArraySeq!(StyleRange) StyleCache; - StyleCache cachedStyles; + StyleRange[] cachedStyles; Color RED = null; Color BLUE = null; @@ -333,22 +330,22 @@ // RTF format, but is not pasted in RTF format. The other way to // handle the pasting of styles would be to access the Clipboard directly and // parse the RTF text. - cachedStyles = new StyleCache(); + cachedStyles = null; Point sel = text.getSelectionRange(); int startX = sel.x; for (int i=sel.x; i<=sel.x+sel.y-1; i++) { StyleRange style = text.getStyleRangeAtOffset(i); if (style !is null) { style.start = style.start - startX; - if (cachedStyles.toArray().length > 0) { - StyleRange lastStyle = cachedStyles.tail(); + if (cachedStyles.length > 0) { + StyleRange lastStyle = cachedStyles[$-1]; if (lastStyle.similarTo(style) && lastStyle.start + lastStyle.length is style.start) { lastStyle.length++; } else { - cachedStyles.append(style); + cachedStyles ~= style; } } else { - cachedStyles.append(style); + cachedStyles ~= style; } } } @@ -359,10 +356,10 @@ */ void handleExtendedModify(ExtendedModifyEvent event) { if (event.length is 0) return; - StyleRange style; //PORTING event.length is char count, but it needs to decide on codepoint count auto cont = text.getTextRange(event.start, event.length); if ( codepointCount(cont) is 1 || cont == text.getLineDelimiter()) { + StyleRange style; // Have the new text take on the style of the text to its right (during // typing) if no style information is active. int caretOffset = text.getCaretOffset();