Changeset 144:7248e4c09c4f
- Timestamp:
- 08/07/08 17:04:04
(4 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
Fix: make TextEditor? not using the tango.util.collection
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r80 |
r144 |
|
| 11 | 11 | * Thomas Graber <d4rkdragon@gmail.com> |
|---|
| 12 | 12 | *******************************************************************************/ |
|---|
| 13 | | module examples.texteditor.Images; |
|---|
| | 13 | module texteditor.Images; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | import dwt.dwthelper.InputStream; |
|---|
| r115 |
r144 |
|
| 11 | 11 | * Thomas Graber <d4rkdragon@gmail.com> |
|---|
| 12 | 12 | *******************************************************************************/ |
|---|
| 13 | | module examples.texteditor.TextEditor; |
|---|
| | 13 | module texteditor.TextEditor; |
|---|
| 14 | 14 | |
|---|
| 15 | 15 | import dwt.DWT; |
|---|
| … | … | |
| 40 | 40 | import dwt.dwthelper.utils; |
|---|
| 41 | 41 | |
|---|
| 42 | | import tango.util.collection.ArraySeq; |
|---|
| 43 | | |
|---|
| 44 | | import examples.texteditor.Images; |
|---|
| | 42 | import texteditor.Images; |
|---|
| 45 | 43 | |
|---|
| 46 | 44 | version( JIVE ){ |
|---|
| … | … | |
| 55 | 53 | StyledText text; |
|---|
| 56 | 54 | Images images; |
|---|
| 57 | | alias ArraySeq!(StyleRange) StyleCache; |
|---|
| 58 | | StyleCache cachedStyles; |
|---|
| | 55 | StyleRange[] cachedStyles; |
|---|
| 59 | 56 | |
|---|
| 60 | 57 | Color RED = null; |
|---|
| … | … | |
| 334 | 331 | // handle the pasting of styles would be to access the Clipboard directly and |
|---|
| 335 | 332 | // parse the RTF text. |
|---|
| 336 | | cachedStyles = new StyleCache(); |
|---|
| | 333 | cachedStyles = null; |
|---|
| 337 | 334 | Point sel = text.getSelectionRange(); |
|---|
| 338 | 335 | int startX = sel.x; |
|---|
| … | … | |
| 341 | 338 | if (style !is null) { |
|---|
| 342 | 339 | style.start = style.start - startX; |
|---|
| 343 | | if (cachedStyles.toArray().length > 0) { |
|---|
| 344 | | StyleRange lastStyle = cachedStyles.tail(); |
|---|
| | 340 | if (cachedStyles.length > 0) { |
|---|
| | 341 | StyleRange lastStyle = cachedStyles[$-1]; |
|---|
| 345 | 342 | if (lastStyle.similarTo(style) && lastStyle.start + lastStyle.length is style.start) { |
|---|
| 346 | 343 | lastStyle.length++; |
|---|
| 347 | 344 | } else { |
|---|
| 348 | | cachedStyles.append(style); |
|---|
| | 345 | cachedStyles ~= style; |
|---|
| 349 | 346 | } |
|---|
| 350 | 347 | } else { |
|---|
| 351 | | cachedStyles.append(style); |
|---|
| | 348 | cachedStyles ~= style; |
|---|
| 352 | 349 | } |
|---|
| 353 | 350 | } |
|---|
| … | … | |
| 360 | 357 | void handleExtendedModify(ExtendedModifyEvent event) { |
|---|
| 361 | 358 | if (event.length is 0) return; |
|---|
| 362 | | StyleRange style; |
|---|
| 363 | 359 | //PORTING event.length is char count, but it needs to decide on codepoint count |
|---|
| 364 | 360 | auto cont = text.getTextRange(event.start, event.length); |
|---|
| 365 | 361 | if ( codepointCount(cont) is 1 || cont == text.getLineDelimiter()) { |
|---|
| | 362 | StyleRange style; |
|---|
| 366 | 363 | // Have the new text take on the style of the text to its right (during |
|---|
| 367 | 364 | // typing) if no style information is active. |
|---|