diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 69abf31cf..bcfcdcf3f 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -451,9 +451,7 @@ public class Editor extends JFrame implements RunnerListener { saveAsMenuItem.setEnabled(!external); scrollPane.setLineNumbersEnabled(PreferencesData.getBoolean("editor.linenumbers")); - - textarea.setTheme(PreferencesData.get("editor.syntax_theme")); - + textarea.setCodeFoldingEnabled(PreferencesData.getBoolean("editor.code_folding")); if (external) { @@ -957,7 +955,7 @@ public class Editor extends JFrame implements RunnerListener { } - protected SketchTextArea createTextArea(){ + protected SketchTextArea createTextArea() throws IOException { SketchTextArea textArea = new SketchTextArea(); textArea.requestFocusInWindow(); textArea.setMarkOccurrences(true); diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 28d61ac2b..7d361c41d 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -231,7 +231,6 @@ public class Preferences { JCheckBox autoAssociateBox; JComboBox comboLanguage; JComboBox comboWarnings; - JComboBox comboSyntaxThemes; JCheckBox saveVerifyUploadBox; JTextField proxyHTTPServer; JTextField proxyHTTPPort; @@ -359,27 +358,6 @@ public class Preferences { fontSizeField.setText(String.valueOf(editorFont.getSize())); top += d.height + GUI_BETWEEN; - // Syntax Coloring [ ] - - box = Box.createHorizontalBox(); - label = new JLabel(_("Syntax Coloring: ")); - box.add(label); - String[] syntaxThemes = new String[]{"default","dark"}; - comboSyntaxThemes = new JComboBox(syntaxThemes); - String currentTheme = PreferencesData.get("editor.syntax_theme", "default"); - for (String item : syntaxThemes) { - if (currentTheme.equals(item)) { - comboSyntaxThemes.setSelectedItem(item); - } - } - box.add(comboSyntaxThemes); - pane.add(box); - d = box.getPreferredSize(); - box.setForeground(Color.gray); - box.setBounds(left, top, d.width, d.height); - right = Math.max(right, left + d.width); - top += d.height + GUI_BETWEEN; - // Show verbose output during: [ ] compilation [ ] upload box = Box.createHorizontalBox(); @@ -778,7 +756,6 @@ public class Preferences { PreferencesData.set("sketchbook.path", newPath); } - PreferencesData.set("editor.syntax_theme", comboSyntaxThemes.getSelectedItem().toString()); PreferencesData.setBoolean("editor.external", externalEditorBox.isSelected()); PreferencesData.setBoolean("update.check", checkUpdatesBox.isSelected()); PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected()); diff --git a/app/src/processing/app/syntax/SketchTextArea.java b/app/src/processing/app/syntax/SketchTextArea.java index 4012ebd83..c2243c25c 100644 --- a/app/src/processing/app/syntax/SketchTextArea.java +++ b/app/src/processing/app/syntax/SketchTextArea.java @@ -75,13 +75,14 @@ public class SketchTextArea extends RSyntaxTextArea { private EditorListener editorListener; - public SketchTextArea() { + public SketchTextArea() throws IOException { super(); installFeatures(); } - protected void installFeatures(){ + protected void installFeatures() throws IOException { + setTheme(PreferencesData.get("editor.syntax_theme", "default")); setLinkGenerator(new DocLinkGenerator()); @@ -89,26 +90,20 @@ public class SketchTextArea extends RSyntaxTextArea { fixControlTab(); installTokenMaker(); } - - public void setTheme(String name){ + + public void setTheme(String name) throws IOException { FileInputStream defaultXmlInputStream = null; try { - defaultXmlInputStream = new FileInputStream(new File(BaseNoGui.getContentFile("lib"), "theme/syntax/"+name+".xml")); + defaultXmlInputStream = new FileInputStream(new File(BaseNoGui.getContentFile("lib"), "theme/syntax/" + name + ".xml")); Theme theme = Theme.load(defaultXmlInputStream); theme.apply(this); - } catch (IOException e) { - e.printStackTrace(); } finally { if (defaultXmlInputStream != null) { - try { - defaultXmlInputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } + defaultXmlInputStream.close(); } } } - + // Removing the default focus traversal keys // This is because the DefaultKeyboardFocusManager handles the keypress and consumes the event protected void fixControlTab(){ diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 7f2e08b8e..5b4bf7888 100644 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -86,9 +86,6 @@ editor.window.height.min = 290 # tested to be 515 on Windows XP, this leaves some room #editor.window.height.min.windows = 530 -# Syntax coloring ( on lib/theme/syntax ) -editor.syntax_theme=default - # Enable code folding editor.code_folding=true