# HG changeset patch # User Frank Benoit # Date 1219390091 -7200 # Node ID 8d6ec2b0357cc600a8537424cc08866a9b57f468 # Parent da0f1a62cabaf3c7a1d029c5780d6c37d7dbf835 Fix: OBJ replace marker in Snippet217 diff -r da0f1a62caba -r 8d6ec2b0357c snippets/styledtext/Snippet217.d --- 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 +}