Skip to content

Commit 083fb38

Browse files
bitroncmaglie
authored andcommitted
Removed GUI dependencies from SketchCode class.
Moved GUI fields into a SketchCodeDoc container class.
1 parent 3b5328b commit 083fb38

File tree

5 files changed

+155
-138
lines changed

5 files changed

+155
-138
lines changed

app/src/processing/app/Editor.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,19 +1637,19 @@ public int getScrollPosition() {
16371637
* Switch between tabs, this swaps out the Document object
16381638
* that's currently being manipulated.
16391639
*/
1640-
protected void setCode(SketchCode code) {
1641-
SyntaxDocument document = (SyntaxDocument) code.getDocument();
1640+
protected void setCode(SketchCodeDoc codeDoc) {
1641+
SyntaxDocument document = (SyntaxDocument) codeDoc.getDocument();
16421642

16431643
if (document == null) { // this document not yet inited
16441644
document = new SyntaxDocument();
1645-
code.setDocument(document);
1646-
1645+
codeDoc.setDocument(document);
1646+
16471647
// turn on syntax highlighting
16481648
document.setTokenMarker(new PdeKeywords());
16491649

16501650
// insert the program text into the document object
16511651
try {
1652-
document.insertString(0, code.getProgram(), null);
1652+
document.insertString(0, codeDoc.getCode().getProgram(), null);
16531653
} catch (BadLocationException bl) {
16541654
bl.printStackTrace();
16551655
}
@@ -1674,12 +1674,12 @@ public void undoableEditHappened(UndoableEditEvent e) {
16741674

16751675
// update the document object that's in use
16761676
textarea.setDocument(document,
1677-
code.getSelectionStart(), code.getSelectionStop(),
1678-
code.getScrollPosition());
1677+
codeDoc.getSelectionStart(), codeDoc.getSelectionStop(),
1678+
codeDoc.getScrollPosition());
16791679

16801680
textarea.requestFocus(); // get the caret blinking
16811681

1682-
this.undo = code.getUndo();
1682+
this.undo = codeDoc.getUndo();
16831683
undoAction.updateUndoState();
16841684
redoAction.updateRedoState();
16851685
}

app/src/processing/app/EditorHeader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ public void actionPerformed(ActionEvent e) {
361361
editor.getSketch().setCurrentCode(e.getActionCommand());
362362
}
363363
};
364-
for (SketchCode code : sketch.getCode()) {
364+
for (SketchCodeDoc codeDoc : sketch.getCodeDocs()) {
365+
SketchCode code = codeDoc.getCode();
365366
item = new JMenuItem(code.isExtension(sketch.getDefaultExtension()) ?
366367
code.getPrettyName() : code.getFileName());
367368
item.setActionCommand(code.getFileName());

0 commit comments

Comments
 (0)