Changeset 212:ab60f3309436 for dwt/custom/StyledText.d
- Timestamp:
- 05/04/08 18:12:38 (7 months ago)
- Files:
-
- dwt/custom/StyledText.d (modified) (58 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/custom/StyledText.d
r197 r212 149 149 150 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 152 static const int BIDI_CARET_WIDTH = 3; 153 153 static const int DEFAULT_WIDTH = 64; … … 230 230 const static bool IS_CARBON, IS_GTK, IS_MOTIF; 231 231 static this(){ 232 char[]platform = DWT.getPlatform();232 String platform = DWT.getPlatform(); 233 233 IS_CARBON = ("carbon" == platform); 234 234 IS_GTK = ("gtk" == platform); … … 314 314 StyledTextContent content = printerRenderer.content; 315 315 for (int i = 0; i < lineCount; i++) { 316 char[]line = content.getLine(i);316 String line = content.getLine(i); 317 317 int lineOffset = content.getOffsetAtLine(i); 318 318 StyledTextEvent event = styledText.getLineBackgroundData(lineOffset, line); … … 602 602 */ 603 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 605 if (text is null) return; 606 606 int lastSegmentIndex = 0; 607 607 for (int i = 0; i < 3; i++) { 608 608 int segmentIndex = tango.text.Util.locatePattern( text, StyledTextPrintOptions.SEPARATOR, lastSegmentIndex); 609 char[]segment;609 String segment; 610 610 if (segmentIndex is text.length ) { 611 611 segment = text[ lastSegmentIndex .. $ ].dup; … … 629 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 632 int pageIndex = tango.text.Util.locatePattern( segment, StyledTextPrintOptions.PAGE_TAG ); 633 633 if (pageIndex !is segment.length ) { … … 677 677 printLayout.setAscent(metrics.getAscent() + metrics.getDescent()); 678 678 printLayout.setDescent(metrics.getDescent()); 679 printLayout.setText( to!( char[])(index) );679 printLayout.setText( to!(String)(index) ); 680 680 int paintX = x - printMargin - printLayout.getBounds().width; 681 681 printLayout.draw(gc, paintX, y); … … 690 690 */ 691 691 public void run() { 692 char[]jobName = printOptions.jobName;692 String jobName = printOptions.jobName; 693 693 if (jobName is null) { 694 694 jobName = "Printing"; … … 805 805 */ 806 806 void setUnicode() { 807 // const char[]Win95 = "windows 95";808 // const char[]Win98 = "windows 98";809 // const char[]WinME = "windows me";810 // const char[]WinNT = "windows nt";811 // char[]osName = System.getProperty("os.name").toLowerCase();812 // char[]osVersion = System.getProperty("os.version");807 // const String Win95 = "windows 95"; 808 // const String Win98 = "windows 98"; 809 // const String WinME = "windows me"; 810 // const String WinNT = "windows nt"; 811 // String osName = System.getProperty("os.name").toLowerCase(); 812 // String osVersion = System.getProperty("os.version"); 813 813 // int majorVersion = 0; 814 814 // … … 840 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 843 wchar[] wstring = tango.text.convert.Utf.toString16( string[ start .. end ] ); 844 844 start = 0; … … 853 853 } 854 854 write("\\u"); 855 write( to!( char[])( cast(short)ch ));855 write( to!(String)( cast(short)ch )); 856 856 write(' '); // control word delimiter 857 857 start = index + 1; … … 882 882 // specify code page, necessary for copy to work in bidi 883 883 // systems that don't support Unicode RTF. 884 // PORTING_TODO: char[]cpg = System.getProperty("file.encoding").toLowerCase();885 char[]cpg = "UTF16";884 // PORTING_TODO: String cpg = System.getProperty("file.encoding").toLowerCase(); 885 String cpg = "UTF16"; 886 886 /+ 887 887 if (cpg.startsWith("cp") || cpg.startsWith("ms")) { … … 935 935 * </ul> 936 936 */ 937 public override void writeLine( char[]line, int lineOffset) {937 public override void writeLine(String line, int lineOffset) { 938 938 if (isClosed()) { 939 939 DWT.error(DWT.ERROR_IO); … … 972 972 * </ul> 973 973 */ 974 public override void writeLineDelimiter( char[]lineDelimiter) {974 public override void writeLineDelimiter(String lineDelimiter) { 975 975 if (isClosed()) { 976 976 DWT.error(DWT.ERROR_IO); … … 997 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 1000 int lineLength = line.length; 1001 1001 int startOffset = getStart(); … … 1175 1175 * @return the string 1176 1176 */ 1177 public override char[]toString() {1177 public override String toString() { 1178 1178 return buffer.toString(); 1179 1179 } … … 1181 1181 * Appends the given string to the data. 1182 1182 */ 1183 void write( char[]string) {1183 void write(String string) { 1184 1184 buffer.append(string); 1185 1185 } … … 1193 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 1196 if (offset < 0 || offset > buffer.length()) { 1197 1197 return; … … 1224 1224 * </ul> 1225 1225 */ 1226 public void writeLine( char[]line, int lineOffset) {1226 public void writeLine(String line, int lineOffset) { 1227 1227 if (isClosed_) { 1228 1228 DWT.error(DWT.ERROR_IO); … … 1251 1251 * </ul> 1252 1252 */ 1253 public void writeLineDelimiter( char[]lineDelimiter) {1253 public void writeLineDelimiter(String lineDelimiter) { 1254 1254 if (isClosed_) { 1255 1255 DWT.error(DWT.ERROR_IO); … … 1568 1568 * 1569 1569 * @param string the string to be appended 1570 * @see #replaceTextRange(int,int, char[])1570 * @see #replaceTextRange(int,int,String) 1571 1571 * @exception DWTException <ul> 1572 1572 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> … … 1577 1577 * </ul> 1578 1578 */ 1579 public void append( char[]string) {1579 public void append(String string) { 1580 1580 checkWidget(); 1581 1581 if (string is null) { … … 1892 1892 * has the DWT.SINGLE style. 1893 1893 */ 1894 char[] getModelDelimitedText(char[]text) {1894 String getModelDelimitedText(String text) { 1895 1895 int length = text.length; 1896 1896 if (length is 0) { … … 1901 1901 int i = 0; 1902 1902 StringBuffer convertedText = new StringBuffer(length); 1903 char[]delimiter = getLineDelimiter();1903 String delimiter = getLineDelimiter(); 1904 1904 while (i < length) { 1905 1905 if (crIndex !is -1) { … … 2256 2256 int lineIndex = content.getLineAtOffset(event.end); 2257 2257 int lineOffset = content.getOffsetAtLine(lineIndex); 2258 char[]line = content.getLine(lineIndex);2258 String line = content.getLine(lineIndex); 2259 2259 // replace character at caret offset if the caret is not at the 2260 2260 // end of the line … … 3247 3247 Rectangle getBoundsAtOffset(int offset) { 3248 3248 int lineIndex = content.getLineAtOffset(offset); 3249 char[]line = content.getLine(lineIndex);3249 String line = content.getLine(lineIndex); 3250 3250 Rectangle bounds; 3251 3251 if (line.length !is 0) { … … 3575 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 3578 return sendLineEvent(LineGetBackground, lineOffset, line); 3579 3579 } … … 3616 3616 * </ul> 3617 3617 */ 3618 public char[]getLineDelimiter() {3618 public String getLineDelimiter() { 3619 3619 checkWidget(); 3620 3620 return content.getLineDelimiter(); … … 3754 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 3757 return sendLineEvent(LineGetStyle, lineOffset, line); 3758 3758 } … … 3916 3916 int y = point.y - getLinePixel(lineIndex); 3917 3917 int offsetInLine = layout.getOffset(x, y, trailing); 3918 char[]line = content.getLine(lineIndex);3918 String line = content.getLine(lineIndex); 3919 3919 if (offsetInLine !is line.length - 1) { 3920 3920 offsetInLine = Math.min(line.length, offsetInLine + trailing[0]); … … 3954 3954 caretAlignment = PREVIOUS_OFFSET_TRAILING; 3955 3955 } else { 3956 char[]line = content.getLine(lineIndex);3956 String line = content.getLine(lineIndex); 3957 3957 int level; 3958 3958 int offset = offsetInLine; … … 4024 4024 * delimiter to separate lines as written by the specified TextWriter. 4025 4025 */ 4026 char[]getPlatformDelimitedText(TextWriter writer) {4026 String getPlatformDelimitedText(TextWriter writer) { 4027 4027 int end = writer.getStart() + writer.getCharCount(); 4028 4028 int startLine = content.getLineAtOffset(writer.getStart()); 4029 4029 int endLine = content.getLineAtOffset(end); 4030 char[]endLineText = content.getLine(endLine);4030 String endLineText = content.getLine(endLine); 4031 4031 int endLineOffset = content.getOffsetAtLine(endLine); 4032 4032 … … 4217 4217 * </ul> 4218 4218 */ 4219 public char[]getSelectionText() {4219 public String getSelectionText() { 4220 4220 checkWidget(); 4221 4221 return content.getTextRange(selection.x, selection.y - selection.x); … … 4249 4249 * </ul> 4250 4250 */ 4251 int [] getBidiSegments(int lineOffset, char[]line) {4251 int [] getBidiSegments(int lineOffset, String line) { 4252 4252 if (!isBidi()) return null; 4253 4253 if (!isListening(LineGetSegments)) { … … 4286 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 4289 int lineLength = line.length; 4290 4290 if (!bidiColoring) { … … 4540 4540 * </ul> 4541 4541 */ 4542 public char[]getText() {4542 public String getText() { 4543 4543 checkWidget(); 4544 4544 return content.getTextRange(0, getCharCount()); … … 4547 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 4550 * @param end offset of the last character in the returned String 4551 4551 * @return widget content starting at start and ending at end … … 4559 4559 * </ul> 4560 4560 */ 4561 public char[]getText(int start, int end) {4561 public String getText(int start, int end) { 4562 4562 checkWidget(); 4563 4563 int contentLength = getCharCount(); … … 4601 4601 rect = layout.getBounds(start - lineOffset, end - lineOffset); 4602 4602 } else if (i is lineStart) { 4603 char[]line = content.getLine(i);4603 String line = content.getLine(i); 4604 4604 rect = layout.getBounds(start - lineOffset, line.length); 4605 4605 } else if (i is lineEnd) { … … 4634 4634 * </ul> 4635 4635 */ 4636 public char[]getTextRange(int start, int length) {4636 public String getTextRange(int start, int length) { 4637 4637 checkWidget(); 4638 4638 int contentLength = getCharCount(); … … 4731 4731 int caretLine = getCaretLine(); 4732 4732 int lineOffset = content.getOffsetAtLine(caretLine); 4733 char[]line = content.getLine(caretLine);4733 String line = content.getLine(caretLine); 4734 4734 int offset = caretOffset - lineOffset; 4735 4735 int lineLength = line.length; … … 4761 4761 int getWordNext (int offset, int movement) { 4762 4762 int newOffset, lineOffset; 4763 char[]lineText;4763 String lineText; 4764 4764 if (offset >= getCharCount()) { 4765 4765 newOffset = offset; … … 4784 4784 int getWordPrevious(int offset, int movement) { 4785 4785 int newOffset, lineOffset; 4786 char[]lineText;4786 String lineText; 4787 4787 if (offset <= 0) { 4788 4788 newOffset = 0; … … 4795 4795 lineText = content.getLine(lineIndex); 4796 4796 if (offset is lineOffset) { 4797 char[]nextLineText = content.getLine(lineIndex - 1);4797 String nextLineText = content.getLine(lineIndex - 1); 4798 4798 int nextLineOffset = content.getOffsetAtLine(lineIndex - 1); 4799 4799 newOffset = nextLineOffset + nextLineText.length; … … 4826 4826 Point getPointAtOffset(int offset) { 4827 4827 int lineIndex = content.getLineAtOffset(offset); 4828 char[]line = content.getLine(lineIndex);4828 String line = content.getLine(lineIndex); 4829 4829 int lineOffset = content.getOffsetAtLine(lineIndex); 4830 4830 int offsetInLine = offset - lineOffset; … … 4868 4868 * 4869 4869 * @param string the string 4870 * @see #replaceTextRange(int,int, char[])4870 * @see #replaceTextRange(int,int,String) 4871 4871 * @exception DWTException <ul> 4872 4872 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> … … 4877 4877 * </ul> 4878 4878 */ 4879 public void insert( char[]string) {4879 public void insert(String string) { 4880 4880 checkWidget(); 4881 4881 if (string is null) { … … 5211 5211 if (event.button is 2) { 5212 5212 auto o = cast(ArrayWrapperString)getClipboardContent(DND.SELECTION_CLIPBOARD); 5213 char[]text = o.array;5213 String text = o.array; 5214 5214 if (text !is null && text.length > 0) { 5215 5215 // position cursor … … 5527 5527 accessible.addAccessibleListener(new class() AccessibleAdapter { 5528 5528 public void getName (AccessibleEvent e) { 5529 char[]name = null;5529 String name = null; 5530 5530 Label label = getAssociatedLabel (); 5531 5531 if (label !is null) { … … 5538 5538 } 5539 5539 public void getKeyboardShortcut(AccessibleEvent e) { 5540 char[]shortcut = null;5540 String shortcut = null; 5541 5541 Label label = getAssociatedLabel (); 5542 5542 if (label !is null) { 5543 char[]text = label.getText ();5543 String text = label.getText (); 5544 5544 if (text !is null) { 5545 5545 dchar mnemonic = _findMnemonic (text); … … 5601 5601 return null; 5602 5602 } 5603 char[] stripMnemonic (char[]string) {5603 String stripMnemonic (String string) { 5604 5604 int index = 0; 5605 5605 int length_ = string.length; … … 5619 5619 * characters in the given string, return '\0'. 5620 5620 */ 5621 dchar _findMnemonic ( char[]string) {5621 dchar _findMnemonic (String string) { 5622 5622 if (string is null) return '\0'; 5623 5623 int index = 0; … … 5919 5919 public void paste(){ 5920 5920 checkWidget(); 5921 char[]text = (cast(ArrayWrapperString) getClipboardContent(DND.CLIPBOARD)).array;5921 String text = (cast(ArrayWrapperString) getClipboardContent(DND.CLIPBOARD)).array; 5922 5922 if (text !is null && text.length > 0) { 5923 5923 Event event = new Event(); … … 6396 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 6399 checkWidget(); 6400 6400 if (text is null) { … … 6639 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 6642 StyledTextEvent event = null; 6643 6643 if (isListening(eventType)) { … … 6676 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 6679 if (isListening(eventType)) { 6680 6680 StyledTextEvent event = new StyledTextEvent(content); … … 6875 6875 TextTransfer plainTextTransfer = TextTransfer.getInstance(); 6876 6876 TextWriter plainTextWriter = new TextWriter(start, length); 6877 char[]plainText = getPlatformDelimitedText(plainTextWriter);6877 String plainText = getPlatformDelimitedText(plainTextWriter); 6878 6878 Object[] data; 6879 6879 Transfer[] types; … … 6884 6884 RTFTransfer rtfTransfer = RTFTransfer.getInstance(); 6885 6885 RTFWriter rtfWriter = new RTFWriter(start, length); 6886 char[]rtfText = getPlatformDelimitedText(rtfWriter);6886 String rtfText = getPlatformDelimitedText(rtfWriter); 6887 6887 data = [ cast(Object) new ArrayWrapperString(rtfText), new ArrayWrapperString(plainText) ]; 6888 6888 types = [ cast(Transfer)rtfTransfer, plainTextTransfer]; … … 8035 8035 * </ul> 8036 8036 */ 8037 public void setText( char[]text) {8037 public void setText(String text) { 8038 8038 checkWidget(); 8039 8039 if (text is null) {
