1 22 23 27 28 package org.netbeans.lib.terminalemulator; 29 30 39 40 public class WordDelineator { 41 52 protected int charClass(char c) { 53 if (Character.isWhitespace(c)) 54 return 1; 55 else 56 return 0; 57 } 58 59 62 protected int findLeft(StringBuffer buf, int start) { 63 int cclass = charClass(buf.charAt(start)); 64 65 int lx = start; 67 while (lx > 0 && charClass(buf.charAt(lx-1)) == cclass) { 68 lx--; 69 } 70 return lx; 71 } 72 73 76 protected int findRight(StringBuffer buf, int start) { 77 int cclass = charClass(buf.charAt(start)); 78 79 int rx = start; 81 while (rx < buf.length() && charClass(buf.charAt(rx)) == cclass) { 82 rx++; 83 } 84 rx--; 85 return rx; 86 } 87 } 88 89 | Popular Tags |