changeset 157:8d6ec2b0357c

Fix: OBJ replace marker in Snippet217
author Frank Benoit <benoit@tionex.de>
date Fri, 22 Aug 2008 09:28:11 +0200
parents da0f1a62caba
children 683d3e7b184a
files snippets/styledtext/Snippet217.d
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/snippets/styledtext/Snippet217.d	Fri Aug 22 09:27:49 2008 +0200
+++ b/snippets/styledtext/Snippet217.d	Fri Aug 22 09:28:11 2008 +0200
@@ -48,11 +48,12 @@
     import jive.stacktrace;
 }
 
+const char[] OBJ_MARKER = "\uFFFC";
 void main() {
     static StyledText styledText;
     static String text =
         "This snippet shows how to embed widgets in a StyledText.\n"
-        "Here is one: \uFFFC, and here is another: \uFFFC.";
+        "Here is one: " ~ OBJ_MARKER ~ ", and here is another: " ~ OBJ_MARKER ~ ".";
     static int[] offsets;
     static Control[] controls;
     static int MARGIN = 5;
@@ -60,7 +61,7 @@
     void addControl(Control control, int offset) {
         StyleRange style = new StyleRange ();
         style.start = offset;
-        style.length = 1;
+        style.length = OBJ_MARKER.length;
         control.pack();
         Rectangle rect = control.getBounds();
         int ascent = 2*rect.height/3;
@@ -89,10 +90,10 @@
     offsets = new int[controls.length];
     int lastOffset = 0;
     for (int i = 0; i < controls.length; i++) {
-        int offset = text.indexOf("\uFFFC", lastOffset);
+        int offset = text.indexOf( OBJ_MARKER, lastOffset);
         offsets[i] = offset;
         addControl(controls[i], offsets[i]);
-        lastOffset = offset + 1;
+        lastOffset = offset + OBJ_MARKER.length;
     }
 
     void onVerify(Event e) {
@@ -146,4 +147,4 @@
     }
     font.dispose();
     display.dispose();
-}
\ No newline at end of file
+}