StyleRange style = text.getStyleRangeAtOffset(i);
if (style != null) {
style.start = style.start - startX;
if (!cachedStyles.isEmpty()) {
StyleRange lastStyle = (StyleRange) cachedStyles.lastElement();
if (lastStyle.similarTo(style) && lastStyle.start + lastStyle.length == style.start)
lastStyle.length++;
else
cachedStyles.addElement(style);
} else
cachedStyles.addElement(style);