org.eclipse.swt.custom.LineBackgroundEvent Java Examples
The following examples show how to use
org.eclipse.swt.custom.LineBackgroundEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BrowseKillRingHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Return the correct background highlight for the kill ring entry line offset * * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) */ public void lineGetBackground(LineBackgroundEvent event) { KilledText kt = offsetHash.get(event.lineOffset); if (kt == null) { for (KilledText k : ringEntries) { if (event.lineOffset >= k.begin && event.lineOffset <= k.end) { offsetHash.put(event.lineOffset, k); kt = k; break; } } } if (kt != null) { event.lineBackground = kt.color; } }
Example #2
Source File: XdsConsoleViewer.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
@Override public void lineGetBackground(LineBackgroundEvent event) { if (event.lineOffset >= markedOffset && event.lineOffset < markedOffset + markedLength) { event.lineBackground = new Color(event.display, 255,255,128); } else { event.lineBackground = null; } }
Example #3
Source File: FindReplaceDialog.java From Rel with Apache License 2.0 | 5 votes |
@Override public void lineGetBackground(LineBackgroundEvent event) { if (!btnRadioSelected.getSelection()) return; if (isOverlappingOriginalSelectionLineOffsetRange(event.lineOffset, event.lineText.length())) event.lineBackground = originalSelectionHighlightColor; }
Example #4
Source File: SyntaxHighlighter.java From RepDev with GNU General Public License v3.0 | 5 votes |
public void lineGetBackground(LineBackgroundEvent event) { boolean go = false; for( int i : customLines) if( i == txt.getLineAtOffset(event.lineOffset) ) { go = true; break; } if( go ){ event.lineBackground = customColor; } }
Example #5
Source File: LineBackgroundPainter.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
public void lineGetBackground(LineBackgroundEvent event) { if (fViewer == null) { return; } final StyledText textWidget = fViewer.getTextWidget(); if (textWidget == null) { return; } try { final int offset = event.lineOffset; IDocument document = fViewer.getDocument(); int line = document.getLineOfOffset(offset); final IRegion lineRegion = document.getLineInformation(line); // Handle fully opaque line highlight here. A modified approach from CursorLinePainter. if (fEnabled && isOpaque() && isCurrentLine(line)) { // draw current line drawCurrentLine(event, lineRegion); return; } // Not drawing an opaque line highlight, so we need to do our normal line coloring here. // This extends the bg color out for a given line based on it's end scope. String endOfLineScope = getScopeManager().getScopeAtOffset(document, lineRegion.getLength() + offset); String commonPrefix = getScope(document, line, endOfLineScope); TextAttribute at = getCurrentTheme().getTextAttribute(commonPrefix); // if we have no color we need to extend to end of line, but this used to be the highlight line, force the // theme bg color if (at.getBackground() == null && isOpaque() && fLastLine.includes(offset)) { event.lineBackground = getColorManager().getColor(getCurrentTheme().getBackground()); } else { event.lineBackground = at.getBackground(); } } catch (BadLocationException e) { IdeLog.logError(CommonEditorPlugin.getDefault(), e); } }
Example #6
Source File: LineBackgroundPainter.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void drawCurrentLine(LineBackgroundEvent event, final IRegion lineRegion) { final StyledText textWidget = fViewer.getTextWidget(); final int offset = event.lineOffset; final RGBa lineHighlight = getCurrentTheme().getLineHighlight(); event.lineBackground = getColorManager().getColor(lineHighlight.toRGB()); // In this case, we should be overriding the bg of the style ranges for the line too! if (textWidget.isDisposed()) { return; } // FIXME Only change bg colors of visible ranges! int replaceLength = 160; if (lineRegion != null) { replaceLength = Math.min(replaceLength, lineRegion.getLength()); } // be safe about offsets int charCount = textWidget.getCharCount(); if (offset + replaceLength > charCount) { replaceLength = charCount - offset; if (replaceLength < 0) { // Just playing safe here replaceLength = 0; } } final StyleRange[] ranges = textWidget.getStyleRanges(offset, replaceLength, true); if (ranges == null || ranges.length == 0) { return; } Color background = textWidget.getBackground(); final int[] positions = new int[ranges.length << 1]; int x = 0; boolean apply = false; for (StyleRange range : ranges) { if (range.background != null) { if (!range.background.equals(background)) { positions[x] = range.start; positions[x + 1] = range.length; x += 2; continue; } apply = true; } range.background = null; positions[x] = range.start; positions[x + 1] = range.length; x += 2; } if (apply) { textWidget.setStyleRanges(offset, replaceLength, positions, ranges); } }
Example #7
Source File: ScriptConsoleViewerWrapper.java From Pydev with Eclipse Public License 1.0 | 4 votes |
public void lineGetBackground(LineBackgroundEvent event) { viewer.lineGetBackground(event); }