Skip to content

Commit 69db733

Browse files
committed
single click for breakpoint
1 parent 1f3ab67 commit 69db733

File tree

5 files changed

+73
-39
lines changed

5 files changed

+73
-39
lines changed

java/src/processing/mode/java/Debugger.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -470,22 +470,16 @@ LineBreakpoint breakpointOnLine(LineID line) {
470470
}
471471

472472

473-
/** Toggle a breakpoint on the current line. */
474-
synchronized void toggleBreakpoint() {
475-
toggleBreakpoint(editor.getCurrentLineID().lineIdx());
476-
}
477-
478-
479473
/**
480474
* Toggle a breakpoint on a line in the current tab.
481475
* @param lineIdx the line index (0-based) in the current tab
482476
*/
483477
synchronized void toggleBreakpoint(int lineIdx) {
484478
LineID line = editor.getLineIDInCurrentTab(lineIdx);
485-
if (!hasBreakpoint(line)) {
486-
setBreakpoint(line.lineIdx());
487-
} else {
479+
if (hasBreakpoint(line)) {
488480
removeBreakpoint(line.lineIdx());
481+
} else {
482+
setBreakpoint(line.lineIdx());
489483
}
490484
}
491485

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,6 +1202,19 @@ public void handleContinue() {
12021202
}
12031203

12041204

1205+
/** Toggle a breakpoint on the current line. */
1206+
public void toggleBreakpoint() {
1207+
debugger.toggleBreakpoint(getCurrentLineID().lineIdx());
1208+
}
1209+
1210+
1211+
public void toggleBreakpoint(int lineIndex) {
1212+
new Exception().printStackTrace(System.out);
1213+
debugger.toggleBreakpoint(lineIndex);
1214+
}
1215+
1216+
1217+
12051218
/*
12061219
public void handleSave() {
12071220
// toolbar.activate(JavaToolbar.SAVE);
@@ -1516,7 +1529,7 @@ public void actionPerformed(ActionEvent e) {
15161529
item.addActionListener(new ActionListener() {
15171530
public void actionPerformed(ActionEvent e) {
15181531
Logger.getLogger(JavaEditor.class.getName()).log(Level.INFO, "Invoked 'Toggle Breakpoint' menu item");
1519-
debugger.toggleBreakpoint();
1532+
toggleBreakpoint();
15201533
}
15211534
});
15221535
debugMenu.add(item);
@@ -2477,15 +2490,15 @@ public Document currentDocument() {
24772490
}
24782491

24792492

2480-
/**
2481-
* Event Handler for double clicking in the left hand gutter area.
2482-
* @param lineIdx the line (0-based) that was double clicked
2483-
*/
2484-
public void gutterDblClicked(int lineIdx) {
2485-
if (debugger != null) {
2486-
debugger.toggleBreakpoint(lineIdx);
2487-
}
2488-
}
2493+
// /**
2494+
// * Event Handler for double clicking in the left hand gutter area.
2495+
// * @param lineIdx the line (0-based) that was double clicked
2496+
// */
2497+
// public void gutterDblClicked(int lineIdx) {
2498+
// if (debugger != null) {
2499+
// debugger.toggleBreakpoint(lineIdx);
2500+
// }
2501+
// }
24892502

24902503

24912504
public void statusBusy() {

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,22 @@ public void mouseClicked(MouseEvent me) {
719719

720720
@Override
721721
public void mousePressed(MouseEvent me) {
722-
// check if this happened in the gutter area
723-
if (me.getX() < Editor.LEFT_GUTTER) {
724-
if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 2) {
725-
int line = me.getY() / painter.getFontMetrics().getHeight()
726-
+ firstLine;
727-
if (line >= 0 && line <= getLineCount() - 1) {
728-
editor.gutterDblClicked(line);
729-
}
730-
}
731-
return;
732-
}
722+
// // check if this happened in the gutter area
723+
// if (me.getX() < Editor.LEFT_GUTTER) {
724+
// if (me.getButton() == MouseEvent.BUTTON1) { // && me.getClickCount() == 2) {
725+
// //int line = me.getY() / painter.getFontMetrics().getHeight() + firstLine;
726+
// int offset = xyToOffset(me.getX(), me.getY());
727+
// if (offset >= 0) {
728+
// int lineIndex = getLineOfOffset(offset);
729+
// editor.toggleBreakpoint(lineIndex);
730+
// }
731+
//// if (line >= 0 && line < getLineCount()) {
732+
//// //editor.gutterDblClicked(line);
733+
//// editor.toggleBreakpoint(line);
734+
//// }
735+
// }
736+
// return;
737+
// }
733738

734739
if (me.getButton() == MouseEvent.BUTTON3) {
735740
if (!editor.hasJavaTabs()) { // tooltips, etc disabled for java tabs

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public ErrorLineCoord(int xStart, int xEnd, int yStart, int yEnd, Problem proble
100100

101101
public JavaTextAreaPainter(JavaTextArea textArea, TextAreaDefaults defaults) {
102102
super(textArea, defaults);
103+
new Exception().printStackTrace(System.out);
103104

104105
addMouseListener(new MouseAdapter() {
105106
public void mouseClicked(MouseEvent evt) {
@@ -113,18 +114,37 @@ public void mouseClicked(MouseEvent evt) {
113114
}
114115
});
115116

117+
// Handle mouse clicks to toggle breakpoints
118+
addMouseListener(new MouseAdapter() {
119+
long lastTime; // OS X seems to be firing multiple mouse events
120+
121+
public void mousePressed(MouseEvent event) {
122+
long thisTime = event.getWhen();
123+
if (thisTime - lastTime > 100) {
124+
if (event.getX() < Editor.LEFT_GUTTER) {
125+
int offset = getTextArea().xyToOffset(event.getX(), event.getY());
126+
if (offset >= 0) {
127+
int lineIndex = getTextArea().getLineOfOffset(offset);
128+
getEditor().toggleBreakpoint(lineIndex);
129+
}
130+
}
131+
lastTime = thisTime;
132+
}
133+
}
134+
});
135+
116136
addMouseMotionListener(new MouseMotionAdapter() {
117137
@Override
118138
public void mouseMoved(final MouseEvent evt) {
119-
for (ErrorLineCoord coord : errorLineCoords) {
120-
if (evt.getX() >= coord.xStart && evt.getX() <= coord.xEnd
121-
&& evt.getY() >= coord.yStart && evt.getY() <= coord.yEnd + 2) {
122-
setToolTipText(coord.problem.getMessage());
123-
break;
124-
}
125-
}
139+
for (ErrorLineCoord coord : errorLineCoords) {
140+
if (evt.getX() >= coord.xStart && evt.getX() <= coord.xEnd &&
141+
evt.getY() >= coord.yStart && evt.getY() <= coord.yEnd + 2) {
142+
setToolTipText(coord.problem.getMessage());
143+
break;
144+
}
145+
}
126146
}
127-
});
147+
});
128148

129149
// TweakMode code
130150
interactiveMode = false;

todo.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ o name isn't tied to its function, but the symptom
3434
X update hasJavaTabs on editor header rebuild
3535
X remove focus border from the Variables window
3636
X need active state for the butterfly
37+
X click a line number to toggle breakpoint
38+
X was in there before, but required double-click
3739

3840
in alpha 8 (but not confirmed in time)
3941
X "step" not working properly
@@ -43,13 +45,13 @@ X https://github.com/processing/processing/issues/3242
4345

4446

4547
gui
46-
_ click a line number to toggle breakpoint
4748
_ finish the gui
4849
_ https://github.com/processing/processing/issues/3072
4950
_ add a "what's new" window to explain features in 3
5051

5152

5253
gui (lower, not blocking for beta)
54+
_ tiny trail of dots when moving the selection bar up/down on retina
5355
_ need 'actively pressed' version of 'play' and 'stop'
5456
_ could do rollover as well, but do other apps use them?
5557
_ iTunes has no rollover state but has a 'down' state

0 commit comments

Comments
 (0)