Mercurial > projects > dwt-addons
comparison dwtx/jface/internal/text/html/HTMLTextPresenter.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 7926b636c282 |
children |
comparison
equal
deleted
inserted
replaced
161:f8d52b926852 | 162:1a5b8f8129df |
---|---|
22 import dwtx.jface.internal.text.html.HTMLMessages; // packageimport | 22 import dwtx.jface.internal.text.html.HTMLMessages; // packageimport |
23 | 23 |
24 | 24 |
25 import dwt.dwthelper.utils; | 25 import dwt.dwthelper.utils; |
26 import dwtx.dwtxhelper.Collection; | 26 import dwtx.dwtxhelper.Collection; |
27 import dwtx.dwtxhelper.StringReader; | |
27 | 28 |
28 import dwt.custom.StyleRange; | 29 import dwt.custom.StyleRange; |
29 import dwt.graphics.Drawable; | 30 import dwt.graphics.Drawable; |
30 import dwt.graphics.GC; | 31 import dwt.graphics.GC; |
31 import dwt.widgets.Display; | 32 import dwt.widgets.Display; |
51 | 52 |
52 private int fCounter; | 53 private int fCounter; |
53 private bool fEnforceUpperLineLimit; | 54 private bool fEnforceUpperLineLimit; |
54 | 55 |
55 public this(bool enforceUpperLineLimit) { | 56 public this(bool enforceUpperLineLimit) { |
56 super(); | 57 // super(); |
57 fEnforceUpperLineLimit= enforceUpperLineLimit; | 58 fEnforceUpperLineLimit= enforceUpperLineLimit; |
58 } | 59 } |
59 | 60 |
60 public this() { | 61 public this() { |
61 this(true); | 62 this(true); |
103 | 104 |
104 private String getIndent(String line) { | 105 private String getIndent(String line) { |
105 int length= line.length(); | 106 int length= line.length(); |
106 | 107 |
107 int i= 0; | 108 int i= 0; |
108 while (i < length && Character.isWhitespace(line.charAt(i))) ++i; | 109 while (i < length && Character.isWhitespace(line.getRelativeCodePoint(i,0))) |
109 | 110 i += line.getRelativeCodePointOffset(i,1); |
110 return (i is length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$ | 111 |
112 return (i is length ? line : line.substring(0, i)) ~ " "; //$NON-NLS-1$ | |
111 } | 113 } |
112 | 114 |
113 /** | 115 /** |
114 * {@inheritDoc} | 116 * {@inheritDoc} |
115 * | 117 * |
131 | 133 |
132 GC gc= new GC(drawable); | 134 GC gc= new GC(drawable); |
133 try { | 135 try { |
134 | 136 |
135 StringBuffer buffer= new StringBuffer(); | 137 StringBuffer buffer= new StringBuffer(); |
136 int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight()); | 138 int maxNumberOfLines= cast(int) Math.round(maxHeight / gc.getFontMetrics().getHeight()); |
137 | 139 |
138 fCounter= 0; | 140 fCounter= 0; |
139 LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth); | 141 LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth); |
140 | 142 |
141 bool lastLineFormatted= false; | 143 bool lastLineFormatted= false; |
195 private String trim(StringBuffer buffer, TextPresentation presentation) { | 197 private String trim(StringBuffer buffer, TextPresentation presentation) { |
196 | 198 |
197 int length= buffer.length(); | 199 int length= buffer.length(); |
198 | 200 |
199 int end= length -1; | 201 int end= length -1; |
200 while (end >= 0 && Character.isWhitespace(buffer.charAt(end))) | 202 |
201 -- end; | 203 while (end >= 0 && Character.isWhitespace(buffer.slice().getRelativeCodePoint( end, -1 ))) |
202 | 204 end += buffer.slice().getRelativeCodePointOffset( end, -1 ); |
203 if (end is -1) | 205 |
206 if (end <= -1) | |
204 return ""; //$NON-NLS-1$ | 207 return ""; //$NON-NLS-1$ |
205 | 208 |
206 if (end < length -1) | 209 if (end < buffer.slice().getAbsoluteCodePointOffset( length, -1 )) |
207 buffer.delete_(end + 1, length); | 210 buffer.truncate(buffer.slice().getAbsoluteCodePointOffset( end, 1)); |
208 else | 211 else |
209 end= length; | 212 end= length; |
210 | 213 |
211 int start= 0; | 214 int start= 0; |
212 while (start < end && Character.isWhitespace(buffer.charAt(start))) | 215 while (start < end && Character.isWhitespace(buffer.slice().getRelativeCodePoint(start, 0))) |
213 ++ start; | 216 start += buffer.slice().getRelativeCodePointOffset( start, 1 ); |
214 | 217 |
215 buffer.delete_(0, start); | 218 buffer.select(0, start); |
219 buffer.remove(); | |
216 presentation.setResultWindow(new Region(start, buffer.length())); | 220 presentation.setResultWindow(new Region(start, buffer.length())); |
217 return buffer.toString(); | 221 return buffer.toString(); |
218 } | 222 } |
219 } | 223 } |
220 | 224 |