Skip to content

Commit eb4889e

Browse files
committed
Remove Line & Gutter Color support
1 parent 814657a commit eb4889e

File tree

3 files changed

+12
-147
lines changed

3 files changed

+12
-147
lines changed

java/src/processing/mode/java/JavaEditor.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ public class JavaEditor extends Editor {
4949

5050
// Need to sort through the rest of these additions [fry]
5151

52-
// TODO these are all null, need to remove color support
53-
protected Color breakpointColor;
54-
protected Color currentLineColor;
55-
protected Color breakpointMarkerColor;
56-
protected Color currentLineMarkerColor;
57-
5852
protected List<LineHighlight> breakpointedLines =
5953
new ArrayList<LineHighlight>();
6054
protected LineHighlight currentLine; // where the debugger is suspended
@@ -2213,8 +2207,8 @@ public void setCurrentLine(LineID line) {
22132207
// scroll to line, by setting the cursor
22142208
cursorToLineStart(line.lineIdx());
22152209
// highlight line
2216-
currentLine = new LineHighlight(line.lineIdx(), currentLineColor, this);
2217-
currentLine.setMarker(JavaTextArea.STEP_MARKER, currentLineMarkerColor);
2210+
currentLine = new LineHighlight(line.lineIdx(), this);
2211+
currentLine.setMarker(JavaTextArea.STEP_MARKER);
22182212
currentLine.setPriority(10); // fixes current line being hidden by the breakpoint when moved down
22192213
}
22202214

@@ -2242,8 +2236,8 @@ public void clearCurrentLine() {
22422236
* @param lineID the line id to highlight as breakpointed
22432237
*/
22442238
public void addBreakpointedLine(LineID lineID) {
2245-
LineHighlight hl = new LineHighlight(lineID, breakpointColor, this);
2246-
hl.setMarker(JavaTextArea.BREAK_MARKER, breakpointMarkerColor);
2239+
LineHighlight hl = new LineHighlight(lineID, this);
2240+
hl.setMarker(JavaTextArea.BREAK_MARKER);
22472241
breakpointedLines.add(hl);
22482242
// repaint current line if it's on this line
22492243
if (currentLine != null && currentLine.getLineID().equals(lineID)) {
@@ -2299,7 +2293,6 @@ public void clearBreakpointedLines() {
22992293
breakpointedLines.clear(); // remove all breakpoints
23002294
// fix highlights not being removed when tab names have
23012295
// changed due to opening a new sketch in same editor
2302-
getJavaTextArea().clearLineBgColors(); // force clear all highlights
23032296
getJavaTextArea().clearGutterText();
23042297

23052298
// repaint current line
@@ -2364,11 +2357,8 @@ public void setCode(SketchCode code) {
23642357
final JavaTextArea ta = getJavaTextArea();
23652358
// can be null when setCode is called the first time (in constructor)
23662359
if (ta != null) {
2367-
// clear all line backgrounds
2368-
ta.clearLineBgColors();
23692360
// clear all gutter text
23702361
ta.clearGutterText();
2371-
// load appropriate line backgrounds for tab
23722362
// first paint breakpoints
23732363
if (breakpointedLines != null) {
23742364
for (LineHighlight hl : breakpointedLines) {

java/src/processing/mode/java/debug/LineHighlight.java

Lines changed: 8 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
package processing.mode.java.debug;
2222

23-
import java.awt.Color;
2423
import java.util.HashSet;
2524
import java.util.Set;
2625

@@ -35,25 +34,21 @@
3534
*/
3635
public class LineHighlight {
3736

38-
protected JavaEditor editor; // the view, used for highlighting lines by setting a background color
39-
protected Color bgColor; // the background color for highlighting lines
40-
protected LineID lineID; // the id of the line
37+
protected final JavaEditor editor; // the view, used for highlighting lines by setting a background color
38+
protected final LineID lineID; // the id of the line
4139
protected String marker; //
42-
protected Color markerColor;
4340
protected int priority = 0;
44-
protected static Set<LineHighlight> allHighlights = new HashSet<LineHighlight>();
41+
protected static final Set<LineHighlight> allHighlights = new HashSet<>();
4542

4643

4744
/**
4845
* Create a {@link LineHighlight}.
4946
*
5047
* @param lineID the line id to highlight
51-
* @param bgColor the background color used for highlighting
5248
* @param editor the {@link JavaEditor}
5349
*/
54-
public LineHighlight(LineID lineID, Color bgColor, JavaEditor editor) {
50+
public LineHighlight(LineID lineID, JavaEditor editor) {
5551
this.lineID = lineID;
56-
this.bgColor = bgColor;
5752
this.editor = editor;
5853
lineID.addListener(this);
5954
lineID.startTracking(editor.getTab(lineID.fileName()).getDocument()); // TODO: overwrite a previous doc?
@@ -87,12 +82,11 @@ public int priority() {
8782
* Create a {@link LineHighlight} on the current tab.
8883
*
8984
* @param lineIdx the line index on the current tab to highlight
90-
* @param bgColor the background color used for highlighting
9185
* @param editor the {@link JavaEditor}
9286
*/
93-
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, Color bgColor, JavaEditor editor)}
94-
public LineHighlight(int lineIdx, Color bgColor, JavaEditor editor) {
95-
this(editor.getLineIDInCurrentTab(lineIdx), bgColor, editor);
87+
// TODO: Remove and replace by {@link #LineHighlight(LineID lineID, JavaEditor editor)}
88+
public LineHighlight(int lineIdx, JavaEditor editor) {
89+
this(editor.getLineIDInCurrentTab(lineIdx), editor);
9690
}
9791

9892
/**
@@ -106,18 +100,6 @@ public void setMarker(String marker) {
106100
paint();
107101
}
108102

109-
/**
110-
* Set a text based marker displayed in the left hand gutter area of this
111-
* highlighted line. Also use a custom text color.
112-
*
113-
* @param marker the marker text
114-
* @param markerColor the text color
115-
*/
116-
public void setMarker(String marker, Color markerColor) {
117-
this.markerColor = markerColor;
118-
setMarker(marker);
119-
}
120-
121103
/**
122104
* Retrieve the line id of this {@link LineHighlight}.
123105
*
@@ -127,15 +109,6 @@ public LineID getLineID() {
127109
return lineID;
128110
}
129111

130-
/**
131-
* Retrieve the color for highlighting this line.
132-
*
133-
* @return the highlight color.
134-
*/
135-
public Color getColor() {
136-
return bgColor;
137-
}
138-
139112
/**
140113
* Test if this highlight is on a certain line.
141114
*
@@ -157,7 +130,6 @@ public boolean isOnLine(LineID testLine) {
157130
public void lineChanged(LineID line, int oldLineIdx, int newLineIdx) {
158131
// clear old line
159132
if (editor.isInCurrentTab(new LineID(line.fileName(), oldLineIdx))) {
160-
editor.getJavaTextArea().clearLineBgColor(oldLineIdx);
161133
editor.getJavaTextArea().clearGutterText(oldLineIdx);
162134
}
163135

@@ -184,13 +156,8 @@ public void dispose() {
184156
*/
185157
public void paint() {
186158
if (editor.isInCurrentTab(lineID)) {
187-
editor.getJavaTextArea().setLineBgColor(lineID.lineIdx(), bgColor);
188159
if (marker != null) {
189-
if (markerColor != null) {
190-
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker, markerColor);
191-
} else {
192-
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker);
193-
}
160+
editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker);
194161
}
195162
}
196163
}
@@ -200,7 +167,6 @@ public void paint() {
200167
*/
201168
public void clear() {
202169
if (editor.isInCurrentTab(lineID)) {
203-
editor.getJavaTextArea().clearLineBgColor(lineID.lineIdx());
204170
editor.getJavaTextArea().clearGutterText(lineID.lineIdx());
205171
}
206172
}

java/src/processing/mode/java/pdex/JavaTextArea.java

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,7 @@
5858
public class JavaTextArea extends JEditTextArea {
5959
protected final JavaEditor editor;
6060

61-
62-
// contains line background colors
63-
protected final Map<Integer, Color> lineColors = new HashMap<>();
64-
65-
// [px] space added to the left and right of gutter chars
66-
protected final int gutterPadding; // = 3;
6761
protected Image gutterGradient;
68-
// protected Color gutterBgColor; // = new Color(252, 252, 252); // gutter background color
69-
protected final Color gutterLineColor; // = new Color(233, 233, 233); // color of vertical separation line
7062

7163
/// the text marker for highlighting breakpoints in the gutter
7264
static public final String BREAK_MARKER = "<>";
@@ -76,9 +68,6 @@ public class JavaTextArea extends JEditTextArea {
7668
/// maps line index to gutter text
7769
protected final Map<Integer, String> gutterText = new HashMap<>();
7870

79-
/// maps line index to gutter text color
80-
protected final Map<Integer, Color> gutterTextColors = new HashMap<>();
81-
8271
private CompletionPanel suggestion;
8372

8473

@@ -98,9 +87,6 @@ public JavaTextArea(TextAreaDefaults defaults, JavaEditor editor) {
9887
// load settings from theme.txt
9988
Mode mode = editor.getMode();
10089
gutterGradient = mode.makeGradient("editor", Editor.LEFT_GUTTER, 500);
101-
//gutterBgColor = mode.getColor("editor.gutter.bgcolor");
102-
gutterLineColor = mode.getColor("editor.gutter.linecolor");
103-
gutterPadding = mode.getInteger("editor.gutter.padding");
10490

10591
// TweakMode code
10692
prevCompListeners = painter.getComponentListeners();
@@ -655,22 +641,6 @@ public void setGutterText(int lineIdx, String text) {
655641
}
656642

657643

658-
/**
659-
* Set the gutter text and color of a specific line.
660-
*
661-
* @param lineIdx
662-
* the line index (0-based)
663-
* @param text
664-
* the text
665-
* @param textColor
666-
* the text color
667-
*/
668-
public void setGutterText(int lineIdx, String text, Color textColor) {
669-
gutterTextColors.put(lineIdx, textColor);
670-
setGutterText(lineIdx, text);
671-
}
672-
673-
674644
/**
675645
* Clear the gutter text of a specific line.
676646
*
@@ -706,67 +676,6 @@ public String getGutterText(int lineIdx) {
706676
}
707677

708678

709-
/**
710-
* Retrieve the gutter text color for a specific line.
711-
*
712-
* @param lineIdx
713-
* the line index
714-
* @return the gutter text color
715-
*/
716-
public Color getGutterTextColor(int lineIdx) {
717-
return gutterTextColors.get(lineIdx);
718-
}
719-
720-
721-
/**
722-
* Set the background color of a line.
723-
*
724-
* @param lineIdx
725-
* 0-based line number
726-
* @param col
727-
* the background color to set
728-
*/
729-
public void setLineBgColor(int lineIdx, Color col) {
730-
lineColors.put(lineIdx, col);
731-
painter.invalidateLine(lineIdx);
732-
}
733-
734-
735-
/**
736-
* Clear the background color of a line.
737-
*
738-
* @param lineIdx
739-
* 0-based line number
740-
*/
741-
public void clearLineBgColor(int lineIdx) {
742-
lineColors.remove(lineIdx);
743-
painter.invalidateLine(lineIdx);
744-
}
745-
746-
747-
/**
748-
* Clear all line background colors.
749-
*/
750-
public void clearLineBgColors() {
751-
for (int lineIdx : lineColors.keySet()) {
752-
painter.invalidateLine(lineIdx);
753-
}
754-
lineColors.clear();
755-
}
756-
757-
758-
/**
759-
* Get a lines background color.
760-
*
761-
* @param lineIdx
762-
* 0-based line number
763-
* @return the color or null if no color was set for the specified line
764-
*/
765-
public Color getLineBgColor(int lineIdx) {
766-
return lineColors.get(lineIdx);
767-
}
768-
769-
770679
/**
771680
* Convert a character offset to a horizontal pixel position inside the text
772681
* area. Overridden to take gutter width into account.

0 commit comments

Comments
 (0)