Mercurial > projects > dwt-win
comparison dwt/custom/DefaultContent.d @ 274:62a03a4c21c8
sync StyledText with dwt-linux
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 23:40:57 +0200 |
parents | a63e2cd5485e |
children |
comparison
equal
deleted
inserted
replaced
273:8632408a70aa | 274:62a03a4c21c8 |
---|---|
19 import dwt.custom.StyledTextContent; | 19 import dwt.custom.StyledTextContent; |
20 import dwt.custom.TextChangeListener; | 20 import dwt.custom.TextChangeListener; |
21 import dwt.custom.StyledTextEvent; | 21 import dwt.custom.StyledTextEvent; |
22 import dwt.custom.StyledTextListener; | 22 import dwt.custom.StyledTextListener; |
23 import dwt.custom.StyledText; | 23 import dwt.custom.StyledText; |
24 import dwt.dwthelper.utils; | |
24 | 25 |
25 static import tango.io.model.IFile; | 26 static import tango.io.model.IFile; |
26 static import tango.text.Text; | 27 static import tango.text.Text; |
27 import dwt.dwthelper.utils; | |
28 | 28 |
29 alias tango.text.Text.Text!(char) StringBuffer; | 29 alias tango.text.Text.Text!(char) StringBuffer; |
30 | 30 |
31 class DefaultContent : StyledTextContent { | 31 class DefaultContent : StyledTextContent { |
32 private final static String LineDelimiter = tango.io.model.IFile.FileConst.NewlineString; | 32 private final static String LineDelimiter = tango.io.model.IFile.FileConst.NewlineString; |
33 | 33 |
34 StyledTextListener[] textListeners; // stores text listeners for event sending | 34 StyledTextListener[] textListeners; // stores text listeners for event sending |
35 String textStore; // stores the actual text | 35 char[] textStore; // stores the actual text |
36 int gapStart = -1; // the character position start of the gap | 36 int gapStart = -1; // the character position start of the gap |
37 int gapEnd = -1; // the character position after the end of the gap | 37 int gapEnd = -1; // the character position after the end of the gap |
38 int gapLine = -1; // the line on which the gap exists, the gap will always be associated with one line | 38 int gapLine = -1; // the line on which the gap exists, the gap will always be associated with one line |
39 int highWatermark = 300; | 39 int highWatermark = 300; |
40 int lowWatermark = 50; | 40 int lowWatermark = 50; |
732 /** | 732 /** |
733 * Removes the specified <code>TextChangeListener</code>. | 733 * Removes the specified <code>TextChangeListener</code>. |
734 * <p> | 734 * <p> |
735 * | 735 * |
736 * @param listener the listener which should no longer be notified | 736 * @param listener the listener which should no longer be notified |
737 * | 737 * |
738 * @exception IllegalArgumentException <ul> | 738 * @exception IllegalArgumentException <ul> |
739 * <li>ERROR_NULL_ARGUMENT when listener is null</li> | 739 * <li>ERROR_NULL_ARGUMENT when listener is null</li> |
740 * </ul> | 740 * </ul> |
741 */ | 741 */ |
742 public void removeTextChangeListener(TextChangeListener listener){ | 742 public void removeTextChangeListener(TextChangeListener listener){ |
889 lines[i - numOldLines] = lines[i]; | 889 lines[i - numOldLines] = lines[i]; |
890 } | 890 } |
891 lineCount_ -= numOldLines; | 891 lineCount_ -= numOldLines; |
892 gapLine = getLineAtPhysicalOffset(gapStart); | 892 gapLine = getLineAtPhysicalOffset(gapStart); |
893 } | 893 } |
894 } | 894 |
895 /++ | |
896 + DWT extension | |
897 +/ | |
898 int utf8AdjustOffset( int offset ){ | |
899 if (textStore is null) | |
900 return offset; | |
901 if (offset is 0) | |
902 return offset; | |
903 if( offset >= textStore.length ){ | |
904 return offset; | |
905 } | |
906 if (!gapExists() || (offset < gapStart)){ | |
907 while( textStore[offset] & 0xC0 is 0x80 ){ | |
908 offset--; | |
909 } | |
910 return offset; | |
911 } | |
912 int gapLength= gapEnd - gapStart; | |
913 if( offset+gapLength >= textStore.length ){ | |
914 return offset; | |
915 } | |
916 while( textStore[offset+gapLength] & 0xC0 is 0x80 ){ | |
917 offset--; | |
918 } | |
919 return offset; | |
920 } | |
921 | |
922 | |
923 } |