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
24 changes: 24 additions & 0 deletions src/main/java/org/fife/ui/rtextarea/RTextAreaBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public abstract class RTextAreaBase extends JTextArea {
private boolean tabsEmulatedWithSpaces; // If true, tabs will be expanded to spaces.

private boolean highlightCurrentLine; // If true, the current line is highlighted.
private boolean paintCurrentLineHighlightFirst; // If true (default is false), the current line highlight will be painted before the custom line highlights.
private Color currentLineColor; // The color used to highlight the current line.
private boolean marginLineEnabled; // If true, paint a "margin line."
private Color marginLineColor; // The color used to paint the margin line.
Expand Down Expand Up @@ -542,6 +543,14 @@ public boolean getHighlightCurrentLine() {
return highlightCurrentLine;
}

/**
* Returns whether or not the current line highlight should be painted (overwritten) before the custom linr highlight.
*
* @return true if the custom line highlight should overwrite the current line highlight.
*/
public boolean getPaintCurrentLineHighlightFirst() {
return this.paintCurrentLineHighlightFirst;
}

/**
* Returns the offset of the last character of the line that the caret is
Expand Down Expand Up @@ -660,6 +669,7 @@ protected void init() {

// Defaults for various properties.
setHighlightCurrentLine(true);
this.setPaintCurrentLineHighlightFirst(false);
setCurrentLineHighlightColor(getDefaultCurrentLineHighlightColor());
setMarginLineEnabled(false);
setMarginLineColor(getDefaultMarginLineColor());
Expand Down Expand Up @@ -1003,6 +1013,20 @@ public void setHighlightCurrentLine(boolean highlight) {
}
}

/**
* Sets whether the current line highlight should be painted before the custom line highlight.
* In this case if there is a custom line highlight the current line highlight will be overwritten.
* This is useful when line highlights are used to show breakpoints.
* For example, if there is a breakpoint at line X, the line may have a specific background,
* now if the user moves the cursor at that line should we paint first the current line background
* or the background of the breakpoint line? Setting true will paint current line background
* and then the breakpoint line background.
*
* @param paintCurrentLineHighlightFirst - true to override the current line highlight by the custom line highlight.
*/
public void setPaintCurrentLineHighlightFirst(final boolean paintCurrentLineHighlightFirst) {
this.paintCurrentLineHighlightFirst = paintCurrentLineHighlightFirst;
}

/**
* Sets whether or not word wrap is enabled. This is overridden so that
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/org/fife/ui/rtextarea/RTextAreaUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected ActionMap createRTextAreaActionMap() {
map.put(TransferHandler.getCopyAction().getValue(Action.NAME),
TransferHandler.getCopyAction());
map.put(TransferHandler.getPasteAction().getValue(Action.NAME),
TransferHandler.getPasteAction());
TransferHandler.getPasteAction());

return map;

Expand Down Expand Up @@ -489,8 +489,14 @@ protected void paintCurrentLineHighlight(Graphics g, Rectangle visibleRect) {
*/
protected void paintEditorAugmentations(Graphics g) {
Rectangle visibleRect = textArea.getVisibleRect();
boolean first = textArea.getPaintCurrentLineHighlightFirst();
if (first) {
paintCurrentLineHighlight(g, visibleRect);
}
paintLineHighlights(g);
paintCurrentLineHighlight(g, visibleRect);
if (!first) {
paintCurrentLineHighlight(g, visibleRect);
}
paintMarginLine(g, visibleRect);
}

Expand Down