From f426188d0406fb6ee1652f09db13e14bc264b5f8 Mon Sep 17 00:00:00 2001 From: "ricardo.jl.rufino" Date: Thu, 23 Apr 2015 14:08:33 -0300 Subject: [PATCH] Add 'Code Folding' preferences and fix Font-Size changes --- app/src/processing/app/Editor.java | 7 +++++-- app/src/processing/app/Preferences.java | 12 ++++++++++++ build/shared/lib/preferences.txt | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 796e12bd5..69abf31cf 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -451,6 +451,10 @@ 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) { // disable line highlight and turn off the caret when disabling @@ -479,8 +483,7 @@ public class Editor extends JFrame implements RunnerListener { //sketchbook.rebuildMenus(); // For 0126, moved into Base, which will notify all editors. //base.rebuildMenusAsync(); - - textarea.setTheme(Preferences.get("editor.syntax_theme")); + } diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index dd5da7eaa..28d61ac2b 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -222,6 +222,7 @@ public class Preferences { JCheckBox verboseCompilationBox; JCheckBox verboseUploadBox; JCheckBox displayLineNumbersBox; + JCheckBox enableCodeFoldingBox; JCheckBox verifyUploadBox; JCheckBox externalEditorBox; JCheckBox checkUpdatesBox; @@ -423,6 +424,15 @@ public class Preferences { right = Math.max(right, left + d.width); top += d.height + GUI_BETWEEN; + // [ ] Enable Code Folding + + enableCodeFoldingBox = new JCheckBox(_("Enable Code Folding")); + pane.add(enableCodeFoldingBox); + d = enableCodeFoldingBox.getPreferredSize(); + enableCodeFoldingBox.setBounds(left, top, d.width + 10, d.height); + right = Math.max(right, left + d.width); + top += d.height + GUI_BETWEEN; + // [ ] Verify code after upload verifyUploadBox = new JCheckBox(_("Verify code after upload")); @@ -745,6 +755,7 @@ public class Preferences { PreferencesData.setBoolean("build.verbose", verboseCompilationBox.isSelected()); PreferencesData.setBoolean("upload.verbose", verboseUploadBox.isSelected()); PreferencesData.setBoolean("editor.linenumbers", displayLineNumbersBox.isSelected()); + PreferencesData.setBoolean("editor.code_folding", enableCodeFoldingBox.isSelected()); PreferencesData.setBoolean("upload.verify", verifyUploadBox.isSelected()); PreferencesData.setBoolean("editor.save_on_verify", saveVerifyUploadBox.isSelected()); @@ -836,6 +847,7 @@ public class Preferences { verboseCompilationBox.setSelected(PreferencesData.getBoolean("build.verbose")); verboseUploadBox.setSelected(PreferencesData.getBoolean("upload.verbose")); displayLineNumbersBox.setSelected(PreferencesData.getBoolean("editor.linenumbers")); + enableCodeFoldingBox.setSelected(PreferencesData.getBoolean("editor.code_folding")); verifyUploadBox.setSelected(PreferencesData.getBoolean("upload.verify")); //closingLastQuitsBox. diff --git a/build/shared/lib/preferences.txt b/build/shared/lib/preferences.txt index 27c45c52e..7f2e08b8e 100644 --- a/build/shared/lib/preferences.txt +++ b/build/shared/lib/preferences.txt @@ -87,7 +87,10 @@ editor.window.height.min = 290 #editor.window.height.min.windows = 530 # Syntax coloring ( on lib/theme/syntax ) -editor.syntax_theme = default +editor.syntax_theme=default + +# Enable code folding +editor.code_folding=true # font size for editor editor.font=Monospaced,plain,12