void drawLine(int lno) { if (lno < 0 || lno >= text.getLineCount()) return; int y = text.getLocationAtOffset(text.getOffsetAtLine(lno)).y; int height = 0; if (text.getLineCount() > lno + 1) height = text.getLocationAtOffset(text.getOffsetAtLine(lno + 1)).y - y; else height = text.getLocationAtOffset(text.getCharCount()).y + text.getLineHeight(); int width = text.getClientArea().width + text.getHorizontalPixel(); text.redraw(0, y, width, height, false); }
/** Moves caret to the position of currently active pair. */ public boolean matchPair() { if (currentPair == null) return false; int caret = text.getCaretOffset(); int lno = text.getLineAtOffset(caret); PairMatch cp = baseEditor.getPairMatch(lno, caret - text.getOffsetAtLine(lno)); baseEditor.searchGlobalPair(cp); if (cp.end == null) return false; if (cp.topPosition) text.setSelection(text.getOffsetAtLine(cp.eline) + cp.end.end); else text.setSelection(text.getOffsetAtLine(cp.eline) + cp.end.start); return true; }
void pairsDraw(GC gc, PairMatch pm) { if (pm == null) return; if (pm.start != null) { if (pm.sline >= text.getLineCount()) return; int lineOffset = text.getOffsetAtLine(pm.sline); pairDraw( gc, (StyledRegion) pm.start.rdef, pm.start.start + lineOffset, pm.start.end + lineOffset); } if (pm.end != null) { if (pm.eline >= text.getLineCount()) return; int lineOffset = text.getOffsetAtLine(pm.eline); pairDraw(gc, (StyledRegion) pm.end.rdef, pm.end.start + lineOffset, pm.end.end + lineOffset); } }
void redrawFrom(int lno) { if (lno < 0 || lno >= text.getLineCount()) return; int y = text.getLocationAtOffset(text.getOffsetAtLine(lno)).y; int height = text.getClientArea().height - y; int width = text.getClientArea().width + text.getHorizontalPixel(); text.redraw(0, y, width, height, false); }
public void stateChanged() { backParserDelay = true; int curLine = text.getLineAtOffset(text.getCaretOffset()); if (lineHighlighting && text.getSelectionRange().y != 0) { lineHighlighting = false; drawLine(prevLine); pairsHighlighting = false; pairsDraw(null, currentPair); return; } if (text.getSelectionRange().y != 0) return; if (!lineHighlighting) { // drawing current line lineHighlighting = true; drawLine(curLine); } else if (curLine != prevLine) { drawLine(prevLine); drawLine(curLine); prevLine = curLine; } // drawing current pairs if (!pairsHighlighting) { pairsHighlighting = true; pairsDraw(null, currentPair); } else { int lineOffset = text.getOffsetAtLine(curLine); PairMatch newmatch = baseEditor.getPairMatch(curLine, text.getCaretOffset() - lineOffset); if (newmatch != null) baseEditor.searchLocalPair(newmatch); if ((newmatch == null && currentPair != null) || (newmatch != null && !newmatch.equals(currentPair))) { pairsDraw(null, currentPair); pairsDraw(null, newmatch); } currentPair = newmatch; } }