use of processing.mode.java.debug.LineID in project processing by processing.
the class JavaEditor method getCurrentLineID.
/**
* Retrieve line of sketch where the cursor currently resides.
* @return the current {@link LineID}
*/
protected LineID getCurrentLineID() {
String tab = getSketch().getCurrentCode().getFileName();
int lineNo = getTextArea().getCaretLine();
return new LineID(tab, lineNo);
}
use of processing.mode.java.debug.LineID in project processing by processing.
the class JavaEditor method removeBreakpointedLine.
/**
* Remove a highlight for a breakpointed line. Needs to be on the current tab.
* @param lineIdx the line index on the current tab to remove a breakpoint
* highlight from
*/
public void removeBreakpointedLine(int lineIdx) {
LineID line = getLineIDInCurrentTab(lineIdx);
//System.out.println("line id: " + line.fileName() + " " + line.lineIdx());
LineHighlight foundLine = null;
for (LineHighlight hl : breakpointedLines) {
if (hl.getLineID().equals(line)) {
foundLine = hl;
break;
}
}
if (foundLine != null) {
foundLine.clear();
breakpointedLines.remove(foundLine);
foundLine.dispose();
// repaint current line if it's on this line
if (currentLine != null && currentLine.getLineID().equals(line)) {
currentLine.paint();
}
}
}
use of processing.mode.java.debug.LineID in project processing by processing.
the class JavaEditor method handleSaveAs.
public boolean handleSaveAs() {
//System.out.println("handleSaveAs");
String oldName = getSketch().getCode(0).getFileName();
//System.out.println("old name: " + oldName);
boolean saved = super.handleSaveAs();
if (saved) {
// re-set breakpoints in first tab (name has changed)
List<LineBreakpoint> bps = debugger.getBreakpoints(oldName);
debugger.clearBreakpoints(oldName);
String newName = getSketch().getCode(0).getFileName();
//System.out.println("new name: " + newName);
for (LineBreakpoint bp : bps) {
LineID line = new LineID(newName, bp.lineID().lineIdx());
//System.out.println("setting: " + line);
debugger.setBreakpoint(line);
}
// add breakpoint marker comments to source file
for (SketchCode code : getSketch().getCode()) {
addBreakpointComments(code.getFileName());
}
// set new name of variable inspector
//inspector.setTitle(getSketch().getName());
}
return saved;
}
use of processing.mode.java.debug.LineID in project processing by processing.
the class JavaEditor method stripBreakpointComments.
// handleOpenInternal() only called by the Editor constructor, meaning that
// this code is all useless. All these things will be in their default state.
// /**
// * Event handler called when loading another sketch in this editor.
// * Clears breakpoints of previous sketch.
// * @return true if a sketch was opened, false if aborted
// */
// @Override
// protected void handleOpenInternal(String path) throws EditorException {
// super.handleOpenInternal(path);
//
// // should already been stopped (open calls handleStop)
// if (debugger != null) {
// debugger.clearBreakpoints();
// }
// clearBreakpointedLines();
// variableInspector().reset();
// }
/**
* Extract breakpointed lines from source code marker comments. This removes
* marker comments from the editor text. Intended to be called on loading a
* sketch, since re-setting the sketches contents after removing the markers
* will clear all breakpoints.
*
* @return the list of {@link LineID}s where breakpoint marker comments were
* removed from.
*/
protected List<LineID> stripBreakpointComments() {
List<LineID> bps = new ArrayList<>();
// iterate over all tabs
Sketch sketch = getSketch();
for (int i = 0; i < sketch.getCodeCount(); i++) {
SketchCode tab = sketch.getCode(i);
String code = tab.getProgram();
// newlines not included
String[] lines = code.split("\\r?\\n");
//System.out.println(code);
// scan code for breakpoint comments
int lineIdx = 0;
for (String line : lines) {
//System.out.println(line);
if (line.endsWith(breakpointMarkerComment)) {
LineID lineID = new LineID(tab.getFileName(), lineIdx);
bps.add(lineID);
//System.out.println("found breakpoint: " + lineID);
// got a breakpoint
//dbg.setBreakpoint(lineID);
int index = line.lastIndexOf(breakpointMarkerComment);
lines[lineIdx] = line.substring(0, index);
}
lineIdx++;
}
//tab.setProgram(code);
code = PApplet.join(lines, "\n");
setTabContents(tab.getFileName(), code);
}
return bps;
}
Aggregations