Skip to content

Commit 2361ce0

Browse files
committed
implement breakpoint diamond and step arrow (fixes processing#3307)
1 parent a89a06e commit 2361ce0

5 files changed

Lines changed: 72 additions & 35 deletions

File tree

build/shared/lib/theme.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ editor.gutter.text.font = processing.mono,plain,11
114114
editor.gutter.text.color = #bbd6d5
115115

116116
# marker for breakpointed lines in left hand gutter (2 ascii characters)
117-
editor.gutter.breakpoint.marker = <>
118-
editor.gutter.breakpoint.marker.color = #4a545e
117+
#editor.gutter.breakpoint.marker = <>
118+
#editor.gutter.breakpoint.marker.color = #4a545e
119119

120120
# marker for the current line in left hand gutter (2 ascii characters)
121-
editor.gutter.currentline.marker = ->
122-
editor.gutter.currentline.marker.color = #e27500
121+
#editor.gutter.currentline.marker = ->
122+
#editor.gutter.currentline.marker.color = #e27500
123123

124124
# bgcolor for the current (highlighted) line
125125
editor.gutter.linehighlight.color=#587478

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ public class JavaEditor extends Editor {
5050
// Runner associated with this editor window
5151
private Runner runtime;
5252

53-
// Need to sort through the rest of these additions...
53+
// Need to sort through the rest of these additions [fry]
5454

55+
// TODO these are all null, need to remove color support
5556
protected Color breakpointColor;
5657
protected Color currentLineColor;
5758
protected Color breakpointMarkerColor;
@@ -122,11 +123,11 @@ public void actionPerformed(ActionEvent e) {
122123

123124
Toolkit.setMenuMnemonics(textarea.getRightClickPopup());
124125

125-
// load settings from theme.txt
126-
breakpointColor = mode.getColor("breakpoint.bgcolor");
127-
breakpointMarkerColor = mode.getColor("breakpoint.marker.color");
128-
currentLineColor = mode.getColor("currentline.bgcolor");
129-
currentLineMarkerColor = mode.getColor("currentline.marker.color");
126+
// // load settings from theme.txt
127+
// breakpointColor = mode.getColor("breakpoint.bgcolor");
128+
// breakpointMarkerColor = mode.getColor("breakpoint.marker.color");
129+
// currentLineColor = mode.getColor("currentline.bgcolor");
130+
// currentLineMarkerColor = mode.getColor("currentline.marker.color");
130131

131132
// set breakpoints from marker comments
132133
for (LineID lineID : stripBreakpointComments()) {
@@ -2189,7 +2190,7 @@ public void setCurrentLine(LineID line) {
21892190
cursorToLineStart(line.lineIdx());
21902191
// highlight line
21912192
currentLine = new LineHighlight(line.lineIdx(), currentLineColor, this);
2192-
currentLine.setMarker(getJavaTextArea().currentLineMarker, currentLineMarkerColor);
2193+
currentLine.setMarker(JavaTextArea.STEP_MARKER, currentLineMarkerColor);
21932194
currentLine.setPriority(10); // fixes current line being hidden by the breakpoint when moved down
21942195
}
21952196

@@ -2218,7 +2219,7 @@ public void clearCurrentLine() {
22182219
*/
22192220
public void addBreakpointedLine(LineID lineID) {
22202221
LineHighlight hl = new LineHighlight(lineID, breakpointColor, this);
2221-
hl.setMarker(getJavaTextArea().breakpointMarker, breakpointMarkerColor);
2222+
hl.setMarker(JavaTextArea.BREAK_MARKER, breakpointMarkerColor);
22222223
breakpointedLines.add(hl);
22232224
// repaint current line if it's on this line
22242225
if (currentLine != null && currentLine.getLineID().equals(lineID)) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ public class JavaTextArea extends JEditTextArea {
7272
protected Color gutterLineColor; // = new Color(233, 233, 233); // color of vertical separation line
7373

7474
/// the text marker for highlighting breakpoints in the gutter
75-
public String breakpointMarker = "<>";
75+
static public final String BREAK_MARKER = "<>";
7676
/// the text marker for highlighting the current line in the gutter
77-
public String currentLineMarker = "->";
77+
static public final String STEP_MARKER = "->";
7878

7979
/// maps line index to gutter text
8080
protected Map<Integer, String> gutterText = new HashMap<Integer, String>();
@@ -129,9 +129,9 @@ public JavaTextArea(TextAreaDefaults defaults, JavaEditor editor) {
129129
gutterBgColor = mode.getColor("editor.gutter.bgcolor"); //, gutterBgColor);
130130
gutterLineColor = mode.getColor("editor.gutter.linecolor"); //, gutterLineColor);
131131
gutterPadding = mode.getInteger("editor.gutter.padding");
132-
breakpointMarker = mode.getString("editor.gutter.breakpoint.marker"); //, breakpointMarker);
132+
// breakpointMarker = mode.getString("editor.gutter.breakpoint.marker"); //, breakpointMarker);
133133
// breakpointMarker = "\u2666";
134-
currentLineMarker = mode.getString("editor.gutter.currentline.marker"); //, currentLineMarker);
134+
// currentLineMarker = mode.getString("editor.gutter.currentline.marker"); //, currentLineMarker);
135135

136136
// TweakMode code
137137
prevCompListeners = painter.getComponentListeners();

java/src/processing/mode/java/pdex/JavaTextAreaPainter.java

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.awt.event.MouseMotionListener;
3939
import java.awt.event.WindowAdapter;
4040
import java.awt.event.WindowEvent;
41+
import java.awt.geom.GeneralPath;
4142
import java.awt.image.BufferedImage;
4243
import java.util.List;
4344

@@ -268,24 +269,56 @@ protected void paintLeftGutter(Graphics gfx, int line, int x) {
268269
if (getJavaEditor().isDebuggerEnabled()) {
269270
text = getTextArea().getGutterText(line);
270271
}
271-
// if no special text for a breakpoint, just show the line number
272-
if (text == null) {
272+
273+
gfx.setColor(gutterTextColor);
274+
int textRight = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN;
275+
int textBaseline = textArea.lineToY(line) + fm.getHeight();
276+
277+
if (text != null) {
278+
if (text.equals(JavaTextArea.BREAK_MARKER)) {
279+
drawDiamond(gfx, textRight - 8, textBaseline - 8, 8, 8);
280+
281+
} else if (text.equals(JavaTextArea.STEP_MARKER)) {
282+
//drawRightArrow(gfx, textRight - 7, textBaseline - 7, 7, 6);
283+
drawRightArrow(gfx, textRight - 7, textBaseline - 7.5f, 7, 7);
284+
}
285+
} else {
286+
// if no special text for a breakpoint, just show the line number
273287
text = String.valueOf(line + 1);
274288
//text = makeOSF(String.valueOf(line + 1));
289+
290+
gfx.setFont(gutterTextFont);
291+
// Right-align the text
292+
char[] txt = text.toCharArray();
293+
int tx = textRight - gfx.getFontMetrics().charsWidth(txt, 0, txt.length);
294+
// Using 'fm' here because it's relative to the editor text size,
295+
// not the numbers in the gutter
296+
Utilities.drawTabbedText(new Segment(txt, 0, text.length()),
297+
tx, textBaseline, gfx, this, 0);
275298
}
276-
char[] txt = text.toCharArray();
299+
}
277300

278-
//gfx.setFont(getFont());
279-
gfx.setFont(gutterTextFont);
280-
// Right-align the text
281-
int tx = Editor.LEFT_GUTTER - Editor.GUTTER_MARGIN -
282-
gfx.getFontMetrics().charsWidth(txt, 0, txt.length);
283-
gfx.setColor(gutterTextColor);
284-
// Using 'fm' here because it's relative to the editor text size,
285-
// not the numbers in the gutter
286-
int ty = textArea.lineToY(line) + fm.getHeight();
287-
Utilities.drawTabbedText(new Segment(txt, 0, text.length()),
288-
tx, ty, gfx, this, 0);
301+
302+
private void drawDiamond(Graphics g, float x, float y, float w, float h) {
303+
Graphics2D g2 = (Graphics2D) g;
304+
GeneralPath path = new GeneralPath();
305+
path.moveTo(x + w/2, y);
306+
path.lineTo(x + w, y + h/2);
307+
path.lineTo(x + w/2, y + h);
308+
path.lineTo(x, y + h/2);
309+
path.closePath();
310+
g2.fill(path);
311+
}
312+
313+
314+
private void drawRightArrow(Graphics g, float x, float y, float w, float h) {
315+
Graphics2D g2 = (Graphics2D) g;
316+
GeneralPath path = new GeneralPath();
317+
path.moveTo(x, y);
318+
path.lineTo(x + w, y + h/2);
319+
path.lineTo(x, y + h);
320+
path.closePath();
321+
g2.fill(path);
289322
}
290323

291324

todo.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
0246 the holy land
2+
X distinguish errors and warnings
3+
X https://github.com/processing/processing/issues/3406
4+
X make breakpoints more prominent
5+
X https://github.com/processing/processing/issues/3307 (comp is set)
26
_ does the "Saving" message never clear on "Save As"?
37
_ probably a regression from the "save as" code
48

@@ -20,18 +24,17 @@ _ new Android release (EditorButton constructor changed)
2024

2125
3.0 final
2226
_ https://github.com/processing/processing/milestones/3.0%20final
23-
_ clean up statusMessage() inside JavaEditor
27+
X clean up statusMessage() inside JavaEditor
28+
_ do we want to bring back the delays?
29+
_ JavaEditor has several null colors, remove color support
30+
_ once the design is complete and we for sure do not need color
2431

2532

2633
gui / James
2734
_ Fix placement and visual design when showing error on hover
2835
_ https://github.com/processing/processing/issues/3173
2936
_ import suggestions box needs design review
3037
_ https://github.com/processing/processing/issues/3407
31-
_ distinguish errors and warnings
32-
_ https://github.com/processing/processing/issues/3406
33-
_ make breakpoints more prominent
34-
_ https://github.com/processing/processing/issues/3307 (comp is set)
3538
_ replace startup/about screen (1x and 2x versions)
3639
_ change 'alpha' to correct name
3740
_ also change the revision in the "about processing" dialog

0 commit comments

Comments
 (0)