comparison dwt/widgets/Link.d @ 77:990305995bc6

Ported dwt.widgets.Spinner
author Jacob Carlborg <doob@me.com>
date Wed, 24 Dec 2008 13:06:45 +0100
parents 3607217555f2
children c7f7f4d7091a
comparison
equal deleted inserted replaced
76:3f1bfbd329c0 77:990305995bc6
37 37
38 import objc = dwt.internal.objc.runtime; 38 import objc = dwt.internal.objc.runtime;
39 import dwt.widgets.Composite; 39 import dwt.widgets.Composite;
40 import dwt.widgets.Control; 40 import dwt.widgets.Control;
41 41
42 alias tango.text.Text.Text!(char) Text8;
43 42
44 /** 43 /**
45 * Instances of this class represent a selectable 44 * Instances of this class represent a selectable
46 * user interface object that displays a text with 45 * user interface object that displays a text with
47 * links. 46 * links.
260 String parse (String string) { 259 String parse (String string) {
261 int length_ = string.length (); 260 int length_ = string.length ();
262 offsets = new Point [length_ / 4]; 261 offsets = new Point [length_ / 4];
263 ids = new String [length_ / 4]; 262 ids = new String [length_ / 4];
264 mnemonics = new int [length_ / 4 + 1]; 263 mnemonics = new int [length_ / 4 + 1];
265 Text8 result = new Text8 (); 264 StringBuffer result = new StringBuffer ();
266 char [] buffer = new char [length_]; 265 char [] buffer = new char [length_];
267 string.getChars (0, string.length (), buffer, 0); 266 string.getChars (0, string.length (), buffer, 0);
268 int index = 0, state = 0, linkIndex = 0; 267 int index = 0, state = 0, linkIndex = 0;
269 int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0; 268 int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0;
270 while (index < length_) { 269 while (index < length_) {
386 mnemonics = newMnemonics; 385 mnemonics = newMnemonics;
387 } 386 }
388 return result.toString (); 387 return result.toString ();
389 } 388 }
390 389
391 int parseMnemonics (char[] buffer, int start, int end, Text8 result) { 390 int parseMnemonics (char[] buffer, int start, int end, StringBuffer result) {
392 int mnemonic = -1, index = start; 391 int mnemonic = -1, index = start;
393 while (index < end) { 392 while (index < end) {
394 if (buffer [index] is '&') { 393 if (buffer [index] is '&') {
395 if (index + 1 < end && buffer [index + 1] is '&') { 394 if (index + 1 < end && buffer [index + 1] is '&') {
396 result.append (buffer [index]); 395 result.append (buffer [index]);