public static int getPrevWordBreakForCache(TextBuff buff, int offset) { int len = buff.size; if (offset == 0) { return(0); } if (offset > len) { offset = len; } if (isWordBreakBefore(buff.charAt(offset - 1))) { return(offset - 1); } for (int i = offset - 1; i > 0; i--) { if (isWordBreakBefore(buff.charAt(i)) || isWordBreakAfter(buff.charAt(i - 1))) { return(i); } } return(0); }
static uint preCode(TextBuff text, ref int index, int start) { --index; uint ch = text.charAt(index); if (isTrailSurrogate(ch)) { if (index > start && isLeadSurrogate(text.charAt(index - 1))) { ch = getSupplementary(text.charAt(index - 1), ch); --index; } } return(ch); }
static uint nextCode(TextBuff text, ref int index, int end) { uint ch = text.charAt(index); index++; if (isLeadSurrogate(ch)) { if (index < end && isTrailSurrogate(text.charAt(index))) { char ch2 = text.charAt(index); index++; ch = getSupplementary(ch, ch2); } } return(ch); }
public static int getNextWordBreakForCache(TextBuff buff, int offset) { int len = buff.size; if (offset >= len) { return(len); } if (isWordBreakAfter(buff.charAt(offset))) { return(offset + 1); } for (int i = offset + 1; i < len; i++) { if (isWordBreakBefore(buff.charAt(i))) { return(i); } } return(len); }