Mercurial > projects > dwt-addons
comparison dwtx/jface/text/TreeLineTracker.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | 25f1f92fa3df |
children | 3678e4f1a766 |
comparison
equal
deleted
inserted
replaced
158:25f1f92fa3df | 159:7926b636c282 |
---|---|
796 * <code>node</code> > <code>length</code> | 796 * <code>node</code> > <code>length</code> |
797 */ | 797 */ |
798 private void replaceInternal(Node node, String text, int length, int firstLineDelta) { | 798 private void replaceInternal(Node node, String text, int length, int firstLineDelta) { |
799 // 1) modification on a single line | 799 // 1) modification on a single line |
800 | 800 |
801 AbstractLineTracker.DelimiterInfo info= text is null ? null : nextDelimiterInfo(text, 0); | 801 AbstractLineTracker_DelimiterInfo info= text is null ? null : nextDelimiterInfo(text, 0); |
802 | 802 |
803 if (info is null || info.delimiter is null) { | 803 if (info is null || info.delimiter is null) { |
804 // a) trivial case: insert into a single node, no line mangling | 804 // a) trivial case: insert into a single node, no line mangling |
805 int added= text is null ? 0 : text.length(); | 805 int added= text is null ? 0 : text.length(); |
806 updateLength(node, added - length); | 806 updateLength(node, added - length); |
853 Node toDelete= successor; | 853 Node toDelete= successor; |
854 successor= successor(successor); | 854 successor= successor(successor); |
855 updateLength(toDelete, -toDelete.length); | 855 updateLength(toDelete, -toDelete.length); |
856 } | 856 } |
857 | 857 |
858 AbstractLineTracker.DelimiterInfo info= text is null ? null : nextDelimiterInfo(text, 0); | 858 AbstractLineTracker_DelimiterInfo info= text is null ? null : nextDelimiterInfo(text, 0); |
859 | 859 |
860 if (info is null || info.delimiter is null) { | 860 if (info is null || info.delimiter is null) { |
861 int added= text is null ? 0 : text.length(); | 861 int added= text is null ? 0 : text.length(); |
862 | 862 |
863 // join the two lines if there are no lines added | 863 // join the two lines if there are no lines added |
1208 * | 1208 * |
1209 * @param text the text to be searched | 1209 * @param text the text to be searched |
1210 * @param offset the offset in the given text | 1210 * @param offset the offset in the given text |
1211 * @return the information of the first found delimiter or <code>null</code> | 1211 * @return the information of the first found delimiter or <code>null</code> |
1212 */ | 1212 */ |
1213 protected abstract AbstractLineTracker.DelimiterInfo nextDelimiterInfo(String text, int offset); | 1213 protected abstract AbstractLineTracker_DelimiterInfo nextDelimiterInfo(String text, int offset); |
1214 | 1214 |
1215 /* | 1215 /* |
1216 * @see dwtx.jface.text.ILineTracker#getLineDelimiter(int) | 1216 * @see dwtx.jface.text.ILineTracker#getLineDelimiter(int) |
1217 */ | 1217 */ |
1218 public final String getLineDelimiter(int line) { | 1218 public final String getLineDelimiter(int line) { |
1224 * @see dwtx.jface.text.ILineTracker#computeNumberOfLines(java.lang.String) | 1224 * @see dwtx.jface.text.ILineTracker#computeNumberOfLines(java.lang.String) |
1225 */ | 1225 */ |
1226 public final int computeNumberOfLines(String text) { | 1226 public final int computeNumberOfLines(String text) { |
1227 int count= 0; | 1227 int count= 0; |
1228 int start= 0; | 1228 int start= 0; |
1229 AbstractLineTracker.DelimiterInfo delimiterInfo= nextDelimiterInfo(text, start); | 1229 AbstractLineTracker_DelimiterInfo delimiterInfo= nextDelimiterInfo(text, start); |
1230 while (delimiterInfo !is null && delimiterInfo.delimiterIndex > -1) { | 1230 while (delimiterInfo !is null && delimiterInfo.delimiterIndex > -1) { |
1231 ++count; | 1231 ++count; |
1232 start= delimiterInfo.delimiterIndex + delimiterInfo.delimiterLength; | 1232 start= delimiterInfo.delimiterIndex + delimiterInfo.delimiterLength; |
1233 delimiterInfo= nextDelimiterInfo(text, start); | 1233 delimiterInfo= nextDelimiterInfo(text, start); |
1234 } | 1234 } |