forked from facchinm/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSketchCodeDocument.java
More file actions
103 lines (78 loc) · 2.24 KB
/
Copy pathSketchCodeDocument.java
File metadata and controls
103 lines (78 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package processing.app;
import java.io.File;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import javax.swing.undo.UndoManager;
public class SketchCodeDocument implements DocumentListener{
private SketchCode code;
private Sketch sketch;
private Document document;
// Undo Manager for this tab, each tab keeps track of their own Editor.undo
// will be set to this object when this code is the tab that's currently the
// front.
private UndoManager undo;
// saved positions from last time this tab was used
private int selectionStart;
private int selectionStop;
private int scrollPosition;
public SketchCodeDocument(Sketch sketch, SketchCode code) {
this.code = code;
this.sketch = sketch;
this.code.setMetadata(this);
}
public SketchCodeDocument(Sketch sketch, File file) {
this.code = new SketchCode(file, this);
this.sketch = sketch;
}
public UndoManager getUndo() {
return undo;
}
public void setUndo(UndoManager undo) {
this.undo = undo;
}
public int getSelectionStart() {
return selectionStart;
}
public void setSelectionStart(int selectionStart) {
this.selectionStart = selectionStart;
}
public int getSelectionStop() {
return selectionStop;
}
public void setSelectionStop(int selectionStop) {
this.selectionStop = selectionStop;
}
public int getScrollPosition() {
return scrollPosition;
}
public void setScrollPosition(int scrollPosition) {
this.scrollPosition = scrollPosition;
}
public SketchCode getCode() {
return code;
}
public void setCode(SketchCode code) {
this.code = code;
}
public Document getDocument() {
return document;
}
public void setDocument(Document document) {
this.document = document;
document.addDocumentListener(this);
}
@Override
public void insertUpdate(DocumentEvent e) {
if(!code.isModified()) sketch.setModified(true);
}
@Override
public void removeUpdate(DocumentEvent e) {
if(!code.isModified()) sketch.setModified(true);
}
@Override
public void changedUpdate(DocumentEvent e) {
// Callback for when styles in the current document change.
// This method is never called.
}
}