Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/StyledText.d @ 51:c01d033c633a
[swt lin]
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 19:58:06 +0100 |
parents | 7a2dd761a8b2 |
children | fb3aa8075988 |
comparison
equal
deleted
inserted
replaced
50:d5075f5226e5 | 51:c01d033c633a |
---|---|
84 | 84 |
85 version(Tango){ | 85 version(Tango){ |
86 static import tango.io.model.IFile; | 86 static import tango.io.model.IFile; |
87 import tango.util.Convert; | 87 import tango.util.Convert; |
88 } else { // Phobos | 88 } else { // Phobos |
89 import std.conv; | |
89 static import std.string; | 90 static import std.string; |
90 } | 91 } |
91 import java.lang.all; | 92 import java.lang.all; |
92 | 93 |
93 | 94 |
656 if (pageIndex !is -1 ) { | 657 if (pageIndex !is -1 ) { |
657 int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length; | 658 int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length; |
658 StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex)); | 659 StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex)); |
659 buffer.append (page); | 660 buffer.append (page); |
660 buffer.append (segment.substring(pageIndex + pageTagLength)); | 661 buffer.append (segment.substring(pageIndex + pageTagLength)); |
661 segment = buffer.toString().dup; | 662 segment = buffer.toString()._idup(); |
662 } | 663 } |
663 if (segment.length > 0) { | 664 if (segment.length > 0) { |
664 layout.setText(segment); | 665 layout.setText(segment); |
665 int segmentWidth = layout.getBounds().width; | 666 int segmentWidth = layout.getBounds().width; |
666 int segmentHeight = printerRenderer.getLineHeight(); | 667 int segmentHeight = printerRenderer.getLineHeight(); |
4001 caretAlignment = PREVIOUS_OFFSET_TRAILING; | 4002 caretAlignment = PREVIOUS_OFFSET_TRAILING; |
4002 } else { | 4003 } else { |
4003 String line = content.getLine(lineIndex); | 4004 String line = content.getLine(lineIndex); |
4004 int level; | 4005 int level; |
4005 int offset = offsetInLine; | 4006 int offset = offsetInLine; |
4006 while (offset > 0 && tango.text.Unicode.isDigit(line[offset])) offset--; | 4007 while (offset > 0 && Character.isDigit(line.dcharAt(offset))) offset--; |
4007 if (offset is 0 && tango.text.Unicode.isDigit(line[offset])) { | 4008 if (offset is 0 && Character.isDigit(line.dcharAt(offset))) { |
4008 level = isMirrored() ? 1 : 0; | 4009 level = isMirrored() ? 1 : 0; |
4009 } else { | 4010 } else { |
4010 level = layout.getLevel(offset) & 0x1; | 4011 level = layout.getLevel(offset) & 0x1; |
4011 } | 4012 } |
4012 offsetInLine += trailing[0]; | 4013 offsetInLine += trailing[0]; |
4807 int offset = caretOffset - lineOffset; | 4808 int offset = caretOffset - lineOffset; |
4808 int lineLength = line.length; | 4809 int lineLength = line.length; |
4809 if (lineLength is 0) return isMirrored() ? SWT.RIGHT : SWT.LEFT; | 4810 if (lineLength is 0) return isMirrored() ? SWT.RIGHT : SWT.LEFT; |
4810 if (caretAlignment is PREVIOUS_OFFSET_TRAILING && offset > 0) offset--; | 4811 if (caretAlignment is PREVIOUS_OFFSET_TRAILING && offset > 0) offset--; |
4811 if (offset is lineLength && offset > 0) offset--; | 4812 if (offset is lineLength && offset > 0) offset--; |
4812 while (offset > 0 && tango.text.Unicode.isDigit(line[offset])) offset--; | 4813 while (offset > 0 && Character.isDigit(line.dcharAt(offset))) offset--; |
4813 if (offset is 0 && tango.text.Unicode.isDigit(line[offset])) { | 4814 if (offset is 0 && Character.isDigit(line.dcharAt(offset))) { |
4814 return isMirrored() ? SWT.RIGHT : SWT.LEFT; | 4815 return isMirrored() ? SWT.RIGHT : SWT.LEFT; |
4815 } | 4816 } |
4816 TextLayout layout = renderer.getTextLayout(caretLine); | 4817 TextLayout layout = renderer.getTextLayout(caretLine); |
4817 int level = layout.getLevel(offset); | 4818 int level = layout.getLevel(offset); |
4818 renderer.disposeTextLayout(layout); | 4819 renderer.disposeTextLayout(layout); |
5326 //drag detect | 5327 //drag detect |
5327 if (dragDetect_ && checkDragDetect(event)) return; | 5328 if (dragDetect_ && checkDragDetect(event)) return; |
5328 | 5329 |
5329 //paste clipboard selection | 5330 //paste clipboard selection |
5330 if (event.button is 2) { | 5331 if (event.button is 2) { |
5331 auto o = cast(ArrayWrapperString)getClipboardContent(DND.SELECTION_CLIPBOARD); | 5332 String text = stringcast(getClipboardContent(DND.SELECTION_CLIPBOARD)); |
5332 String text = o.array; | |
5333 if (text !is null && text.length > 0) { | 5333 if (text !is null && text.length > 0) { |
5334 // position cursor | 5334 // position cursor |
5335 doMouseLocationChange(event.x, event.y, false); | 5335 doMouseLocationChange(event.x, event.y, false); |
5336 // insert text | 5336 // insert text |
5337 Event e = new Event(); | 5337 Event e = new Event(); |
5664 if (label !is null) { | 5664 if (label !is null) { |
5665 String text = label.getText (); | 5665 String text = label.getText (); |
5666 if (text !is null) { | 5666 if (text !is null) { |
5667 dchar mnemonic = _findMnemonic (text); | 5667 dchar mnemonic = _findMnemonic (text); |
5668 if (mnemonic !is '\0') { | 5668 if (mnemonic !is '\0') { |
5669 shortcut = "Alt+"~String_valueOf( [mnemonic] ); //$NON-NLS-1$ | 5669 shortcut = Format("Alt+{}", mnemonic ); //$NON-NLS-1$ |
5670 } | 5670 } |
5671 } | 5671 } |
5672 } | 5672 } |
5673 e.result = shortcut; | 5673 e.result = shortcut; |
5674 } | 5674 } |
6038 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 6038 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
6039 * </ul> | 6039 * </ul> |
6040 */ | 6040 */ |
6041 public void paste(){ | 6041 public void paste(){ |
6042 checkWidget(); | 6042 checkWidget(); |
6043 String text = null; | 6043 String text = stringcast( getClipboardContent(DND.CLIPBOARD)); |
6044 if( auto o = cast(ArrayWrapperString) getClipboardContent(DND.CLIPBOARD)){ | |
6045 text = o.array; | |
6046 } | |
6047 if (text !is null && text.length > 0) { | 6044 if (text !is null && text.length > 0) { |
6048 Event event = new Event(); | 6045 Event event = new Event(); |
6049 event.start = selection.x; | 6046 event.start = selection.x; |
6050 event.end = selection.y; | 6047 event.end = selection.y; |
6051 event.text = getModelDelimitedText(text); | 6048 event.text = getModelDelimitedText(text); |