Skip to content

Commit 8e0d007

Browse files
matthijskooijmanfacchinm
authored andcommitted
Rename SketchCode to SketchFile
That name more accurately reflects its purpose: It represents a single file within a sketch. This just updates the class name and variable names referring to these objects and some comments, so no behaviour should change.
1 parent dfa60da commit 8e0d007

File tree

9 files changed

+126
-126
lines changed

9 files changed

+126
-126
lines changed

app/src/processing/app/Editor.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,13 +1640,13 @@ public void selectPrevTab() {
16401640
selectTab((currentTabIndex - 1 + tabs.size()) % tabs.size());
16411641
}
16421642

1643-
public EditorTab findTab(final SketchCode doc) {
1644-
return tabs.get(findTabIndex(doc));
1643+
public EditorTab findTab(final SketchFile file) {
1644+
return tabs.get(findTabIndex(file));
16451645
}
16461646

1647-
public int findTabIndex(final SketchCode doc) {
1647+
public int findTabIndex(final SketchFile file) {
16481648
for (int i = 0; i < tabs.size(); ++i) {
1649-
if (tabs.get(i).getSketchCode() == doc)
1649+
if (tabs.get(i).getSketchFile() == file)
16501650
return i;
16511651
}
16521652
return -1;
@@ -1660,9 +1660,9 @@ public void createTabs() {
16601660
tabs.clear();
16611661
currentTabIndex = -1;
16621662
tabs.ensureCapacity(sketch.getCodeCount());
1663-
for (SketchCode code : sketch.getCodes()) {
1663+
for (SketchFile file : sketch.getFiles()) {
16641664
try {
1665-
addTab(code, null);
1665+
addTab(file, null);
16661666
} catch(IOException e) {
16671667
// TODO: Improve / move error handling
16681668
System.err.println(e);
@@ -1674,15 +1674,15 @@ public void createTabs() {
16741674
/**
16751675
* Add a new tab.
16761676
*
1677-
* @param code
1677+
* @param file
16781678
* The file to show in the tab.
16791679
* @param contents
1680-
* The contents to show in the tab, or null to load the
1681-
* contents from the given file.
1680+
* The contents to show in the tab, or null to load the contents from
1681+
* the given file.
16821682
* @throws IOException
16831683
*/
1684-
protected void addTab(SketchCode code, String contents) throws IOException {
1685-
EditorTab tab = new EditorTab(this, code, contents);
1684+
protected void addTab(SketchFile file, String contents) throws IOException {
1685+
EditorTab tab = new EditorTab(this, file, contents);
16861686
tabs.add(tab);
16871687
}
16881688

@@ -1999,7 +1999,7 @@ private void updateTitle() {
19991999
if (sketchController == null) {
20002000
return;
20012001
}
2002-
SketchCode current = getCurrentTab().getSketchCode();
2002+
SketchFile current = getCurrentTab().getSketchFile();
20032003
if (current.isPrimary()) {
20042004
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
20052005
BaseNoGui.VERSION_NAME_LONG));
@@ -2635,7 +2635,7 @@ private void handlePrint() {
26352635
printerJob.setPrintable(getCurrentTab().getTextArea());
26362636
}
26372637
// set the name of the job to the code name
2638-
printerJob.setJobName(getCurrentTab().getSketchCode().getPrettyName());
2638+
printerJob.setJobName(getCurrentTab().getSketchFile().getPrettyName());
26392639

26402640
if (printerJob.printDialog()) {
26412641
try {

app/src/processing/app/EditorHeader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ public void paintComponent(Graphics screen) {
244244
int x = scale(6); // offset from left edge of the component
245245
int i = 0;
246246
for (EditorTab tab : tabs) {
247-
SketchCode code = tab.getSketchCode();
248-
String codeName = code.getPrettyName();
247+
SketchFile file = tab.getSketchFile();
248+
String filename = file.getPrettyName();
249249

250250
// if modified, add the li'l glyph next to the name
251-
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
251+
String text = " " + filename + (file.isModified() ? " \u00A7" : " ");
252252

253253
int textWidth = (int)
254254
font.getStringBounds(text, g.getFontRenderContext()).getWidth();
@@ -325,9 +325,9 @@ public void rebuildMenu() {
325325

326326
int i = 0;
327327
for (EditorTab tab : editor.getTabs()) {
328-
SketchCode code = tab.getSketchCode();
328+
SketchFile file = tab.getSketchFile();
329329
final int index = i++;
330-
item = new JMenuItem(code.getPrettyName());
330+
item = new JMenuItem(file.getPrettyName());
331331
item.addActionListener((ActionEvent e) -> {
332332
editor.selectTab(index);
333333
});

app/src/processing/app/EditorTab.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@
6565
/**
6666
* Single tab, editing a single file, in the main window.
6767
*/
68-
public class EditorTab extends JPanel implements SketchCode.TextStorage {
68+
public class EditorTab extends JPanel implements SketchFile.TextStorage {
6969
protected Editor editor;
7070
protected SketchTextArea textarea;
7171
protected RTextScrollPane scrollPane;
72-
protected SketchCode code;
72+
protected SketchFile file;
7373
protected boolean modified;
7474
/** Is external editing mode currently enabled? */
7575
protected boolean external;
@@ -79,32 +79,32 @@ public class EditorTab extends JPanel implements SketchCode.TextStorage {
7979
*
8080
* @param editor
8181
* The Editor this tab runs in
82-
* @param code
82+
* @param file
8383
* The file to display in this tab
8484
* @param contents
85-
* Initial contents to display in this tab. Can be used when
86-
* editing a file that doesn't exist yet. If null is passed,
87-
* code.load() is called and displayed instead.
85+
* Initial contents to display in this tab. Can be used when editing
86+
* a file that doesn't exist yet. If null is passed, code.load() is
87+
* called and displayed instead.
8888
* @throws IOException
8989
*/
90-
public EditorTab(Editor editor, SketchCode code, String contents)
90+
public EditorTab(Editor editor, SketchFile file, String contents)
9191
throws IOException {
9292
super(new BorderLayout());
9393

9494
// Load initial contents contents from file if nothing was specified.
9595
if (contents == null) {
96-
contents = code.load();
96+
contents = file.load();
9797
modified = false;
9898
} else {
9999
modified = true;
100100
}
101101

102102
this.editor = editor;
103-
this.code = code;
103+
this.file = file;
104104
RSyntaxDocument document = createDocument(contents);
105105
this.textarea = createTextArea(document);
106106
this.scrollPane = createScrollPane(this.textarea);
107-
code.setStorage(this);
107+
file.setStorage(this);
108108
applyPreferences();
109109
add(this.scrollPane, BorderLayout.CENTER);
110110

@@ -292,14 +292,14 @@ public void applyPreferences() {
292292
textarea.setEditable(false);
293293
// Detach from the code, since we are no longer the authoritative source
294294
// for file contents.
295-
code.setStorage(null);
295+
file.setStorage(null);
296296
// Reload, in case the file contents already changed.
297297
reload();
298298
} else {
299299
textarea.setBackground(Theme.getColor("editor.bgcolor"));
300300
textarea.setHighlightCurrentLine(Theme.getBoolean("editor.linehighlight"));
301301
textarea.setEditable(true);
302-
code.setStorage(this);
302+
file.setStorage(this);
303303
// Reload once just before disabling external mode, to ensure we have
304304
// the latest contents.
305305
reload();
@@ -337,10 +337,10 @@ public void activated() {
337337
private void reload() {
338338
String text;
339339
try {
340-
text = code.load();
340+
text = file.load();
341341
} catch (IOException e) {
342342
System.err.println(I18n.format("Warning: Failed to reload file: \"{0}\"",
343-
code.getFileName()));
343+
file.getFileName()));
344344
return;
345345
}
346346
setText(text);
@@ -366,10 +366,10 @@ public SketchController getSketch() {
366366
}
367367

368368
/**
369-
* Get the SketchCodeDocument that is being edited in this tab.
369+
* Get the SketchFile that is being edited in this tab.
370370
*/
371-
public SketchCode getSketchCode() {
372-
return this.code;
371+
public SketchFile getSketchFile() {
372+
return this.file;
373373
}
374374

375375
/**
@@ -429,8 +429,8 @@ public boolean isModified() {
429429
}
430430

431431
/**
432-
* Clear modified status. Should only be called by SketchCode through
433-
* the TextStorage interface.
432+
* Clear modified status. Should only be called by SketchFile through the
433+
* TextStorage interface.
434434
*/
435435
public void clearModified() {
436436
setModified(false);

0 commit comments

Comments
 (0)