Mercurial > projects > dwt-win
changeset 125:8b6d038b7f79
uncommented getCodePage for compatibility and made the parse statemachine work only with ascii to ensure proper parsing.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 12 Feb 2008 02:23:29 +0100 |
parents | 1da8c82b1c84 |
children | 8d7572b6f3f6 |
files | dwt/widgets/Link.d |
diffstat | 1 files changed, 21 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/widgets/Link.d Tue Feb 12 02:21:26 2008 +0100 +++ b/dwt/widgets/Link.d Tue Feb 12 02:23:29 2008 +0100 @@ -178,7 +178,7 @@ auto hDC = OS.GetDC (handle); auto newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); auto oldFont = OS.SelectObject (hDC, newFont); - TCHAR[] buffer = StrToTCHARs (/+getCodePage (),+/ parse (text)); + TCHAR[] buffer = StrToTCHARs (getCodePage (), parse (text)); RECT rect; int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX; if (wHint !is DWT.DEFAULT) { @@ -410,8 +410,24 @@ string.getChars (0, string.length, buffer, 0); int index = 0, state = 0, linkIndex = 0; int start = 0, tagStart = 0, linkStart = 0, endtagStart = 0, refStart = 0; + while (index < length_) { - char c = CharacterToLower (buffer [index]); + + // instead Character.toLower + // only needed for the control symbols, which are always ascii + char c = buffer[index]; + if( c >= 'A' && c <= 'Z' ){ + c -= ( 'A' - 'a' ); + } + + // only simple ascii whitespace needed + bool isWhitespace(char w ){ + switch(w){ + case ' ': return true; + default : return false; + } + } + switch (state) { case 0: if (c is '<') { @@ -432,7 +448,7 @@ state++; break; default: - if (CharacterIsWhitespace(c)) break; + if (isWhitespace(c)) break; else state = 13; } break; @@ -491,7 +507,7 @@ } break; case 13: - if (CharacterIsWhitespace (c)) { + if (isWhitespace (c)) { state = 0; } else if (c is '='){ state++; @@ -624,7 +640,7 @@ * text to a space instead. */ if (string.length is 0) string = " "; //$NON-NLS-1$ - TCHAR* buffer = StrToTCHARz (/+getCodePage (),+/ string); + TCHAR* buffer = StrToTCHARz (getCodePage (), string); OS.SetWindowText (handle, buffer); parse (text); enableWidget (enabled);