comparison dwt/custom/StyledText.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 184ab53b7785
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
146 public class StyledText : Canvas { 146 public class StyledText : Canvas {
147 147
148 alias Canvas.computeSize computeSize; 148 alias Canvas.computeSize computeSize;
149 149
150 static const char TAB = '\t'; 150 static const char TAB = '\t';
151 static const char[] PlatformLineDelimiter = tango.io.FileConst.FileConst.NewlineString; 151 static const String PlatformLineDelimiter = tango.io.FileConst.FileConst.NewlineString;
152 static const int BIDI_CARET_WIDTH = 3; 152 static const int BIDI_CARET_WIDTH = 3;
153 static const int DEFAULT_WIDTH = 64; 153 static const int DEFAULT_WIDTH = 64;
154 static const int DEFAULT_HEIGHT = 64; 154 static const int DEFAULT_HEIGHT = 64;
155 static const int V_SCROLL_RATE = 50; 155 static const int V_SCROLL_RATE = 50;
156 static const int H_SCROLL_RATE = 10; 156 static const int H_SCROLL_RATE = 10;
227 int indent; 227 int indent;
228 int lineSpacing; 228 int lineSpacing;
229 229
230 const static bool IS_CARBON, IS_GTK, IS_MOTIF; 230 const static bool IS_CARBON, IS_GTK, IS_MOTIF;
231 static this(){ 231 static this(){
232 char[] platform = DWT.getPlatform(); 232 String platform = DWT.getPlatform();
233 IS_CARBON = ("carbon" == platform); 233 IS_CARBON = ("carbon" == platform);
234 IS_GTK = ("gtk" == platform); 234 IS_GTK = ("gtk" == platform);
235 IS_MOTIF = ("motif" == platform); 235 IS_MOTIF = ("motif" == platform);
236 } 236 }
237 237
311 tabLength = styledText.tabLength; 311 tabLength = styledText.tabLength;
312 int lineCount = printerRenderer.lineCount; 312 int lineCount = printerRenderer.lineCount;
313 if (styledText.isListening(LineGetBackground) || (styledText.isBidi() && styledText.isListening(LineGetSegments)) || styledText.isListening(LineGetStyle)) { 313 if (styledText.isListening(LineGetBackground) || (styledText.isBidi() && styledText.isListening(LineGetSegments)) || styledText.isListening(LineGetStyle)) {
314 StyledTextContent content = printerRenderer.content; 314 StyledTextContent content = printerRenderer.content;
315 for (int i = 0; i < lineCount; i++) { 315 for (int i = 0; i < lineCount; i++) {
316 char[] line = content.getLine(i); 316 String line = content.getLine(i);
317 int lineOffset = content.getOffsetAtLine(i); 317 int lineOffset = content.getOffsetAtLine(i);
318 StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line); 318 StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line);
319 if (event !is null && event.lineBackground !is null) { 319 if (event !is null && event.lineBackground !is null) {
320 printerRenderer.setLineBackground(i, 1, event.lineBackground); 320 printerRenderer.setLineBackground(i, 1, event.lineBackground);
321 } 321 }
599 * 599 *
600 * @param page page number to print, if specified in the StyledTextPrintOptions header or footer. 600 * @param page page number to print, if specified in the StyledTextPrintOptions header or footer.
601 * @param header true = print the header, false = print the footer 601 * @param header true = print the header, false = print the footer
602 */ 602 */
603 void printDecoration(int page, bool header, TextLayout layout) { 603 void printDecoration(int page, bool header, TextLayout layout) {
604 char[] text = header ? printOptions.header : printOptions.footer; 604 String text = header ? printOptions.header : printOptions.footer;
605 if (text is null) return; 605 if (text is null) return;
606 int lastSegmentIndex = 0; 606 int lastSegmentIndex = 0;
607 for (int i = 0; i < 3; i++) { 607 for (int i = 0; i < 3; i++) {
608 int segmentIndex = tango.text.Util.locatePattern( text, StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); 608 int segmentIndex = tango.text.Util.locatePattern( text, StyledTextPrintOptions.SEPARATOR, lastSegmentIndex);
609 char[] segment; 609 String segment;
610 if (segmentIndex is text.length ) { 610 if (segmentIndex is text.length ) {
611 segment = text[ lastSegmentIndex .. $ ].dup; 611 segment = text[ lastSegmentIndex .. $ ].dup;
612 printDecorationSegment(segment, i, page, header, layout); 612 printDecorationSegment(segment, i, page, header, layout);
613 break; 613 break;
614 } else { 614 } else {
626 * @param segment decoration segment to print 626 * @param segment decoration segment to print
627 * @param alignment alignment of the segment. 0=left, 1=center, 2=right 627 * @param alignment alignment of the segment. 0=left, 1=center, 2=right
628 * @param page page number to print, if specified in the decoration segment. 628 * @param page page number to print, if specified in the decoration segment.
629 * @param header true = print the header, false = print the footer 629 * @param header true = print the header, false = print the footer
630 */ 630 */
631 void printDecorationSegment(char[] segment, int alignment, int page, bool header, TextLayout layout) { 631 void printDecorationSegment(String segment, int alignment, int page, bool header, TextLayout layout) {
632 int pageIndex = tango.text.Util.locatePattern( segment, StyledTextPrintOptions.PAGE_TAG ); 632 int pageIndex = tango.text.Util.locatePattern( segment, StyledTextPrintOptions.PAGE_TAG );
633 if (pageIndex !is segment.length ) { 633 if (pageIndex !is segment.length ) {
634 int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length; 634 int pageTagLength = StyledTextPrintOptions.PAGE_TAG.length;
635 StringBuffer buffer = new StringBuffer(segment[ 0 .. pageIndex ]); 635 StringBuffer buffer = new StringBuffer(segment[ 0 .. pageIndex ]);
636 buffer.append (page); 636 buffer.append (page);
674 } 674 }
675 if (printOptions.printLineNumbers) { 675 if (printOptions.printLineNumbers) {
676 FontMetrics metrics = layout.getLineMetrics(0); 676 FontMetrics metrics = layout.getLineMetrics(0);
677 printLayout.setAscent(metrics.getAscent() + metrics.getDescent()); 677 printLayout.setAscent(metrics.getAscent() + metrics.getDescent());
678 printLayout.setDescent(metrics.getDescent()); 678 printLayout.setDescent(metrics.getDescent());
679 printLayout.setText( to!(char[])(index) ); 679 printLayout.setText( to!(String)(index) );
680 int paintX = x - printMargin - printLayout.getBounds().width; 680 int paintX = x - printMargin - printLayout.getBounds().width;
681 printLayout.draw(gc, paintX, y); 681 printLayout.draw(gc, paintX, y);
682 printLayout.setAscent(-1); 682 printLayout.setAscent(-1);
683 printLayout.setDescent(-1); 683 printLayout.setDescent(-1);
684 } 684 }
687 } 687 }
688 /** 688 /**
689 * Starts a print job and prints the pages specified in the constructor. 689 * Starts a print job and prints the pages specified in the constructor.
690 */ 690 */
691 public void run() { 691 public void run() {
692 char[] jobName = printOptions.jobName; 692 String jobName = printOptions.jobName;
693 if (jobName is null) { 693 if (jobName is null) {
694 jobName = "Printing"; 694 jobName = "Printing";
695 } 695 }
696 if (printer.startJob(jobName)) { 696 if (printer.startJob(jobName)) {
697 init_(); 697 init_();
802 /** 802 /**
803 * Determines if Unicode RTF should be written. 803 * Determines if Unicode RTF should be written.
804 * Don't write Unicode RTF on Windows 95/98/ME or NT. 804 * Don't write Unicode RTF on Windows 95/98/ME or NT.
805 */ 805 */
806 void setUnicode() { 806 void setUnicode() {
807 // const char[] Win95 = "windows 95"; 807 // const String Win95 = "windows 95";
808 // const char[] Win98 = "windows 98"; 808 // const String Win98 = "windows 98";
809 // const char[] WinME = "windows me"; 809 // const String WinME = "windows me";
810 // const char[] WinNT = "windows nt"; 810 // const String WinNT = "windows nt";
811 // char[] osName = System.getProperty("os.name").toLowerCase(); 811 // String osName = System.getProperty("os.name").toLowerCase();
812 // char[] osVersion = System.getProperty("os.version"); 812 // String osVersion = System.getProperty("os.version");
813 // int majorVersion = 0; 813 // int majorVersion = 0;
814 // 814 //
815 // if (osName.startsWith(WinNT) && osVersion !is null) { 815 // if (osName.startsWith(WinNT) && osVersion !is null) {
816 // int majorIndex = osVersion.indexOf('.'); 816 // int majorIndex = osVersion.indexOf('.');
817 // if (majorIndex !is -1) { 817 // if (majorIndex !is -1) {
837 * @param string string to copy a segment from. Must not contain 837 * @param string string to copy a segment from. Must not contain
838 * line breaks. Line breaks should be written using writeLineDelimiter() 838 * line breaks. Line breaks should be written using writeLineDelimiter()
839 * @param start start offset of segment. 0 based. 839 * @param start start offset of segment. 0 based.
840 * @param end end offset of segment 840 * @param end end offset of segment
841 */ 841 */
842 void write(char[] string, int start, int end) { 842 void write(String string, int start, int end) {
843 wchar[] wstring = tango.text.convert.Utf.toString16( string[ start .. end ] ); 843 wchar[] wstring = tango.text.convert.Utf.toString16( string[ start .. end ] );
844 start = 0; 844 start = 0;
845 end = wstring.length; 845 end = wstring.length;
846 for (int index = start; index < end; index++) { 846 for (int index = start; index < end; index++) {
847 wchar ch = wstring[index]; 847 wchar ch = wstring[index];
850 // to the current one. Fixes bug 21698. 850 // to the current one. Fixes bug 21698.
851 if (index > start) { 851 if (index > start) {
852 write(tango.text.convert.Utf.toString(wstring[start .. index ])); 852 write(tango.text.convert.Utf.toString(wstring[start .. index ]));
853 } 853 }
854 write("\\u"); 854 write("\\u");
855 write( to!(char[])( cast(short)ch )); 855 write( to!(String)( cast(short)ch ));
856 write(' '); // control word delimiter 856 write(' '); // control word delimiter
857 start = index + 1; 857 start = index + 1;
858 } else if (ch is '}' || ch is '{' || ch is '\\') { 858 } else if (ch is '}' || ch is '{' || ch is '\\') {
859 // write the sub string from the last escaped character 859 // write the sub string from the last escaped character
860 // to the current one. Fixes bug 21698. 860 // to the current one. Fixes bug 21698.
879 StringBuffer header = new StringBuffer(); 879 StringBuffer header = new StringBuffer();
880 FontData fontData = getFont().getFontData()[0]; 880 FontData fontData = getFont().getFontData()[0];
881 header.append("{\\rtf1\\ansi"); 881 header.append("{\\rtf1\\ansi");
882 // specify code page, necessary for copy to work in bidi 882 // specify code page, necessary for copy to work in bidi
883 // systems that don't support Unicode RTF. 883 // systems that don't support Unicode RTF.
884 // PORTING_TODO: char[] cpg = System.getProperty("file.encoding").toLowerCase(); 884 // PORTING_TODO: String cpg = System.getProperty("file.encoding").toLowerCase();
885 char[] cpg = "UTF16"; 885 String cpg = "UTF16";
886 /+ 886 /+
887 if (cpg.startsWith("cp") || cpg.startsWith("ms")) { 887 if (cpg.startsWith("cp") || cpg.startsWith("ms")) {
888 cpg = cpg.substring(2, cpg.length()); 888 cpg = cpg.substring(2, cpg.length());
889 header.append("\\ansicpg"); 889 header.append("\\ansicpg");
890 header.append(cpg); 890 header.append(cpg);
932 * end offset specified during object creation is ignored. 932 * end offset specified during object creation is ignored.
933 * @exception DWTException <ul> 933 * @exception DWTException <ul>
934 * <li>ERROR_IO when the writer is closed.</li> 934 * <li>ERROR_IO when the writer is closed.</li>
935 * </ul> 935 * </ul>
936 */ 936 */
937 public override void writeLine(char[] line, int lineOffset) { 937 public override void writeLine(String line, int lineOffset) {
938 if (isClosed()) { 938 if (isClosed()) {
939 DWT.error(DWT.ERROR_IO); 939 DWT.error(DWT.ERROR_IO);
940 } 940 }
941 int lineIndex = content.getLineAtOffset(lineOffset); 941 int lineIndex = content.getLineAtOffset(lineOffset);
942 int lineAlignment, lineIndent; 942 int lineAlignment, lineIndent;
969 * @param lineDelimiter line delimiter to write as RTF. 969 * @param lineDelimiter line delimiter to write as RTF.
970 * @exception DWTException <ul> 970 * @exception DWTException <ul>
971 * <li>ERROR_IO when the writer is closed.</li> 971 * <li>ERROR_IO when the writer is closed.</li>
972 * </ul> 972 * </ul>
973 */ 973 */
974 public override void writeLineDelimiter(char[] lineDelimiter) { 974 public override void writeLineDelimiter(String lineDelimiter) {
975 if (isClosed()) { 975 if (isClosed()) {
976 DWT.error(DWT.ERROR_IO); 976 DWT.error(DWT.ERROR_IO);
977 } 977 }
978 write(lineDelimiter, 0, lineDelimiter.length); 978 write(lineDelimiter, 0, lineDelimiter.length);
979 write("\\par "); 979 write("\\par ");
994 * end offset specified during object creation is ignored. 994 * end offset specified during object creation is ignored.
995 * @param styles styles to use for formatting. Must not be null. 995 * @param styles styles to use for formatting. Must not be null.
996 * @param lineBackground line background color to use for formatting. 996 * @param lineBackground line background color to use for formatting.
997 * May be null. 997 * May be null.
998 */ 998 */
999 void writeStyledLine(char[] line, int lineOffset, int ranges[], StyleRange[] styles, Color lineBackground, int indent, int alignment, bool justify) { 999 void writeStyledLine(String line, int lineOffset, int ranges[], StyleRange[] styles, Color lineBackground, int indent, int alignment, bool justify) {
1000 int lineLength = line.length; 1000 int lineLength = line.length;
1001 int startOffset = getStart(); 1001 int startOffset = getStart();
1002 int writeOffset = startOffset - lineOffset; 1002 int writeOffset = startOffset - lineOffset;
1003 if (writeOffset >= lineLength) return; 1003 if (writeOffset >= lineLength) return;
1004 int lineIndex = Math.max(0, writeOffset); 1004 int lineIndex = Math.max(0, writeOffset);
1172 * Returns the string. <code>close()</code> must be called before <code>toString()</code> 1172 * Returns the string. <code>close()</code> must be called before <code>toString()</code>
1173 * is guaranteed to return a valid string. 1173 * is guaranteed to return a valid string.
1174 * 1174 *
1175 * @return the string 1175 * @return the string
1176 */ 1176 */
1177 public override char[] toString() { 1177 public override String toString() {
1178 return buffer.toString(); 1178 return buffer.toString();
1179 } 1179 }
1180 /** 1180 /**
1181 * Appends the given string to the data. 1181 * Appends the given string to the data.
1182 */ 1182 */
1183 void write(char[] string) { 1183 void write(String string) {
1184 buffer.append(string); 1184 buffer.append(string);
1185 } 1185 }
1186 /** 1186 /**
1187 * Inserts the given string to the data at the specified offset. 1187 * Inserts the given string to the data at the specified offset.
1188 * <p> 1188 * <p>
1190 * </p> 1190 * </p>
1191 * 1191 *
1192 * @param string text to insert 1192 * @param string text to insert
1193 * @param offset offset in the existing data to insert "string" at. 1193 * @param offset offset in the existing data to insert "string" at.
1194 */ 1194 */
1195 void write(char[] string, int offset) { 1195 void write(String string, int offset) {
1196 if (offset < 0 || offset > buffer.length()) { 1196 if (offset < 0 || offset > buffer.length()) {
1197 return; 1197 return;
1198 } 1198 }
1199 buffer.select( offset ); 1199 buffer.select( offset );
1200 buffer.prepend( string ); 1200 buffer.prepend( string );
1221 * end offset specified during object creation is ignored. 1221 * end offset specified during object creation is ignored.
1222 * @exception DWTException <ul> 1222 * @exception DWTException <ul>
1223 * <li>ERROR_IO when the writer is closed.</li> 1223 * <li>ERROR_IO when the writer is closed.</li>
1224 * </ul> 1224 * </ul>
1225 */ 1225 */
1226 public void writeLine(char[] line, int lineOffset) { 1226 public void writeLine(String line, int lineOffset) {
1227 if (isClosed_) { 1227 if (isClosed_) {
1228 DWT.error(DWT.ERROR_IO); 1228 DWT.error(DWT.ERROR_IO);
1229 } 1229 }
1230 int writeOffset = startOffset - lineOffset; 1230 int writeOffset = startOffset - lineOffset;
1231 int lineLength = line.length; 1231 int lineLength = line.length;
1248 * @param lineDelimiter line delimiter to write 1248 * @param lineDelimiter line delimiter to write
1249 * @exception DWTException <ul> 1249 * @exception DWTException <ul>
1250 * <li>ERROR_IO when the writer is closed.</li> 1250 * <li>ERROR_IO when the writer is closed.</li>
1251 * </ul> 1251 * </ul>
1252 */ 1252 */
1253 public void writeLineDelimiter(char[] lineDelimiter) { 1253 public void writeLineDelimiter(String lineDelimiter) {
1254 if (isClosed_) { 1254 if (isClosed_) {
1255 DWT.error(DWT.ERROR_IO); 1255 DWT.error(DWT.ERROR_IO);
1256 } 1256 }
1257 write(lineDelimiter); 1257 write(lineDelimiter);
1258 } 1258 }
1565 } 1565 }
1566 /** 1566 /**
1567 * Appends a string to the text at the end of the widget. 1567 * Appends a string to the text at the end of the widget.
1568 * 1568 *
1569 * @param string the string to be appended 1569 * @param string the string to be appended
1570 * @see #replaceTextRange(int,int,char[]) 1570 * @see #replaceTextRange(int,int,String)
1571 * @exception DWTException <ul> 1571 * @exception DWTException <ul>
1572 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 1572 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1573 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1573 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1574 * </ul> 1574 * </ul>
1575 * @exception IllegalArgumentException <ul> 1575 * @exception IllegalArgumentException <ul>
1576 * <li>ERROR_NULL_ARGUMENT when listener is null</li> 1576 * <li>ERROR_NULL_ARGUMENT when listener is null</li>
1577 * </ul> 1577 * </ul>
1578 */ 1578 */
1579 public void append(char[] string) { 1579 public void append(String string) {
1580 checkWidget(); 1580 checkWidget();
1581 if (string is null) { 1581 if (string is null) {
1582 DWT.error(DWT.ERROR_NULL_ARGUMENT); 1582 DWT.error(DWT.ERROR_NULL_ARGUMENT);
1583 } 1583 }
1584 int lastChar = Math.max(getCharCount(), 0); 1584 int lastChar = Math.max(getCharCount(), 0);
1889 * are CR ('\r'), LF ('\n'), CR/LF ("\r\n") 1889 * are CR ('\r'), LF ('\n'), CR/LF ("\r\n")
1890 * @return the converted text that only uses the line delimiter 1890 * @return the converted text that only uses the line delimiter
1891 * specified by the model. Returns only the first line if the widget 1891 * specified by the model. Returns only the first line if the widget
1892 * has the DWT.SINGLE style. 1892 * has the DWT.SINGLE style.
1893 */ 1893 */
1894 char[] getModelDelimitedText(char[] text) { 1894 String getModelDelimitedText(String text) {
1895 int length = text.length; 1895 int length = text.length;
1896 if (length is 0) { 1896 if (length is 0) {
1897 return text; 1897 return text;
1898 } 1898 }
1899 int crIndex = 0; 1899 int crIndex = 0;
1900 int lfIndex = 0; 1900 int lfIndex = 0;
1901 int i = 0; 1901 int i = 0;
1902 StringBuffer convertedText = new StringBuffer(length); 1902 StringBuffer convertedText = new StringBuffer(length);
1903 char[] delimiter = getLineDelimiter(); 1903 String delimiter = getLineDelimiter();
1904 while (i < length) { 1904 while (i < length) {
1905 if (crIndex !is -1) { 1905 if (crIndex !is -1) {
1906 crIndex = tango.text.Util.locate( text, DWT.CR, i); 1906 crIndex = tango.text.Util.locate( text, DWT.CR, i);
1907 if( crIndex is text.length ) crIndex = -1; 1907 if( crIndex is text.length ) crIndex = -1;
1908 } 1908 }
2253 } else if (selection.x is selection.y && overwrite && key !is TAB) { 2253 } else if (selection.x is selection.y && overwrite && key !is TAB) {
2254 // no selection and overwrite mode is on and the typed key is not a 2254 // no selection and overwrite mode is on and the typed key is not a
2255 // tab character (tabs are always inserted without overwriting)? 2255 // tab character (tabs are always inserted without overwriting)?
2256 int lineIndex = content.getLineAtOffset(event.end); 2256 int lineIndex = content.getLineAtOffset(event.end);
2257 int lineOffset = content.getOffsetAtLine(lineIndex); 2257 int lineOffset = content.getOffsetAtLine(lineIndex);
2258 char[] line = content.getLine(lineIndex); 2258 String line = content.getLine(lineIndex);
2259 // replace character at caret offset if the caret is not at the 2259 // replace character at caret offset if the caret is not at the
2260 // end of the line 2260 // end of the line
2261 if (event.end < lineOffset + line.length) { 2261 if (event.end < lineOffset + line.length) {
2262 event.end++; 2262 event.end++;
2263 } 2263 }
3244 } 3244 }
3245 return bottomIndex; 3245 return bottomIndex;
3246 } 3246 }
3247 Rectangle getBoundsAtOffset(int offset) { 3247 Rectangle getBoundsAtOffset(int offset) {
3248 int lineIndex = content.getLineAtOffset(offset); 3248 int lineIndex = content.getLineAtOffset(offset);
3249 char[] line = content.getLine(lineIndex); 3249 String line = content.getLine(lineIndex);
3250 Rectangle bounds; 3250 Rectangle bounds;
3251 if (line.length !is 0) { 3251 if (line.length !is 0) {
3252 int offsetInLine = offset - content.getOffsetAtLine(lineIndex); 3252 int offsetInLine = offset - content.getOffsetAtLine(lineIndex);
3253 TextLayout layout = renderer.getTextLayout(lineIndex); 3253 TextLayout layout = renderer.getTextLayout(lineIndex);
3254 bounds = layout.getBounds(offsetInLine, offsetInLine); 3254 bounds = layout.getBounds(offsetInLine, offsetInLine);
3572 * @param lineOffset offset of the line start relative to the start 3572 * @param lineOffset offset of the line start relative to the start
3573 * of the content. 3573 * of the content.
3574 * @param line line to get line background data for 3574 * @param line line to get line background data for
3575 * @return line background data for the given line. 3575 * @return line background data for the given line.
3576 */ 3576 */
3577 StyledTextEvent getLineBackgroundData(int lineOffset, char[] line) { 3577 StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
3578 return sendLineEvent(LineGetBackground, lineOffset, line); 3578 return sendLineEvent(LineGetBackground, lineOffset, line);
3579 } 3579 }
3580 /** 3580 /**
3581 * Gets the number of text lines. 3581 * Gets the number of text lines.
3582 * 3582 *
3613 * @exception DWTException <ul> 3613 * @exception DWTException <ul>
3614 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 3614 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3615 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 3615 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
3616 * </ul> 3616 * </ul>
3617 */ 3617 */
3618 public char[] getLineDelimiter() { 3618 public String getLineDelimiter() {
3619 checkWidget(); 3619 checkWidget();
3620 return content.getLineDelimiter(); 3620 return content.getLineDelimiter();
3621 } 3621 }
3622 /** 3622 /**
3623 * Returns the line height. 3623 * Returns the line height.
3751 * the content. 3751 * the content.
3752 * @param line line to get line styles for 3752 * @param line line to get line styles for
3753 * @return line style data for the given line. Styles may start before 3753 * @return line style data for the given line. Styles may start before
3754 * line start and end after line end 3754 * line start and end after line end
3755 */ 3755 */
3756 StyledTextEvent getLineStyleData(int lineOffset, char[] line) { 3756 StyledTextEvent getLineStyleData(int lineOffset, String line) {
3757 return sendLineEvent(LineGetStyle, lineOffset, line); 3757 return sendLineEvent(LineGetStyle, lineOffset, line);
3758 } 3758 }
3759 /** 3759 /**
3760 * Returns the top pixel, relative to the client area, of a given line. 3760 * Returns the top pixel, relative to the client area, of a given line.
3761 * Clamps out of ranges index. 3761 * Clamps out of ranges index.
3913 TextLayout layout = renderer.getTextLayout(lineIndex); 3913 TextLayout layout = renderer.getTextLayout(lineIndex);
3914 int[] trailing = new int[1]; 3914 int[] trailing = new int[1];
3915 int x = point.x + horizontalScrollOffset - leftMargin ; 3915 int x = point.x + horizontalScrollOffset - leftMargin ;
3916 int y = point.y - getLinePixel(lineIndex); 3916 int y = point.y - getLinePixel(lineIndex);
3917 int offsetInLine = layout.getOffset(x, y, trailing); 3917 int offsetInLine = layout.getOffset(x, y, trailing);
3918 char[] line = content.getLine(lineIndex); 3918 String line = content.getLine(lineIndex);
3919 if (offsetInLine !is line.length - 1) { 3919 if (offsetInLine !is line.length - 1) {
3920 offsetInLine = Math.min(line.length, offsetInLine + trailing[0]); 3920 offsetInLine = Math.min(line.length, offsetInLine + trailing[0]);
3921 } 3921 }
3922 Rectangle rect = layout.getLineBounds(layout.getLineIndex(offsetInLine)); 3922 Rectangle rect = layout.getLineBounds(layout.getLineIndex(offsetInLine));
3923 renderer.disposeTextLayout(layout); 3923 renderer.disposeTextLayout(layout);
3951 int lineStart = layout.getLineOffsets()[lineInParagraph]; 3951 int lineStart = layout.getLineOffsets()[lineInParagraph];
3952 if (offsetInLine + trailing[0] is lineStart) { 3952 if (offsetInLine + trailing[0] is lineStart) {
3953 offsetInLine += trailing[0]; 3953 offsetInLine += trailing[0];
3954 caretAlignment = PREVIOUS_OFFSET_TRAILING; 3954 caretAlignment = PREVIOUS_OFFSET_TRAILING;
3955 } else { 3955 } else {
3956 char[] line = content.getLine(lineIndex); 3956 String line = content.getLine(lineIndex);
3957 int level; 3957 int level;
3958 int offset = offsetInLine; 3958 int offset = offsetInLine;
3959 while (offset > 0 && tango.text.Unicode.isDigit(line[offset])) offset--; 3959 while (offset > 0 && tango.text.Unicode.isDigit(line[offset])) offset--;
3960 if (offset is 0 && tango.text.Unicode.isDigit(line[offset])) { 3960 if (offset is 0 && tango.text.Unicode.isDigit(line[offset])) {
3961 level = isMirrored() ? 1 : 0; 3961 level = isMirrored() ? 1 : 0;
4021 * 4021 *
4022 * @param writer the TextWriter to write line text into 4022 * @param writer the TextWriter to write line text into
4023 * @return the content in the specified range using the platform line 4023 * @return the content in the specified range using the platform line
4024 * delimiter to separate lines as written by the specified TextWriter. 4024 * delimiter to separate lines as written by the specified TextWriter.
4025 */ 4025 */
4026 char[] getPlatformDelimitedText(TextWriter writer) { 4026 String getPlatformDelimitedText(TextWriter writer) {
4027 int end = writer.getStart() + writer.getCharCount(); 4027 int end = writer.getStart() + writer.getCharCount();
4028 int startLine = content.getLineAtOffset(writer.getStart()); 4028 int startLine = content.getLineAtOffset(writer.getStart());
4029 int endLine = content.getLineAtOffset(end); 4029 int endLine = content.getLineAtOffset(end);
4030 char[] endLineText = content.getLine(endLine); 4030 String endLineText = content.getLine(endLine);
4031 int endLineOffset = content.getOffsetAtLine(endLine); 4031 int endLineOffset = content.getOffsetAtLine(endLine);
4032 4032
4033 for (int i = startLine; i <= endLine; i++) { 4033 for (int i = startLine; i <= endLine; i++) {
4034 writer.writeLine(content.getLine(i), content.getOffsetAtLine(i)); 4034 writer.writeLine(content.getLine(i), content.getOffsetAtLine(i));
4035 if (i < endLine) { 4035 if (i < endLine) {
4214 * @exception DWTException <ul> 4214 * @exception DWTException <ul>
4215 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 4215 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
4216 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 4216 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
4217 * </ul> 4217 * </ul>
4218 */ 4218 */
4219 public char[] getSelectionText() { 4219 public String getSelectionText() {
4220 checkWidget(); 4220 checkWidget();
4221 return content.getTextRange(selection.x, selection.y - selection.x); 4221 return content.getTextRange(selection.x, selection.y - selection.x);
4222 } 4222 }
4223 public override int getStyle() { 4223 public override int getStyle() {
4224 int style = super.getStyle(); 4224 int style = super.getStyle();
4246 * <li>ERROR_INVALID_ARGUMENT - if the segment indices returned 4246 * <li>ERROR_INVALID_ARGUMENT - if the segment indices returned
4247 * by the listener do not start with 0, are not in ascending order, 4247 * by the listener do not start with 0, are not in ascending order,
4248 * exceed the line length or have duplicates</li> 4248 * exceed the line length or have duplicates</li>
4249 * </ul> 4249 * </ul>
4250 */ 4250 */
4251 int [] getBidiSegments(int lineOffset, char[] line) { 4251 int [] getBidiSegments(int lineOffset, String line) {
4252 if (!isBidi()) return null; 4252 if (!isBidi()) return null;
4253 if (!isListening(LineGetSegments)) { 4253 if (!isListening(LineGetSegments)) {
4254 return getBidiSegmentsCompatibility(line, lineOffset); 4254 return getBidiSegmentsCompatibility(line, lineOffset);
4255 } 4255 }
4256 StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line); 4256 StyledTextEvent event = sendLineEvent(LineGetSegments, lineOffset, line);
4283 } 4283 }
4284 /** 4284 /**
4285 * @see #getBidiSegments 4285 * @see #getBidiSegments
4286 * Supports deprecated setBidiColoring API. Remove when API is removed. 4286 * Supports deprecated setBidiColoring API. Remove when API is removed.
4287 */ 4287 */
4288 int [] getBidiSegmentsCompatibility(char[] line, int lineOffset) { 4288 int [] getBidiSegmentsCompatibility(String line, int lineOffset) {
4289 int lineLength = line.length; 4289 int lineLength = line.length;
4290 if (!bidiColoring) { 4290 if (!bidiColoring) {
4291 return [0, lineLength]; 4291 return [0, lineLength];
4292 } 4292 }
4293 StyleRange [] styles = null; 4293 StyleRange [] styles = null;
4537 * @exception DWTException <ul> 4537 * @exception DWTException <ul>
4538 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 4538 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
4539 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 4539 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
4540 * </ul> 4540 * </ul>
4541 */ 4541 */
4542 public char[] getText() { 4542 public String getText() {
4543 checkWidget(); 4543 checkWidget();
4544 return content.getTextRange(0, getCharCount()); 4544 return content.getTextRange(0, getCharCount());
4545 } 4545 }
4546 /** 4546 /**
4547 * Returns the widget content between the two offsets. 4547 * Returns the widget content between the two offsets.
4548 * 4548 *
4549 * @param start offset of the first character in the returned char[] 4549 * @param start offset of the first character in the returned String
4550 * @param end offset of the last character in the returned String 4550 * @param end offset of the last character in the returned String
4551 * @return widget content starting at start and ending at end 4551 * @return widget content starting at start and ending at end
4552 * @see #getTextRange(int,int) 4552 * @see #getTextRange(int,int)
4553 * @exception DWTException <ul> 4553 * @exception DWTException <ul>
4554 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 4554 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
4556 * </ul> 4556 * </ul>
4557 * @exception IllegalArgumentException <ul> 4557 * @exception IllegalArgumentException <ul>
4558 * <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li> 4558 * <li>ERROR_INVALID_RANGE when start and/or end are outside the widget content</li>
4559 * </ul> 4559 * </ul>
4560 */ 4560 */
4561 public char[] getText(int start, int end) { 4561 public String getText(int start, int end) {
4562 checkWidget(); 4562 checkWidget();
4563 int contentLength = getCharCount(); 4563 int contentLength = getCharCount();
4564 if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) { 4564 if (start < 0 || start >= contentLength || end < 0 || end >= contentLength || start > end) {
4565 DWT.error(DWT.ERROR_INVALID_RANGE); 4565 DWT.error(DWT.ERROR_INVALID_RANGE);
4566 } 4566 }
4598 TextLayout layout = renderer.getTextLayout(i); 4598 TextLayout layout = renderer.getTextLayout(i);
4599 if (layout.getText().length > 0) { 4599 if (layout.getText().length > 0) {
4600 if (i is lineStart && i is lineEnd) { 4600 if (i is lineStart && i is lineEnd) {
4601 rect = layout.getBounds(start - lineOffset, end - lineOffset); 4601 rect = layout.getBounds(start - lineOffset, end - lineOffset);
4602 } else if (i is lineStart) { 4602 } else if (i is lineStart) {
4603 char[] line = content.getLine(i); 4603 String line = content.getLine(i);
4604 rect = layout.getBounds(start - lineOffset, line.length); 4604 rect = layout.getBounds(start - lineOffset, line.length);
4605 } else if (i is lineEnd) { 4605 } else if (i is lineEnd) {
4606 rect = layout.getBounds(0, end - lineOffset); 4606 rect = layout.getBounds(0, end - lineOffset);
4607 } else { 4607 } else {
4608 rect = layout.getBounds(); 4608 rect = layout.getBounds();
4631 * </ul> 4631 * </ul>
4632 * @exception IllegalArgumentException <ul> 4632 * @exception IllegalArgumentException <ul>
4633 * <li>ERROR_INVALID_RANGE when start and/or length are outside the widget content</li> 4633 * <li>ERROR_INVALID_RANGE when start and/or length are outside the widget content</li>
4634 * </ul> 4634 * </ul>
4635 */ 4635 */
4636 public char[] getTextRange(int start, int length) { 4636 public String getTextRange(int start, int length) {
4637 checkWidget(); 4637 checkWidget();
4638 int contentLength = getCharCount(); 4638 int contentLength = getCharCount();
4639 int end = start + length; 4639 int end = start + length;
4640 if (start > end || start < 0 || end > contentLength) { 4640 if (start > end || start < 0 || end > contentLength) {
4641 DWT.error(DWT.ERROR_INVALID_RANGE); 4641 DWT.error(DWT.ERROR_INVALID_RANGE);
4728 if (!isBidiCaret()) return DWT.DEFAULT; 4728 if (!isBidiCaret()) return DWT.DEFAULT;
4729 if (!updateCaretDirection && caretDirection !is DWT.NULL) return caretDirection; 4729 if (!updateCaretDirection && caretDirection !is DWT.NULL) return caretDirection;
4730 updateCaretDirection = false; 4730 updateCaretDirection = false;
4731 int caretLine = getCaretLine(); 4731 int caretLine = getCaretLine();
4732 int lineOffset = content.getOffsetAtLine(caretLine); 4732 int lineOffset = content.getOffsetAtLine(caretLine);
4733 char[] line = content.getLine(caretLine); 4733 String line = content.getLine(caretLine);
4734 int offset = caretOffset - lineOffset; 4734 int offset = caretOffset - lineOffset;
4735 int lineLength = line.length; 4735 int lineLength = line.length;
4736 if (lineLength is 0) return isMirrored() ? DWT.RIGHT : DWT.LEFT; 4736 if (lineLength is 0) return isMirrored() ? DWT.RIGHT : DWT.LEFT;
4737 if (caretAlignment is PREVIOUS_OFFSET_TRAILING && offset > 0) offset--; 4737 if (caretAlignment is PREVIOUS_OFFSET_TRAILING && offset > 0) offset--;
4738 if (offset is lineLength && offset > 0) offset--; 4738 if (offset is lineLength && offset > 0) offset--;
4758 } 4758 }
4759 return -1; 4759 return -1;
4760 } 4760 }
4761 int getWordNext (int offset, int movement) { 4761 int getWordNext (int offset, int movement) {
4762 int newOffset, lineOffset; 4762 int newOffset, lineOffset;
4763 char[] lineText; 4763 String lineText;
4764 if (offset >= getCharCount()) { 4764 if (offset >= getCharCount()) {
4765 newOffset = offset; 4765 newOffset = offset;
4766 int lineIndex = content.getLineCount() - 1; 4766 int lineIndex = content.getLineCount() - 1;
4767 lineOffset = content.getOffsetAtLine(lineIndex); 4767 lineOffset = content.getOffsetAtLine(lineIndex);
4768 lineText = content.getLine(lineIndex); 4768 lineText = content.getLine(lineIndex);
4781 } 4781 }
4782 return sendWordBoundaryEvent(WordNext, movement, offset, newOffset, lineText, lineOffset); 4782 return sendWordBoundaryEvent(WordNext, movement, offset, newOffset, lineText, lineOffset);
4783 } 4783 }
4784 int getWordPrevious(int offset, int movement) { 4784 int getWordPrevious(int offset, int movement) {
4785 int newOffset, lineOffset; 4785 int newOffset, lineOffset;
4786 char[] lineText; 4786 String lineText;
4787 if (offset <= 0) { 4787 if (offset <= 0) {
4788 newOffset = 0; 4788 newOffset = 0;
4789 int lineIndex = content.getLineAtOffset(newOffset); 4789 int lineIndex = content.getLineAtOffset(newOffset);
4790 lineOffset = content.getOffsetAtLine(lineIndex); 4790 lineOffset = content.getOffsetAtLine(lineIndex);
4791 lineText = content.getLine(lineIndex); 4791 lineText = content.getLine(lineIndex);
4792 } else { 4792 } else {
4793 int lineIndex = content.getLineAtOffset(offset); 4793 int lineIndex = content.getLineAtOffset(offset);
4794 lineOffset = content.getOffsetAtLine(lineIndex); 4794 lineOffset = content.getOffsetAtLine(lineIndex);
4795 lineText = content.getLine(lineIndex); 4795 lineText = content.getLine(lineIndex);
4796 if (offset is lineOffset) { 4796 if (offset is lineOffset) {
4797 char[] nextLineText = content.getLine(lineIndex - 1); 4797 String nextLineText = content.getLine(lineIndex - 1);
4798 int nextLineOffset = content.getOffsetAtLine(lineIndex - 1); 4798 int nextLineOffset = content.getOffsetAtLine(lineIndex - 1);
4799 newOffset = nextLineOffset + nextLineText.length; 4799 newOffset = nextLineOffset + nextLineText.length;
4800 } else { 4800 } else {
4801 TextLayout layout = renderer.getTextLayout(lineIndex); 4801 TextLayout layout = renderer.getTextLayout(lineIndex);
4802 newOffset = lineOffset + layout.getPreviousOffset(offset - lineOffset, movement); 4802 newOffset = lineOffset + layout.getPreviousOffset(offset - lineOffset, movement);
4823 * 4823 *
4824 * @return location of the character at the given offset in the line. 4824 * @return location of the character at the given offset in the line.
4825 */ 4825 */
4826 Point getPointAtOffset(int offset) { 4826 Point getPointAtOffset(int offset) {
4827 int lineIndex = content.getLineAtOffset(offset); 4827 int lineIndex = content.getLineAtOffset(offset);
4828 char[] line = content.getLine(lineIndex); 4828 String line = content.getLine(lineIndex);
4829 int lineOffset = content.getOffsetAtLine(lineIndex); 4829 int lineOffset = content.getOffsetAtLine(lineIndex);
4830 int offsetInLine = offset - lineOffset; 4830 int offsetInLine = offset - lineOffset;
4831 int lineLength = line.length; 4831 int lineLength = line.length;
4832 if (lineIndex < content.getLineCount() - 1) { 4832 if (lineIndex < content.getLineCount() - 1) {
4833 int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1; 4833 int endLineOffset = content.getOffsetAtLine(lineIndex + 1) - 1;
4865 } 4865 }
4866 /** 4866 /**
4867 * Inserts a string. The old selection is replaced with the new text. 4867 * Inserts a string. The old selection is replaced with the new text.
4868 * 4868 *
4869 * @param string the string 4869 * @param string the string
4870 * @see #replaceTextRange(int,int,char[]) 4870 * @see #replaceTextRange(int,int,String)
4871 * @exception DWTException <ul> 4871 * @exception DWTException <ul>
4872 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 4872 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
4873 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 4873 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
4874 * </ul> 4874 * </ul>
4875 * @exception IllegalArgumentException <ul> 4875 * @exception IllegalArgumentException <ul>
4876 * <li>ERROR_NULL_ARGUMENT when string is null</li> 4876 * <li>ERROR_NULL_ARGUMENT when string is null</li>
4877 * </ul> 4877 * </ul>
4878 */ 4878 */
4879 public void insert(char[] string) { 4879 public void insert(String string) {
4880 checkWidget(); 4880 checkWidget();
4881 if (string is null) { 4881 if (string is null) {
4882 DWT.error(DWT.ERROR_NULL_ARGUMENT); 4882 DWT.error(DWT.ERROR_NULL_ARGUMENT);
4883 } 4883 }
4884 Point sel = getSelectionRange(); 4884 Point sel = getSelectionRange();
5208 if (dragDetect_ && checkDragDetect(event)) return; 5208 if (dragDetect_ && checkDragDetect(event)) return;
5209 5209
5210 //paste clipboard selection 5210 //paste clipboard selection
5211 if (event.button is 2) { 5211 if (event.button is 2) {
5212 auto o = cast(ArrayWrapperString)getClipboardContent(DND.SELECTION_CLIPBOARD); 5212 auto o = cast(ArrayWrapperString)getClipboardContent(DND.SELECTION_CLIPBOARD);
5213 char[] text = o.array; 5213 String text = o.array;
5214 if (text !is null && text.length > 0) { 5214 if (text !is null && text.length > 0) {
5215 // position cursor 5215 // position cursor
5216 doMouseLocationChange(event.x, event.y, false); 5216 doMouseLocationChange(event.x, event.y, false);
5217 // insert text 5217 // insert text
5218 Event e = new Event(); 5218 Event e = new Event();
5524 */ 5524 */
5525 void initializeAccessible() { 5525 void initializeAccessible() {
5526 final Accessible accessible = getAccessible(); 5526 final Accessible accessible = getAccessible();
5527 accessible.addAccessibleListener(new class() AccessibleAdapter { 5527 accessible.addAccessibleListener(new class() AccessibleAdapter {
5528 public void getName (AccessibleEvent e) { 5528 public void getName (AccessibleEvent e) {
5529 char[] name = null; 5529 String name = null;
5530 Label label = getAssociatedLabel (); 5530 Label label = getAssociatedLabel ();
5531 if (label !is null) { 5531 if (label !is null) {
5532 name = stripMnemonic (label.getText()); 5532 name = stripMnemonic (label.getText());
5533 } 5533 }
5534 e.result = name; 5534 e.result = name;
5535 } 5535 }
5536 public void getHelp(AccessibleEvent e) { 5536 public void getHelp(AccessibleEvent e) {
5537 e.result = getToolTipText(); 5537 e.result = getToolTipText();
5538 } 5538 }
5539 public void getKeyboardShortcut(AccessibleEvent e) { 5539 public void getKeyboardShortcut(AccessibleEvent e) {
5540 char[] shortcut = null; 5540 String shortcut = null;
5541 Label label = getAssociatedLabel (); 5541 Label label = getAssociatedLabel ();
5542 if (label !is null) { 5542 if (label !is null) {
5543 char[] text = label.getText (); 5543 String text = label.getText ();
5544 if (text !is null) { 5544 if (text !is null) {
5545 dchar mnemonic = _findMnemonic (text); 5545 dchar mnemonic = _findMnemonic (text);
5546 if (mnemonic !is '\0') { 5546 if (mnemonic !is '\0') {
5547 shortcut = "Alt+"~tango.text.convert.Utf.toString( [mnemonic] ); //$NON-NLS-1$ 5547 shortcut = "Alt+"~tango.text.convert.Utf.toString( [mnemonic] ); //$NON-NLS-1$
5548 } 5548 }
5598 } 5598 }
5599 } 5599 }
5600 } 5600 }
5601 return null; 5601 return null;
5602 } 5602 }
5603 char[] stripMnemonic (char[] string) { 5603 String stripMnemonic (String string) {
5604 int index = 0; 5604 int index = 0;
5605 int length_ = string.length; 5605 int length_ = string.length;
5606 do { 5606 do {
5607 while ((index < length_) && (string[index] !is '&')) index++; 5607 while ((index < length_) && (string[index] !is '&')) index++;
5608 if (++index >= length_) return string; 5608 if (++index >= length_) return string;
5616 /* 5616 /*
5617 * Return the lowercase of the first non-'&' character following 5617 * Return the lowercase of the first non-'&' character following
5618 * an '&' character in the given string. If there are no '&' 5618 * an '&' character in the given string. If there are no '&'
5619 * characters in the given string, return '\0'. 5619 * characters in the given string, return '\0'.
5620 */ 5620 */
5621 dchar _findMnemonic (char[] string) { 5621 dchar _findMnemonic (String string) {
5622 if (string is null) return '\0'; 5622 if (string is null) return '\0';
5623 int index = 0; 5623 int index = 0;
5624 int length_ = string.length; 5624 int length_ = string.length;
5625 do { 5625 do {
5626 while (index < length_ && string[index] !is '&') index++; 5626 while (index < length_ && string[index] !is '&') index++;
5916 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 5916 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
5917 * </ul> 5917 * </ul>
5918 */ 5918 */
5919 public void paste(){ 5919 public void paste(){
5920 checkWidget(); 5920 checkWidget();
5921 char[] text = (cast(ArrayWrapperString) getClipboardContent(DND.CLIPBOARD)).array; 5921 String text = (cast(ArrayWrapperString) getClipboardContent(DND.CLIPBOARD)).array;
5922 if (text !is null && text.length > 0) { 5922 if (text !is null && text.length > 0) {
5923 Event event = new Event(); 5923 Event event = new Event();
5924 event.start = selection.x; 5924 event.start = selection.x;
5925 event.end = selection.y; 5925 event.end = selection.y;
5926 event.text = getModelDelimitedText(text); 5926 event.text = getModelDelimitedText(text);
6393 * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. 6393 * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter.
6394 * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li> 6394 * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>
6395 * <li>ERROR_NULL_ARGUMENT when string is null</li> 6395 * <li>ERROR_NULL_ARGUMENT when string is null</li>
6396 * </ul> 6396 * </ul>
6397 */ 6397 */
6398 public void replaceTextRange(int start, int length, char[] text) { 6398 public void replaceTextRange(int start, int length, String text) {
6399 checkWidget(); 6399 checkWidget();
6400 if (text is null) { 6400 if (text is null) {
6401 DWT.error(DWT.ERROR_NULL_ARGUMENT); 6401 DWT.error(DWT.ERROR_NULL_ARGUMENT);
6402 } 6402 }
6403 int contentLength = getCharCount(); 6403 int contentLength = getCharCount();
6636 * @param line line text. This may be the text of a visual line if 6636 * @param line line text. This may be the text of a visual line if
6637 * the widget is in word wrap mode. 6637 * the widget is in word wrap mode.
6638 * @return StyledTextEvent that can be used to request line data 6638 * @return StyledTextEvent that can be used to request line data
6639 * for the given line. 6639 * for the given line.
6640 */ 6640 */
6641 StyledTextEvent sendLineEvent(int eventType, int lineOffset, char[] line) { 6641 StyledTextEvent sendLineEvent(int eventType, int lineOffset, String line) {
6642 StyledTextEvent event = null; 6642 StyledTextEvent event = null;
6643 if (isListening(eventType)) { 6643 if (isListening(eventType)) {
6644 event = new StyledTextEvent(content); 6644 event = new StyledTextEvent(content);
6645 event.detail = lineOffset; 6645 event.detail = lineOffset;
6646 event.text = line; 6646 event.text = line;
6673 Event event = new Event(); 6673 Event event = new Event();
6674 event.x = selection.x; 6674 event.x = selection.x;
6675 event.y = selection.y; 6675 event.y = selection.y;
6676 notifyListeners(DWT.Selection, event); 6676 notifyListeners(DWT.Selection, event);
6677 } 6677 }
6678 int sendWordBoundaryEvent(int eventType, int movement, int offset, int newOffset, char[] lineText, int lineOffset) { 6678 int sendWordBoundaryEvent(int eventType, int movement, int offset, int newOffset, String lineText, int lineOffset) {
6679 if (isListening(eventType)) { 6679 if (isListening(eventType)) {
6680 StyledTextEvent event = new StyledTextEvent(content); 6680 StyledTextEvent event = new StyledTextEvent(content);
6681 event.detail = lineOffset; 6681 event.detail = lineOffset;
6682 event.text = lineText; 6682 event.text = lineText;
6683 event.count = movement; 6683 event.count = movement;
6872 */ 6872 */
6873 void setClipboardContent(int start, int length, int clipboardType) { 6873 void setClipboardContent(int start, int length, int clipboardType) {
6874 if (clipboardType is DND.SELECTION_CLIPBOARD && !(IS_MOTIF || IS_GTK)) return; 6874 if (clipboardType is DND.SELECTION_CLIPBOARD && !(IS_MOTIF || IS_GTK)) return;
6875 TextTransfer plainTextTransfer = TextTransfer.getInstance(); 6875 TextTransfer plainTextTransfer = TextTransfer.getInstance();
6876 TextWriter plainTextWriter = new TextWriter(start, length); 6876 TextWriter plainTextWriter = new TextWriter(start, length);
6877 char[] plainText = getPlatformDelimitedText(plainTextWriter); 6877 String plainText = getPlatformDelimitedText(plainTextWriter);
6878 Object[] data; 6878 Object[] data;
6879 Transfer[] types; 6879 Transfer[] types;
6880 if (clipboardType is DND.SELECTION_CLIPBOARD) { 6880 if (clipboardType is DND.SELECTION_CLIPBOARD) {
6881 data = [ cast(Object) new ArrayWrapperString(plainText) ]; 6881 data = [ cast(Object) new ArrayWrapperString(plainText) ];
6882 types = [plainTextTransfer]; 6882 types = [plainTextTransfer];
6883 } else { 6883 } else {
6884 RTFTransfer rtfTransfer = RTFTransfer.getInstance(); 6884 RTFTransfer rtfTransfer = RTFTransfer.getInstance();
6885 RTFWriter rtfWriter = new RTFWriter(start, length); 6885 RTFWriter rtfWriter = new RTFWriter(start, length);
6886 char[] rtfText = getPlatformDelimitedText(rtfWriter); 6886 String rtfText = getPlatformDelimitedText(rtfWriter);
6887 data = [ cast(Object) new ArrayWrapperString(rtfText), new ArrayWrapperString(plainText) ]; 6887 data = [ cast(Object) new ArrayWrapperString(rtfText), new ArrayWrapperString(plainText) ];
6888 types = [ cast(Transfer)rtfTransfer, plainTextTransfer]; 6888 types = [ cast(Transfer)rtfTransfer, plainTextTransfer];
6889 } 6889 }
6890 clipboard.setContents(data, types, clipboardType); 6890 clipboard.setContents(data, types, clipboardType);
6891 } 6891 }
8032 * </ul> 8032 * </ul>
8033 * @exception IllegalArgumentException <ul> 8033 * @exception IllegalArgumentException <ul>
8034 * <li>ERROR_NULL_ARGUMENT when string is null</li> 8034 * <li>ERROR_NULL_ARGUMENT when string is null</li>
8035 * </ul> 8035 * </ul>
8036 */ 8036 */
8037 public void setText(char[] text) { 8037 public void setText(String text) {
8038 checkWidget(); 8038 checkWidget();
8039 if (text is null) { 8039 if (text is null) {
8040 DWT.error(DWT.ERROR_NULL_ARGUMENT); 8040 DWT.error(DWT.ERROR_NULL_ARGUMENT);
8041 } 8041 }
8042 Event event = new Event(); 8042 Event event = new Event();