1 11 package org.eclipse.jface.text; 12 13 14 23 public class DefaultLineTracker extends AbstractLineTracker { 24 25 26 public final static String [] DELIMITERS= { "\r", "\n", "\r\n" }; 28 private DelimiterInfo fDelimiterInfo= new DelimiterInfo(); 29 30 31 34 public DefaultLineTracker() { 35 } 36 37 40 public String [] getLegalLineDelimiters() { 41 return TextUtilities.copy(DELIMITERS); 42 } 43 44 47 protected DelimiterInfo nextDelimiterInfo(String text, int offset) { 48 49 char ch; 50 int length= text.length(); 51 for (int i= offset; i < length; i++) { 52 53 ch= text.charAt(i); 54 if (ch == '\r') { 55 56 if (i + 1 < length) { 57 if (text.charAt(i + 1) == '\n') { 58 fDelimiterInfo.delimiter= DELIMITERS[2]; 59 fDelimiterInfo.delimiterIndex= i; 60 fDelimiterInfo.delimiterLength= 2; 61 return fDelimiterInfo; 62 } 63 } 64 65 fDelimiterInfo.delimiter= DELIMITERS[0]; 66 fDelimiterInfo.delimiterIndex= i; 67 fDelimiterInfo.delimiterLength= 1; 68 return fDelimiterInfo; 69 70 } else if (ch == '\n') { 71 72 fDelimiterInfo.delimiter= DELIMITERS[1]; 73 fDelimiterInfo.delimiterIndex= i; 74 fDelimiterInfo.delimiterLength= 1; 75 return fDelimiterInfo; 76 } 77 } 78 79 return null; 80 } 81 } 82 | Popular Tags |