Skip to content

Commit cbd822e

Browse files
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 c13537a commit cbd822e

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
@@ -1649,13 +1649,13 @@ public void selectPrevTab() {
16491649
selectTab((currentTabIndex - 1 + tabs.size()) % tabs.size());
16501650
}
16511651

1652-
public EditorTab findTab(final SketchCode doc) {
1653-
return tabs.get(findTabIndex(doc));
1652+
public EditorTab findTab(final SketchFile file) {
1653+
return tabs.get(findTabIndex(file));
16541654
}
16551655

1656-
public int findTabIndex(final SketchCode doc) {
1656+
public int findTabIndex(final SketchFile file) {
16571657
for (int i = 0; i < tabs.size(); ++i) {
1658-
if (tabs.get(i).getSketchCode() == doc)
1658+
if (tabs.get(i).getSketchFile() == file)
16591659
return i;
16601660
}
16611661
return -1;
@@ -1669,9 +1669,9 @@ public void createTabs() {
16691669
tabs.clear();
16701670
currentTabIndex = -1;
16711671
tabs.ensureCapacity(sketch.getCodeCount());
1672-
for (SketchCode code : sketch.getCodes()) {
1672+
for (SketchFile file : sketch.getFiles()) {
16731673
try {
1674-
addTab(code, null);
1674+
addTab(file, null);
16751675
} catch(IOException e) {
16761676
// TODO: Improve / move error handling
16771677
System.err.println(e);
@@ -1683,15 +1683,15 @@ public void createTabs() {
16831683
/**
16841684
* Add a new tab.
16851685
*
1686-
* @param code
1686+
* @param file
16871687
* The file to show in the tab.
16881688
* @param contents
1689-
* The contents to show in the tab, or null to load the
1690-
* contents from the given file.
1689+
* The contents to show in the tab, or null to load the contents from
1690+
* the given file.
16911691
* @throws IOException
16921692
*/
1693-
protected void addTab(SketchCode code, String contents) throws IOException {
1694-
EditorTab tab = new EditorTab(this, code, contents);
1693+
protected void addTab(SketchFile file, String contents) throws IOException {
1694+
EditorTab tab = new EditorTab(this, file, contents);
16951695
tabs.add(tab);
16961696
}
16971697

@@ -2007,7 +2007,7 @@ private void updateTitle() {
20072007
if (sketchController == null) {
20082008
return;
20092009
}
2010-
SketchCode current = getCurrentTab().getSketchCode();
2010+
SketchFile current = getCurrentTab().getSketchFile();
20112011
if (current.isPrimary()) {
20122012
setTitle(I18n.format(tr("{0} | Arduino {1}"), sketch.getName(),
20132013
BaseNoGui.VERSION_NAME_LONG));
@@ -2570,7 +2570,7 @@ private void handlePrint() {
25702570
printerJob.setPrintable(getCurrentTab().getTextArea());
25712571
}
25722572
// set the name of the job to the code name
2573-
printerJob.setJobName(getCurrentTab().getSketchCode().getPrettyName());
2573+
printerJob.setJobName(getCurrentTab().getSketchFile().getPrettyName());
25742574

25752575
if (printerJob.printDialog()) {
25762576
try {

app/src/processing/app/EditorHeader.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ public void paintComponent(Graphics screen) {
238238
int x = 6; // offset from left edge of the component
239239
int i = 0;
240240
for (EditorTab tab : tabs) {
241-
SketchCode code = tab.getSketchCode();
242-
String codeName = code.getPrettyName();
241+
SketchFile file = tab.getSketchFile();
242+
String filename = file.getPrettyName();
243243

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

247247
Graphics2D g2 = (Graphics2D) g;
248248
int textWidth = (int)
@@ -320,9 +320,9 @@ public void rebuildMenu() {
320320

321321
int i = 0;
322322
for (EditorTab tab : editor.getTabs()) {
323-
SketchCode code = tab.getSketchCode();
323+
SketchFile file = tab.getSketchFile();
324324
final int index = i++;
325-
item = new JMenuItem(code.getPrettyName());
325+
item = new JMenuItem(file.getPrettyName());
326326
item.addActionListener((ActionEvent e) -> {
327327
editor.selectTab(index);
328328
});

app/src/processing/app/EditorTab.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
/**
6565
* Single tab, editing a single file, in the main window.
6666
*/
67-
public class EditorTab extends JPanel implements SketchCode.TextStorage {
67+
public class EditorTab extends JPanel implements SketchFile.TextStorage {
6868
protected Editor editor;
6969
protected SketchTextArea textarea;
7070
protected RTextScrollPane scrollPane;
71-
protected SketchCode code;
71+
protected SketchFile file;
7272
protected boolean modified;
7373
/** Is external editing mode currently enabled? */
7474
protected boolean external;
@@ -78,32 +78,32 @@ public class EditorTab extends JPanel implements SketchCode.TextStorage {
7878
*
7979
* @param editor
8080
* The Editor this tab runs in
81-
* @param code
81+
* @param file
8282
* The file to display in this tab
8383
* @param contents
84-
* Initial contents to display in this tab. Can be used when
85-
* editing a file that doesn't exist yet. If null is passed,
86-
* code.load() is called and displayed instead.
84+
* Initial contents to display in this tab. Can be used when editing
85+
* a file that doesn't exist yet. If null is passed, code.load() is
86+
* called and displayed instead.
8787
* @throws IOException
8888
*/
89-
public EditorTab(Editor editor, SketchCode code, String contents)
89+
public EditorTab(Editor editor, SketchFile file, String contents)
9090
throws IOException {
9191
super(new BorderLayout());
9292

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

101101
this.editor = editor;
102-
this.code = code;
102+
this.file = file;
103103
RSyntaxDocument document = createDocument(contents);
104104
this.textarea = createTextArea(document);
105105
this.scrollPane = createScrollPane(this.textarea);
106-
code.setStorage(this);
106+
file.setStorage(this);
107107
applyPreferences();
108108
add(this.scrollPane, BorderLayout.CENTER);
109109

@@ -291,14 +291,14 @@ public void applyPreferences() {
291291
textarea.setEditable(false);
292292
// Detach from the code, since we are no longer the authoritative source
293293
// for file contents.
294-
code.setStorage(null);
294+
file.setStorage(null);
295295
// Reload, in case the file contents already changed.
296296
reload();
297297
} else {
298298
textarea.setBackground(Theme.getColor("editor.bgcolor"));
299299
textarea.setHighlightCurrentLine(Theme.getBoolean("editor.linehighlight"));
300300
textarea.setEditable(true);
301-
code.setStorage(this);
301+
file.setStorage(this);
302302
// Reload once just before disabling external mode, to ensure we have
303303
// the latest contents.
304304
reload();
@@ -334,10 +334,10 @@ public void activated() {
334334
private void reload() {
335335
String text;
336336
try {
337-
text = code.load();
337+
text = file.load();
338338
} catch (IOException e) {
339339
System.err.println(I18n.format("Warning: Failed to reload file: \"{0}\"",
340-
code.getFileName()));
340+
file.getFileName()));
341341
return;
342342
}
343343
setText(text);
@@ -363,10 +363,10 @@ public SketchController getSketch() {
363363
}
364364

365365
/**
366-
* Get the SketchCodeDocument that is being edited in this tab.
366+
* Get the SketchFile that is being edited in this tab.
367367
*/
368-
public SketchCode getSketchCode() {
369-
return this.code;
368+
public SketchFile getSketchFile() {
369+
return this.file;
370370
}
371371

372372
/**
@@ -405,8 +405,8 @@ public boolean isModified() {
405405
}
406406

407407
/**
408-
* Clear modified status. Should only be called by SketchCode through
409-
* the TextStorage interface.
408+
* Clear modified status. Should only be called by SketchFile through the
409+
* TextStorage interface.
410410
*/
411411
public void clearModified() {
412412
setModified(false);

0 commit comments

Comments
 (0)