Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bundles/org.eclipse.ui.editors/.settings/.api_filters
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,12 @@
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/ui/texteditor/stickyscroll/IStickyLine.java" type="org.eclipse.ui.texteditor.stickyscroll.IStickyLine">
<filter id="404000815">
<message_arguments>
<message_argument value="org.eclipse.ui.texteditor.stickyscroll.IStickyLine"/>
<message_argument value="getBackgroundColor()"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CaretEvent;
import org.eclipse.swt.custom.CaretListener;
import org.eclipse.swt.custom.LineBackgroundEvent;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.ControlEvent;
Expand Down Expand Up @@ -185,6 +186,7 @@ private void createControls() {
GridDataFactory.fillDefaults().grab(true, true).applyTo(stickyLineText);
stickyLineText.setEnabled(false);
stickyLineText.setBackground(settings.stickyLineBackgroundColor());
stickyLineText.addLineBackgroundListener(this::styleStickyLineBackground);

bottomSeparator= new Composite(stickyLinesCanvas, SWT.NONE);
GridDataFactory.fillDefaults().hint(0, 3).grab(true, false).span(2, 1).applyTo(bottomSeparator);
Expand Down Expand Up @@ -260,6 +262,12 @@ private void styleStickyLines() {
stickyLineText.setLeftMargin(textWidget.getLeftMargin());
}

private void styleStickyLineBackground(LineBackgroundEvent event) {
int lineIndex = stickyLineText.getLineAtOffset(event.lineOffset);
IStickyLine line = stickyLines.get(lineIndex);
event.lineBackground = line.getBackgroundColor();
}

private void layoutStickyLines() {
if (getNumberStickyLines() == 0) {
stickyLinesCanvas.setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.ui.texteditor.stickyscroll;

import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.Color;

/**
* Representation of a sticky line.
Expand Down Expand Up @@ -43,4 +44,23 @@ public interface IStickyLine {
*/
StyleRange[] getStyleRanges();

/**
* Returns the background color of the sticky line.
* <p>
* The background color is drawn for the full-width of the line. The text
* background color if defined in a StyleRange ({@link #getStyleRanges()})
* overlays the line background color.
* </p>
* <p>
* {@code null} (the default), if the line has no special background color.
* </p>
*
* @return the background color of the sticky line or {@code null} for no
* special color
* @since 3.22
*/
default Color getBackgroundColor() {
return null;
}

}
Loading