implement breakpoint diamond and step arrow (fixes #3307)

This commit is contained in:
Ben Fry
2015-09-24 05:51:14 -04:00
parent 209ea9000a
commit 48d013becf
5 changed files with 73 additions and 36 deletions
+4 -4
View File
@@ -114,12 +114,12 @@ editor.gutter.text.font = processing.mono,plain,11
editor.gutter.text.color = #bbd6d5
# marker for breakpointed lines in left hand gutter (2 ascii characters)
editor.gutter.breakpoint.marker = <>
editor.gutter.breakpoint.marker.color = #4a545e
#editor.gutter.breakpoint.marker = <>
#editor.gutter.breakpoint.marker.color = #4a545e
# marker for the current line in left hand gutter (2 ascii characters)
editor.gutter.currentline.marker = ->
editor.gutter.currentline.marker.color = #e27500
#editor.gutter.currentline.marker = ->
#editor.gutter.currentline.marker.color = #e27500
# bgcolor for the current (highlighted) line
editor.gutter.linehighlight.color=#587478
@@ -50,8 +50,9 @@ public class JavaEditor extends Editor {
// Runner associated with this editor window
private Runner runtime;
// Need to sort through the rest of these additions...
// 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;
@@ -122,11 +123,11 @@ public class JavaEditor extends Editor {
Toolkit.setMenuMnemonics(textarea.getRightClickPopup());
// load settings from theme.txt
breakpointColor = mode.getColor("breakpoint.bgcolor");
breakpointMarkerColor = mode.getColor("breakpoint.marker.color");
currentLineColor = mode.getColor("currentline.bgcolor");
currentLineMarkerColor = mode.getColor("currentline.marker.color");
// // load settings from theme.txt
// breakpointColor = mode.getColor("breakpoint.bgcolor");
// breakpointMarkerColor = mode.getColor("breakpoint.marker.color");
// currentLineColor = mode.getColor("currentline.bgcolor");
// currentLineMarkerColor = mode.getColor("currentline.marker.color");
// set breakpoints from marker comments
for (LineID lineID : stripBreakpointComments()) {
@@ -2189,7 +2190,7 @@ public class JavaEditor extends Editor {
cursorToLineStart(line.lineIdx());
// highlight line
currentLine = new LineHighlight(line.lineIdx(), currentLineColor, this);
currentLine.setMarker(getJavaTextArea().currentLineMarker, currentLineMarkerColor);
currentLine.setMarker(JavaTextArea.STEP_MARKER, currentLineMarkerColor);
currentLine.setPriority(10); // fixes current line being hidden by the breakpoint when moved down
}
@@ -2218,7 +2219,7 @@ public class JavaEditor extends Editor {
*/
public void addBreakpointedLine(LineID lineID) {
LineHighlight hl = new LineHighlight(lineID, breakpointColor, this);
hl.setMarker(getJavaTextArea().breakpointMarker, breakpointMarkerColor);
hl.setMarker(JavaTextArea.BREAK_MARKER, breakpointMarkerColor);
breakpointedLines.add(hl);
// repaint current line if it's on this line
if (currentLine != null && currentLine.getLineID().equals(lineID)) {
@@ -72,9 +72,9 @@ public class JavaTextArea extends JEditTextArea {
protected Color gutterLineColor; // = new Color(233, 233, 233); // color of vertical separation line
/// the text marker for highlighting breakpoints in the gutter
public String breakpointMarker = "<>";
static public final String BREAK_MARKER = "<>";
/// the text marker for highlighting the current line in the gutter
public String currentLineMarker = "->";
static public final String STEP_MARKER = "->";
/// maps line index to gutter text
protected Map<Integer, String> gutterText = new HashMap<Integer, String>();
@@ -129,9 +129,9 @@ public class JavaTextArea extends JEditTextArea {
gutterBgColor = mode.getColor("editor.gutter.bgcolor"); //, gutterBgColor);
gutterLineColor = mode.getColor("editor.gutter.linecolor"); //, gutterLineColor);
gutterPadding = mode.getInteger("editor.gutter.padding");
breakpointMarker = mode.getString("editor.gutter.breakpoint.marker"); //, breakpointMarker);
// breakpointMarker = mode.getString("editor.gutter.breakpoint.marker"); //, breakpointMarker);
// breakpointMarker = "\u2666";
currentLineMarker = mode.getString("editor.gutter.currentline.marker"); //, currentLineMarker);
// currentLineMarker = mode.getString("editor.gutter.currentline.marker"); //, currentLineMarker);
// TweakMode code
prevCompListeners = painter.getComponentListeners();
@@ -38,6 +38,7 @@ import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.GeneralPath;
import java.awt.image.BufferedImage;
import java.util.List;
@@ -268,24 +269,56 @@ public class JavaTextAreaPainter extends TextAreaPainter
if (getJavaEditor().isDebuggerEnabled()) {
text = getTextArea().getGutterText(line);
}
// if no special text for a breakpoint, just show the line number
if (text == null) {
gfx.setColor(gutterTextColor);
int textRight = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN;
int textBaseline = textArea.lineToY(line) + fm.getHeight();
if (text != null) {
if (text.equals(JavaTextArea.BREAK_MARKER)) {
drawDiamond(gfx, textRight - 8, textBaseline - 8, 8, 8);
} else if (text.equals(JavaTextArea.STEP_MARKER)) {
//drawRightArrow(gfx, textRight - 7, textBaseline - 7, 7, 6);
drawRightArrow(gfx, textRight - 7, textBaseline - 7.5f, 7, 7);
}
} else {
// if no special text for a breakpoint, just show the line number
text = String.valueOf(line + 1);
//text = makeOSF(String.valueOf(line + 1));
}
char[] txt = text.toCharArray();
//gfx.setFont(getFont());
gfx.setFont(gutterTextFont);
// Right-align the text
int tx = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN -
gfx.getFontMetrics().charsWidth(txt, 0, txt.length);
gfx.setColor(gutterTextColor);
// Using 'fm' here because it's relative to the editor text size,
// not the numbers in the gutter
int ty = textArea.lineToY(line) + fm.getHeight();
Utilities.drawTabbedText(new Segment(txt, 0, text.length()),
tx, ty, gfx, this, 0);
gfx.setFont(gutterTextFont);
// Right-align the text
char[] txt = text.toCharArray();
int tx = textRight - gfx.getFontMetrics().charsWidth(txt, 0, txt.length);
// Using 'fm' here because it's relative to the editor text size,
// not the numbers in the gutter
Utilities.drawTabbedText(new Segment(txt, 0, text.length()),
tx, textBaseline, gfx, this, 0);
}
}
private void drawDiamond(Graphics g, float x, float y, float w, float h) {
Graphics2D g2 = (Graphics2D) g;
GeneralPath path = new GeneralPath();
path.moveTo(x + w/2, y);
path.lineTo(x + w, y + h/2);
path.lineTo(x + w/2, y + h);
path.lineTo(x, y + h/2);
path.closePath();
g2.fill(path);
}
private void drawRightArrow(Graphics g, float x, float y, float w, float h) {
Graphics2D g2 = (Graphics2D) g;
GeneralPath path = new GeneralPath();
path.moveTo(x, y);
path.lineTo(x + w, y + h/2);
path.lineTo(x, y + h);
path.closePath();
g2.fill(path);
}
+8 -5
View File
@@ -1,4 +1,8 @@
0246 the holy land
X distinguish errors and warnings
X https://github.com/processing/processing/issues/3406
X make breakpoints more prominent
X https://github.com/processing/processing/issues/3307 (comp is set)
_ does the "Saving" message never clear on "Save As"?
_ probably a regression from the "save as" code
@@ -20,7 +24,10 @@ _ new Android release (EditorButton constructor changed)
3.0 final
_ https://github.com/processing/processing/milestones/3.0%20final
_ clean up statusMessage() inside JavaEditor
X clean up statusMessage() inside JavaEditor
_ do we want to bring back the delays?
_ JavaEditor has several null colors, remove color support
_ once the design is complete and we for sure do not need color
gui / James
@@ -28,10 +35,6 @@ _ Fix placement and visual design when showing error on hover
_ https://github.com/processing/processing/issues/3173
_ import suggestions box needs design review
_ https://github.com/processing/processing/issues/3407
_ distinguish errors and warnings
_ https://github.com/processing/processing/issues/3406
_ make breakpoints more prominent
_ https://github.com/processing/processing/issues/3307 (comp is set)
_ replace startup/about screen (1x and 2x versions)
_ change 'alpha' to correct name
_ also change the revision in the "about processing" dialog