Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add quick font-size change to the edit menu #1019

Merged
merged 1 commit into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ public void actionPerformed(ActionEvent e) {
}
});
}

}


Expand Down Expand Up @@ -814,6 +815,18 @@ protected JMenu buildEditMenu() {
item.addActionListener(e -> handleIndentOutdent(false));
menu.add(item);

item = Toolkit.newJMenuItemExt("menu.edit.increase_font");
item.addActionListener(e -> {
modifyFontSize(true);
});
menu.add(item);

item = Toolkit.newJMenuItemExt("menu.edit.decrease_font");
item.addActionListener(e -> {
modifyFontSize(false);
});
menu.add(item);

menu.addSeparator();

item = Toolkit.newJMenuItem(Language.text("menu.edit.find"), 'F');
Expand Down Expand Up @@ -871,6 +884,16 @@ public void menuSelected(MenuEvent e) {
return menu;
}

protected void modifyFontSize(boolean increase){
var fontSize = Preferences.getInteger("editor.font.size");
fontSize += increase ? 1 : -1;
fontSize = Math.max(5, Math.min(72, fontSize));
Preferences.setInteger("editor.font.size", fontSize);
for (Editor editor : base.getEditors()) {
editor.applyPreferences();
}
Preferences.save();
}

abstract public JMenu buildSketchMenu();

Expand Down
8 changes: 8 additions & 0 deletions build/shared/lib/languages/PDE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ menu.edit.decrease_indent = ← Decrease Indent
menu.edit.decrease_indent.keystroke.macos = meta pressed OPEN_BRACKET
menu.edit.decrease_indent.keystroke.windows = ctrl pressed OPEN_BRACKET
menu.edit.decrease_indent.keystroke.linux = ctrl pressed OPEN_BRACKET
menu.edit.increase_font = Increase Font Size
menu.edit.increase_font.keystroke.macos = meta pressed EQUALS
menu.edit.increase_font.keystroke.windows = ctrl pressed EQUALS
menu.edit.increase_font.keystroke.linux = ctrl pressed EQUALS
menu.edit.decrease_font = Decrease Font Size
menu.edit.decrease_font.keystroke.macos = meta pressed MINUS
menu.edit.decrease_font.keystroke.windows = ctrl pressed MINUS
menu.edit.decrease_font.keystroke.linux = ctrl pressed MINUS
menu.edit.find = Find...
menu.edit.find_next = Find Next
menu.edit.find_previous = Find Previous
Expand Down