/** * Specifies visibility of cross at the cursor position. * * @param vert Not used */ public void setCross(boolean horz, boolean vert) { horzCross = horz; vertCross = vert; vertCrossColor = null; horzCrossColor = null; if (horzCross) horzCrossColor = baseEditor.getHorzCross(); if (vertCross) vertCrossColor = baseEditor.getVertCross(); }
/** 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 updateViewport() { baseEditor.lineCountEvent(text.getLineCount()); int start = 0; try { start = text.getTopIndex() - 1; } catch (Exception e) { e.printStackTrace(System.out); } if (start < 0) start = 0; int end = start + text.getClientArea().height / text.getLineHeight(); baseEditor.visibleTextEvent(start, end - start + 2); }
/** * Changes style/coloring scheme into the specified. * * @param name Name of color scheme (HRD name). * @param useBackground If true, native HRD background properties would be assigned to colored * StyledText. */ public void setRegionMapper(String name, boolean useBackground) { baseEditor.setRegionMapper("rgb", name); StyledRegion sr = (StyledRegion) baseEditor.getBackground(); text.setForeground(null); text.setBackground(null); if (useBackground) { text.setForeground(cm.getColor(sr.bfore, sr.fore)); text.setBackground(cm.getColor(sr.bback, sr.back)); } ; /* if ((sr.style & StyledRegion.BOLD) != 0){ Font cf = text.getFont(); FontData fdata[] = cf.getFontData(); fdata[0].setStyle(SWT.BOLD); text.setFont(new Font(text.getDisplay(), fdata)); System.out.println("font!"); }; */ setCross(vertCross, horzCross); };
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; } }
/** * Common TextColorer creation constructor. Creates TextColorer object, which is to be attached to * the StyledText widget. * * @param pf Parser factory, used to create all coloring text parsers. * @param cm Color Manager, used to store cached color objects */ public TextColorer(ParserFactory pf, ColorManager cm) { this.pf = pf; this.cm = cm; setFullBackground(false); setCross(false, false); baseEditor = new BaseEditorNative( pf, new LineSource() { public String getLine(int lno) { if (text.getContent().getLineCount() <= lno) return null; String line = text.getContent().getLine(lno); return line; } }); baseEditor.setRegionCompact(true); }
void modifyEvent(int lno) { updateViewport(); baseEditor.modifyEvent(lno); redrawFrom(lno); stateChanged(); }
/** Removes specified handler from the parse process. */ public void removeRegionHandler(RegionHandler rh) { baseEditor.removeRegionHandler(rh); }
/** Installs specified handler into parse process. */ public void addRegionHandler(RegionHandler rh) { baseEditor.addRegionHandler(rh, rh.getFilter()); }
/** Returns currently used file type. */ public FileType getFileType() { return baseEditor.getFileType(); }
/** * Selects and installs specified file type. * * @param typename Name or description of HRC filetype. */ public void setFileType(FileType typename) { baseEditor.setFileType(typename); }
/** * Selects and installs coloring style (filetype) according to filename string and current first * line of text. * * @param filename File name to be used to autodetect filetype */ public FileType chooseFileType(String filename) { return baseEditor.chooseFileType(filename); }