From 04a7e7ff159f1e797a05308f0028a1b94f04f4ed Mon Sep 17 00:00:00 2001 From: Michael G Date: Sun, 18 Jun 2017 19:10:06 +1000 Subject: [PATCH] Add font size shortcuts (menu and keyboard) --- app/src/processing/app/Base.java | 11 +++++++++++ app/src/processing/app/Editor.java | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index c930cc85f..8c772de8f 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1839,6 +1839,17 @@ public class Base { dialog.setVisible(true); } + /** + * Adjust font size + */ + public void handleFontSizeChange(int change) { + String pieces[] = PApplet.split(PreferencesData.get("editor.font"), ','); + int newSize = Integer.parseInt(pieces[2]) + change; + pieces[2] = String.valueOf(newSize); + PreferencesData.set("editor.font", PApplet.join(pieces, ',')); + this.getEditors().forEach(processing.app.Editor::applyPreferences); + } + // XXX: Remove this method and make librariesIndexer non-static static public LibraryList getLibraries() { return BaseNoGui.librariesIndexer.getInstalledLibraries(); diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index e68ca4778..7064f2844 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1374,6 +1374,24 @@ public class Editor extends JFrame implements RunnerListener { menu.addSeparator(); + JMenuItem increaseFontSizeItem = newJMenuItem(tr("Increase Font Size"), '='); + increaseFontSizeItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + base.handleFontSizeChange(1); + } + }); + menu.add(increaseFontSizeItem); + + JMenuItem decreaseFontSizeItem = newJMenuItem(tr("Decrease Font Size"), '-'); + decreaseFontSizeItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + base.handleFontSizeChange(-1); + } + }); + menu.add(decreaseFontSizeItem); + + menu.addSeparator(); + JMenuItem findItem = newJMenuItem(tr("Find..."), 'F'); findItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) {