Skip to content

Add font size shortcuts (menu and keyboard) #6394

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

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 11 additions & 0 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,17 @@ public void handlePrefs() {
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();
Expand Down
18 changes: 18 additions & 0 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,24 @@ public void actionPerformed(ActionEvent e) {

menu.addSeparator();

JMenuItem increaseFontSizeItem = newJMenuItem(tr("Increase Font Size"), '=');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you choose ctrl + '+' as increase shortcut? The = version doesn't seem to work with an Italian keyboard (since = can only be reached with Maiusc modifier)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! I hadn't thought about other keyboards.
One convention I'm familiar with is to use - and = to avoid having to use a shift key to increase but not decrease the font size. (Plus can only be used with a shift modifier on a US keyboard.)

Perhaps ctrl + '+' should be the primary shortcut and ctrl + '=' be secondary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could work, I'm ccing our UX designer for an advice 🙂 @00alis

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) {
Expand Down