changeset 144:7248e4c09c4f

Fix: make TextEditor not using the tango.util.collection
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 23:04:04 +0200
parents 42c3056512ba
children 161f7698cfb8
files examples/texteditor/Images.d examples/texteditor/TextEditor.d
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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 <d4rkdragon@gmail.com>
  *******************************************************************************/
-module examples.texteditor.Images;
+module texteditor.Images;
 
 import dwt.dwthelper.InputStream;
 
--- 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 <d4rkdragon@gmail.com>
  *******************************************************************************/
-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();