diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index 38af50642..331c9b166 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -49,12 +49,6 @@ public class JavaEditor extends Editor { // Need to sort through the rest of these additions [fry] - // TODO these are all null, need to remove color support - protected Color breakpointColor; - protected Color currentLineColor; - protected Color breakpointMarkerColor; - protected Color currentLineMarkerColor; - protected List breakpointedLines = new ArrayList(); protected LineHighlight currentLine; // where the debugger is suspended @@ -2213,8 +2207,8 @@ public class JavaEditor extends Editor { // scroll to line, by setting the cursor cursorToLineStart(line.lineIdx()); // highlight line - currentLine = new LineHighlight(line.lineIdx(), currentLineColor, this); - currentLine.setMarker(JavaTextArea.STEP_MARKER, currentLineMarkerColor); + currentLine = new LineHighlight(line.lineIdx(), this); + currentLine.setMarker(JavaTextArea.STEP_MARKER); currentLine.setPriority(10); // fixes current line being hidden by the breakpoint when moved down } @@ -2242,8 +2236,8 @@ public class JavaEditor extends Editor { * @param lineID the line id to highlight as breakpointed */ public void addBreakpointedLine(LineID lineID) { - LineHighlight hl = new LineHighlight(lineID, breakpointColor, this); - hl.setMarker(JavaTextArea.BREAK_MARKER, breakpointMarkerColor); + LineHighlight hl = new LineHighlight(lineID, this); + hl.setMarker(JavaTextArea.BREAK_MARKER); breakpointedLines.add(hl); // repaint current line if it's on this line if (currentLine != null && currentLine.getLineID().equals(lineID)) { @@ -2299,7 +2293,6 @@ public class JavaEditor extends Editor { breakpointedLines.clear(); // remove all breakpoints // fix highlights not being removed when tab names have // changed due to opening a new sketch in same editor - getJavaTextArea().clearLineBgColors(); // force clear all highlights getJavaTextArea().clearGutterText(); // repaint current line @@ -2364,11 +2357,8 @@ public class JavaEditor extends Editor { final JavaTextArea ta = getJavaTextArea(); // can be null when setCode is called the first time (in constructor) if (ta != null) { - // clear all line backgrounds - ta.clearLineBgColors(); // clear all gutter text ta.clearGutterText(); - // load appropriate line backgrounds for tab // first paint breakpoints if (breakpointedLines != null) { for (LineHighlight hl : breakpointedLines) { diff --git a/java/src/processing/mode/java/debug/LineHighlight.java b/java/src/processing/mode/java/debug/LineHighlight.java index 13ad3bfbc..789d4ba96 100644 --- a/java/src/processing/mode/java/debug/LineHighlight.java +++ b/java/src/processing/mode/java/debug/LineHighlight.java @@ -20,7 +20,6 @@ along with this program; if not, write to the Free Software Foundation, Inc. package processing.mode.java.debug; -import java.awt.Color; import java.util.HashSet; import java.util.Set; @@ -35,25 +34,21 @@ import processing.mode.java.JavaEditor; */ public class LineHighlight { - protected JavaEditor editor; // the view, used for highlighting lines by setting a background color - protected Color bgColor; // the background color for highlighting lines - protected LineID lineID; // the id of the line + protected final JavaEditor editor; // the view, used for highlighting lines by setting a background color + protected final LineID lineID; // the id of the line protected String marker; // - protected Color markerColor; protected int priority = 0; - protected static Set allHighlights = new HashSet(); + protected static final Set allHighlights = new HashSet<>(); /** * Create a {@link LineHighlight}. * * @param lineID the line id to highlight - * @param bgColor the background color used for highlighting * @param editor the {@link JavaEditor} */ - public LineHighlight(LineID lineID, Color bgColor, JavaEditor editor) { + public LineHighlight(LineID lineID, JavaEditor editor) { this.lineID = lineID; - this.bgColor = bgColor; this.editor = editor; lineID.addListener(this); lineID.startTracking(editor.getTab(lineID.fileName()).getDocument()); // TODO: overwrite a previous doc? @@ -87,12 +82,11 @@ public class LineHighlight { * Create a {@link LineHighlight} on the current tab. * * @param lineIdx the line index on the current tab to highlight - * @param bgColor the background color used for highlighting * @param editor the {@link JavaEditor} */ - // TODO: Remove and replace by {@link #LineHighlight(LineID lineID, Color bgColor, JavaEditor editor)} - public LineHighlight(int lineIdx, Color bgColor, JavaEditor editor) { - this(editor.getLineIDInCurrentTab(lineIdx), bgColor, editor); + // TODO: Remove and replace by {@link #LineHighlight(LineID lineID, JavaEditor editor)} + public LineHighlight(int lineIdx, JavaEditor editor) { + this(editor.getLineIDInCurrentTab(lineIdx), editor); } /** @@ -106,18 +100,6 @@ public class LineHighlight { paint(); } - /** - * Set a text based marker displayed in the left hand gutter area of this - * highlighted line. Also use a custom text color. - * - * @param marker the marker text - * @param markerColor the text color - */ - public void setMarker(String marker, Color markerColor) { - this.markerColor = markerColor; - setMarker(marker); - } - /** * Retrieve the line id of this {@link LineHighlight}. * @@ -127,15 +109,6 @@ public class LineHighlight { return lineID; } - /** - * Retrieve the color for highlighting this line. - * - * @return the highlight color. - */ - public Color getColor() { - return bgColor; - } - /** * Test if this highlight is on a certain line. * @@ -157,7 +130,6 @@ public class LineHighlight { public void lineChanged(LineID line, int oldLineIdx, int newLineIdx) { // clear old line if (editor.isInCurrentTab(new LineID(line.fileName(), oldLineIdx))) { - editor.getJavaTextArea().clearLineBgColor(oldLineIdx); editor.getJavaTextArea().clearGutterText(oldLineIdx); } @@ -184,13 +156,8 @@ public class LineHighlight { */ public void paint() { if (editor.isInCurrentTab(lineID)) { - editor.getJavaTextArea().setLineBgColor(lineID.lineIdx(), bgColor); if (marker != null) { - if (markerColor != null) { - editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker, markerColor); - } else { - editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker); - } + editor.getJavaTextArea().setGutterText(lineID.lineIdx(), marker); } } } @@ -200,7 +167,6 @@ public class LineHighlight { */ public void clear() { if (editor.isInCurrentTab(lineID)) { - editor.getJavaTextArea().clearLineBgColor(lineID.lineIdx()); editor.getJavaTextArea().clearGutterText(lineID.lineIdx()); } } diff --git a/java/src/processing/mode/java/pdex/JavaTextArea.java b/java/src/processing/mode/java/pdex/JavaTextArea.java index c31097139..287042541 100644 --- a/java/src/processing/mode/java/pdex/JavaTextArea.java +++ b/java/src/processing/mode/java/pdex/JavaTextArea.java @@ -58,15 +58,7 @@ import processing.app.ui.Editor; public class JavaTextArea extends JEditTextArea { protected final JavaEditor editor; - - // contains line background colors - protected final Map lineColors = new HashMap<>(); - - // [px] space added to the left and right of gutter chars - protected final int gutterPadding; // = 3; protected Image gutterGradient; -// protected Color gutterBgColor; // = new Color(252, 252, 252); // gutter background color - protected final Color gutterLineColor; // = new Color(233, 233, 233); // color of vertical separation line /// the text marker for highlighting breakpoints in the gutter static public final String BREAK_MARKER = "<>"; @@ -76,9 +68,6 @@ public class JavaTextArea extends JEditTextArea { /// maps line index to gutter text protected final Map gutterText = new HashMap<>(); - /// maps line index to gutter text color - protected final Map gutterTextColors = new HashMap<>(); - private CompletionPanel suggestion; @@ -98,9 +87,6 @@ public class JavaTextArea extends JEditTextArea { // load settings from theme.txt Mode mode = editor.getMode(); gutterGradient = mode.makeGradient("editor", Editor.LEFT_GUTTER, 500); - //gutterBgColor = mode.getColor("editor.gutter.bgcolor"); - gutterLineColor = mode.getColor("editor.gutter.linecolor"); - gutterPadding = mode.getInteger("editor.gutter.padding"); // TweakMode code prevCompListeners = painter.getComponentListeners(); @@ -655,22 +641,6 @@ public class JavaTextArea extends JEditTextArea { } - /** - * Set the gutter text and color of a specific line. - * - * @param lineIdx - * the line index (0-based) - * @param text - * the text - * @param textColor - * the text color - */ - public void setGutterText(int lineIdx, String text, Color textColor) { - gutterTextColors.put(lineIdx, textColor); - setGutterText(lineIdx, text); - } - - /** * Clear the gutter text of a specific line. * @@ -706,67 +676,6 @@ public class JavaTextArea extends JEditTextArea { } - /** - * Retrieve the gutter text color for a specific line. - * - * @param lineIdx - * the line index - * @return the gutter text color - */ - public Color getGutterTextColor(int lineIdx) { - return gutterTextColors.get(lineIdx); - } - - - /** - * Set the background color of a line. - * - * @param lineIdx - * 0-based line number - * @param col - * the background color to set - */ - public void setLineBgColor(int lineIdx, Color col) { - lineColors.put(lineIdx, col); - painter.invalidateLine(lineIdx); - } - - - /** - * Clear the background color of a line. - * - * @param lineIdx - * 0-based line number - */ - public void clearLineBgColor(int lineIdx) { - lineColors.remove(lineIdx); - painter.invalidateLine(lineIdx); - } - - - /** - * Clear all line background colors. - */ - public void clearLineBgColors() { - for (int lineIdx : lineColors.keySet()) { - painter.invalidateLine(lineIdx); - } - lineColors.clear(); - } - - - /** - * Get a lines background color. - * - * @param lineIdx - * 0-based line number - * @return the color or null if no color was set for the specified line - */ - public Color getLineBgColor(int lineIdx) { - return lineColors.get(lineIdx); - } - - /** * Convert a character offset to a horizontal pixel position inside the text * area. Overridden to take gutter width into account.