@Override public void paint(int reason) { if (fViewer.getDocument() == null) { deactivate(false); return; } StyledText textWidget= fViewer.getTextWidget(); // check selection if (hasMultiLineSelection(textWidget)) { deactivate(true); return; } // initialization if (!fIsActive) { textWidget.addLineBackgroundListener(this); fPositionManager.managePosition(fCurrentLine); fIsActive= true; } //redraw line highlight only if it hasn't been drawn yet on the respective line if (updateHighlightLine()) { // clear last line drawHighlightLine(fLastLine); // draw new line drawHighlightLine(fCurrentLine); } }
/** * Shows the cursor line. */ private void showCursorLine() { if (fCursorLinePainter == null) { if (fSourceViewer instanceof ITextViewerExtension2) { fCursorLinePainter= new CursorLinePainter(fSourceViewer); fCursorLinePainter.setHighlightColor(getColor(fCursorLinePainterColorKey)); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fCursorLinePainter); } } }
/** * Hides the cursor line. */ private void hideCursorLine() { if (fCursorLinePainter != null) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fCursorLinePainter); fCursorLinePainter.deactivate(true); fCursorLinePainter.dispose(); fCursorLinePainter= null; } } }
public void propertyChange(PropertyChangeEvent event) { if(event.getProperty().equals(ILogViewerConstants.PREF_CURSORLINE_COLOR)) { Color color = new Color(Display.getCurrent(),PreferenceConverter.getColor(store,ILogViewerConstants.PREF_CURSORLINE_COLOR)); cursorLinePainter.setHighlightColor(color); } if(event.getProperty().equals(ILogViewerConstants.PREF_EDITOR_FONT_STYLE)) { FontData[] fontData = PreferenceConverter.getFontDataArray(store,ILogViewerConstants.PREF_EDITOR_FONT_STYLE); txtViewer.getTextWidget().setFont(new Font(Display.getCurrent(),fontData)); } if(event.getProperty().equals(ILogViewerConstants.PREF_WORD_WRAP)) { boolean wordWrap = store.getBoolean(ILogViewerConstants.PREF_WORD_WRAP); txtViewer.getTextWidget().setWordWrap(wordWrap); } if(event.getProperty().equals(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED)) { showWhenUpdated = store.getBoolean(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED); } if(event.getProperty().equals(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE)) { showTopOfFile = store.getBoolean(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE); } } }
@Override public void lineGetBackground(LineBackgroundEvent event) { // don't use cached line information because of asynchronous painting StyledText textWidget= fViewer.getTextWidget(); if (textWidget != null) { int caret= textWidget.getCaretOffset(); int length= event.lineText.length(); if (event.lineOffset <= caret && caret <= event.lineOffset + length && !hasMultiLineSelection(textWidget)) event.lineBackground= fHighlightColor; } }
@Override public void deactivate(boolean redraw) { if (fIsActive) { fIsActive= false; /* on turning off the feature one has to paint the currently * highlighted line with the standard background color */ if (redraw) drawHighlightLine(fCurrentLine); fViewer.getTextWidget().removeLineBackgroundListener(this); if (fPositionManager != null) fPositionManager.unmanagePosition(fCurrentLine); fLastLineNumber= -1; fCurrentLine.offset= 0; fCurrentLine.length= 0; } }
int modelCaret= getModelCaret(); int lineNumber= document.getLineOfOffset(modelCaret);
@Override public void lineGetBackground(LineBackgroundEvent event) { // don't use cached line information because of asynchronous painting StyledText textWidget= fViewer.getTextWidget(); if (textWidget != null) { int caret= textWidget.getCaretOffset(); int length= event.lineText.length(); if (event.lineOffset <= caret && caret <= event.lineOffset + length && !hasMultiLineSelection(textWidget)) event.lineBackground= fHighlightColor; } }
@Override public void deactivate(boolean redraw) { if (fIsActive) { fIsActive= false; /* on turning off the feature one has to paint the currently * highlighted line with the standard background color */ if (redraw) drawHighlightLine(fCurrentLine); fViewer.getTextWidget().removeLineBackgroundListener(this); if (fPositionManager != null) fPositionManager.unmanagePosition(fCurrentLine); fLastLineNumber= -1; fCurrentLine.offset= 0; fCurrentLine.length= 0; } }
int modelCaret= getModelCaret(); int lineNumber= document.getLineOfOffset(modelCaret);
/** * Shows the cursor line. */ private void showCursorLine() { if (fCursorLinePainter == null) { if (fSourceViewer instanceof ITextViewerExtension2) { fCursorLinePainter= new CursorLinePainter(fSourceViewer); fCursorLinePainter.setHighlightColor(getColor(fCursorLinePainterColorKey)); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fCursorLinePainter); } } }
@Override public void paint(int reason) { if (fViewer.getDocument() == null) { deactivate(false); return; } StyledText textWidget= fViewer.getTextWidget(); // check selection if (hasMultiLineSelection(textWidget)) { deactivate(true); return; } // initialization if (!fIsActive) { textWidget.addLineBackgroundListener(this); fPositionManager.managePosition(fCurrentLine); fIsActive= true; } //redraw line highlight only if it hasn't been drawn yet on the respective line if (updateHighlightLine()) { // clear last line drawHighlightLine(fLastLine); // draw new line drawHighlightLine(fCurrentLine); } }
/** * Hides the cursor line. */ private void hideCursorLine() { if (fCursorLinePainter != null) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fCursorLinePainter); fCursorLinePainter.deactivate(true); fCursorLinePainter.dispose(); fCursorLinePainter= null; } } }
/** * Shows the cursor line. */ private void showCursorLine() { if (fCursorLinePainter == null) { if (fSourceViewer instanceof ITextViewerExtension2) { fCursorLinePainter= new CursorLinePainter(fSourceViewer); fCursorLinePainter.setHighlightColor(getColor(fCursorLinePainterColorKey)); ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.addPainter(fCursorLinePainter); } } }
/** * Hides the cursor line. */ private void hideCursorLine() { if (fCursorLinePainter != null) { if (fSourceViewer instanceof ITextViewerExtension2) { ITextViewerExtension2 extension= (ITextViewerExtension2) fSourceViewer; extension.removePainter(fCursorLinePainter); fCursorLinePainter.deactivate(true); fCursorLinePainter.dispose(); fCursorLinePainter= null; } } }
private void createCursorLinePainter() { cursorLinePainter = new CursorLinePainter(txtViewer); Color color = new Color(Display.getCurrent(),PreferenceConverter.getColor(store,ILogViewerConstants.PREF_CURSORLINE_COLOR)); cursorLinePainter.setHighlightColor(color); ITextViewerExtension2 extension = (ITextViewerExtension2)txtViewer; extension.addPainter(cursorLinePainter); }