mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 11:21:06 +01:00
single click for breakpoint
This commit is contained in:
@@ -470,22 +470,16 @@ public class Debugger implements VMEventListener {
|
||||
}
|
||||
|
||||
|
||||
/** Toggle a breakpoint on the current line. */
|
||||
synchronized void toggleBreakpoint() {
|
||||
toggleBreakpoint(editor.getCurrentLineID().lineIdx());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle a breakpoint on a line in the current tab.
|
||||
* @param lineIdx the line index (0-based) in the current tab
|
||||
*/
|
||||
synchronized void toggleBreakpoint(int lineIdx) {
|
||||
LineID line = editor.getLineIDInCurrentTab(lineIdx);
|
||||
if (!hasBreakpoint(line)) {
|
||||
setBreakpoint(line.lineIdx());
|
||||
} else {
|
||||
if (hasBreakpoint(line)) {
|
||||
removeBreakpoint(line.lineIdx());
|
||||
} else {
|
||||
setBreakpoint(line.lineIdx());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1202,6 +1202,19 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
/** Toggle a breakpoint on the current line. */
|
||||
public void toggleBreakpoint() {
|
||||
debugger.toggleBreakpoint(getCurrentLineID().lineIdx());
|
||||
}
|
||||
|
||||
|
||||
public void toggleBreakpoint(int lineIndex) {
|
||||
new Exception().printStackTrace(System.out);
|
||||
debugger.toggleBreakpoint(lineIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public void handleSave() {
|
||||
// toolbar.activate(JavaToolbar.SAVE);
|
||||
@@ -1516,7 +1529,7 @@ public class JavaEditor extends Editor {
|
||||
item.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Logger.getLogger(JavaEditor.class.getName()).log(Level.INFO, "Invoked 'Toggle Breakpoint' menu item");
|
||||
debugger.toggleBreakpoint();
|
||||
toggleBreakpoint();
|
||||
}
|
||||
});
|
||||
debugMenu.add(item);
|
||||
@@ -2477,15 +2490,15 @@ public class JavaEditor extends Editor {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Event Handler for double clicking in the left hand gutter area.
|
||||
* @param lineIdx the line (0-based) that was double clicked
|
||||
*/
|
||||
public void gutterDblClicked(int lineIdx) {
|
||||
if (debugger != null) {
|
||||
debugger.toggleBreakpoint(lineIdx);
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * Event Handler for double clicking in the left hand gutter area.
|
||||
// * @param lineIdx the line (0-based) that was double clicked
|
||||
// */
|
||||
// public void gutterDblClicked(int lineIdx) {
|
||||
// if (debugger != null) {
|
||||
// debugger.toggleBreakpoint(lineIdx);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
public void statusBusy() {
|
||||
|
||||
@@ -719,17 +719,22 @@ public class JavaTextArea extends JEditTextArea {
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent me) {
|
||||
// check if this happened in the gutter area
|
||||
if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
if (me.getButton() == MouseEvent.BUTTON1 && me.getClickCount() == 2) {
|
||||
int line = me.getY() / painter.getFontMetrics().getHeight()
|
||||
+ firstLine;
|
||||
if (line >= 0 && line <= getLineCount() - 1) {
|
||||
editor.gutterDblClicked(line);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// // check if this happened in the gutter area
|
||||
// if (me.getX() < Editor.LEFT_GUTTER) {
|
||||
// if (me.getButton() == MouseEvent.BUTTON1) { // && me.getClickCount() == 2) {
|
||||
// //int line = me.getY() / painter.getFontMetrics().getHeight() + firstLine;
|
||||
// int offset = xyToOffset(me.getX(), me.getY());
|
||||
// if (offset >= 0) {
|
||||
// int lineIndex = getLineOfOffset(offset);
|
||||
// editor.toggleBreakpoint(lineIndex);
|
||||
// }
|
||||
//// if (line >= 0 && line < getLineCount()) {
|
||||
//// //editor.gutterDblClicked(line);
|
||||
//// editor.toggleBreakpoint(line);
|
||||
//// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (me.getButton() == MouseEvent.BUTTON3) {
|
||||
if (!editor.hasJavaTabs()) { // tooltips, etc disabled for java tabs
|
||||
|
||||
@@ -100,6 +100,7 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
|
||||
public JavaTextAreaPainter(JavaTextArea textArea, TextAreaDefaults defaults) {
|
||||
super(textArea, defaults);
|
||||
new Exception().printStackTrace(System.out);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent evt) {
|
||||
@@ -113,18 +114,37 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
}
|
||||
});
|
||||
|
||||
// Handle mouse clicks to toggle breakpoints
|
||||
addMouseListener(new MouseAdapter() {
|
||||
long lastTime; // OS X seems to be firing multiple mouse events
|
||||
|
||||
public void mousePressed(MouseEvent event) {
|
||||
long thisTime = event.getWhen();
|
||||
if (thisTime - lastTime > 100) {
|
||||
if (event.getX() < Editor.LEFT_GUTTER) {
|
||||
int offset = getTextArea().xyToOffset(event.getX(), event.getY());
|
||||
if (offset >= 0) {
|
||||
int lineIndex = getTextArea().getLineOfOffset(offset);
|
||||
getEditor().toggleBreakpoint(lineIndex);
|
||||
}
|
||||
}
|
||||
lastTime = thisTime;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(final MouseEvent evt) {
|
||||
for (ErrorLineCoord coord : errorLineCoords) {
|
||||
if (evt.getX() >= coord.xStart && evt.getX() <= coord.xEnd
|
||||
&& evt.getY() >= coord.yStart && evt.getY() <= coord.yEnd + 2) {
|
||||
setToolTipText(coord.problem.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (ErrorLineCoord coord : errorLineCoords) {
|
||||
if (evt.getX() >= coord.xStart && evt.getX() <= coord.xEnd &&
|
||||
evt.getY() >= coord.yStart && evt.getY() <= coord.yEnd + 2) {
|
||||
setToolTipText(coord.problem.getMessage());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// TweakMode code
|
||||
interactiveMode = false;
|
||||
|
||||
Reference in New Issue
Block a user