Skip to content

Commit 04a7e7f

Browse files
gdyrfacchinm
authored andcommitted
Add font size shortcuts (menu and keyboard)
1 parent cd798ab commit 04a7e7f

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

app/src/processing/app/Base.java

+11
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,17 @@ public void handlePrefs() {
18391839
dialog.setVisible(true);
18401840
}
18411841

1842+
/**
1843+
* Adjust font size
1844+
*/
1845+
public void handleFontSizeChange(int change) {
1846+
String pieces[] = PApplet.split(PreferencesData.get("editor.font"), ',');
1847+
int newSize = Integer.parseInt(pieces[2]) + change;
1848+
pieces[2] = String.valueOf(newSize);
1849+
PreferencesData.set("editor.font", PApplet.join(pieces, ','));
1850+
this.getEditors().forEach(processing.app.Editor::applyPreferences);
1851+
}
1852+
18421853
// XXX: Remove this method and make librariesIndexer non-static
18431854
static public LibraryList getLibraries() {
18441855
return BaseNoGui.librariesIndexer.getInstalledLibraries();

app/src/processing/app/Editor.java

+18
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,24 @@ public void actionPerformed(ActionEvent e) {
13741374

13751375
menu.addSeparator();
13761376

1377+
JMenuItem increaseFontSizeItem = newJMenuItem(tr("Increase Font Size"), '=');
1378+
increaseFontSizeItem.addActionListener(new ActionListener() {
1379+
public void actionPerformed(ActionEvent e) {
1380+
base.handleFontSizeChange(1);
1381+
}
1382+
});
1383+
menu.add(increaseFontSizeItem);
1384+
1385+
JMenuItem decreaseFontSizeItem = newJMenuItem(tr("Decrease Font Size"), '-');
1386+
decreaseFontSizeItem.addActionListener(new ActionListener() {
1387+
public void actionPerformed(ActionEvent e) {
1388+
base.handleFontSizeChange(-1);
1389+
}
1390+
});
1391+
menu.add(decreaseFontSizeItem);
1392+
1393+
menu.addSeparator();
1394+
13771395
JMenuItem findItem = newJMenuItem(tr("Find..."), 'F');
13781396
findItem.addActionListener(new ActionListener() {
13791397
public void actionPerformed(ActionEvent e) {

0 commit comments

Comments
 (0)