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

macOS: Cmd + Shift + Plus should increase font size too #3899

Open
mitchellh opened this issue Dec 29, 2024 · 19 comments
Open

macOS: Cmd + Shift + Plus should increase font size too #3899

mitchellh opened this issue Dec 29, 2024 · 19 comments
Labels
contributor friendly A well-scoped, approachable issue for someone looking to contributor. gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos

Comments

@mitchellh
Copy link
Contributor

Discussed in #3888

Originally posted by thiagowfx December 29, 2024
Out-of-the-box, the shortcut to increase/decrease font sizes in Ghostty on macOS is Cmd + + and Cmd + -, respectively (no Shift).

With Shift:

Observed: Cmd + Shift + + inserts a literal '+', and Cmd + Shift + - decreases the font size.

Expected: Cmd + Shift + + should increase the font size as well, consistently.

Why is the behavior for Cmd + Shift + + different? This seems unintentional.

Note that this is the out-of-the-box behavior in both Terminal.app and iTerm2.

@mitchellh mitchellh added contributor friendly A well-scoped, approachable issue for someone looking to contributor. gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos labels Dec 29, 2024
@mitchellh
Copy link
Contributor Author

Note: the solution here doesn't appear on the surface to be a missing binding (but may be). Some research is required why cmd+shift+- works but not plus on macOS currently.

@alexhollinghead
Copy link

I'm not able to reproduce this on 15.1 Sequoia; both CMD + Shift + + and CMD + Shift + - adjust the font size for me. I do already have font size manually configured in my config file. Could this account for your issue?

@curtbushko
Copy link
Collaborator

I can reproduce this on Sequoia 15.2.

Cmd + Shift + + gives me = in my shell.
Cmd + Shift + - reduces the font size.

From: Mac keyboard shortcuts

Shift–Command–Minus sign (-): Decrease the size of the selected item.

Shift–Command–Plus sign (+): Increase the size of the selected item. Command–Equal sign (=) performs the same function.```

Also, the Cmd + Shift shortcuts are not listed in the Apple Terminal guide

@mdznr
Copy link

mdznr commented Dec 30, 2024

You should be able to just set ⌘+ as the menu item’s key equivalent and AppKit will do the keyboard localization for you for this well-known key equivalent. This is inspectable in other apps that have similar menu items (Safari, TextEdit, Preview, Terminal, and others).

I verified locally that removing:

    try result.keybind.set.put(
        alloc,
        .{ .key = .{ .translated = .equal }, .mods = inputpkg.ctrlOrSuper(.{}) },
        .{ .increase_font_size = 1 },
    );

from src/config/Config.zig:2052 and adding:

        GHOSTTY_KEY_PLUS: "+",

to macos/Sources/Ghostty/Ghostty.Input.swift:150 resolves the issue on macOS.
I have not inspected/tested the impact of this on other platforms, though.

@curtbushko
Copy link
Collaborator

@mdznr I tried that out and it didn't work for me. Command + Shift + plus just gives me + in the terminal.

Here is my diff:

Image

@curtbushko
Copy link
Collaborator

Give this a try and see if it works for you.

Image

@mateossh
Copy link

@curtbushko your change fixes issue with shortcut, but there's still something wrong. While testing I noticed that shortcut isn't associated with "increasing font" action in menu bar.

Image

@curtbushko
Copy link
Collaborator

curtbushko commented Dec 31, 2024

@mateossh Interesting. I have Increase Font Size Command =. Even using the default ghostty config I get this. I am using a M1 laptop and I wonder if it is different because of the built in keyboard.

What version of Mac are you on?
Does your regular/downloaded copy of ghostty have the same problem?

@mateossh
Copy link

I ran ghostty +show-config --default --docs > ~/.config/ghostty/config when started using Ghostty, but didn't change any keybind.

Without config file I have the same behavior as you but with default config applied I don't have shortcut.

Ghostty 2f6860fb on M3 MacBook Pro with ANSI keyboard, Mac OS Sequoia 15.2.

@curtbushko
Copy link
Collaborator

Awesome. Thank you. We must have 2 semi-related bugs here.

@jcollie
Copy link
Collaborator

jcollie commented Dec 31, 2024

I ran ghostty +show-config --default --docs > ~/.config/ghostty/config when started using Ghostty, but didn't change any keybind.

This is not how we recommend configuring Ghostty as there are a number of ways that this can mess up. Try removing everything except the configuration entries that you changed and try again.

@maranix
Copy link

maranix commented Jan 1, 2025

Same for meCmd + Shift + Plus doesn't work on Sequoia 15.2 but Cmd + Shift + Minus works.

However, Cmd + = and Cmd + - does increase and decrease the font sizes.

@peterjc
Copy link
Contributor

peterjc commented Jan 1, 2025

You probably don't need any more confirmation, but me too on macOS Sequoia 15.2 with a non-US layout.

Specifically with a Japanese MacBook Air and the builtin keyboard. Note here plus is shift+semi-colon, the key right of letter l, and unlike the US or UK layout, minus and equals are the same key, minus+shift gives equals):

Ghosty v1.0.1 with Apple Japanese keyboard:

  • command+minus works to shrink the font size
  • command+zero works to reset the font size
  • command+shift+semi-colon (i.e. command+plus) types a plus sign.
  • command+shift+minus (i.e. command+equals) enlarges the font

i.e. This works as per the built-in menu shortcut labels, but is missing the command+plus behaviour which the Apple Terminal has:

Apple Terminal with Apple Japanese keyboard:

  • command+minus works to shrink the font size
  • command+zero works to reset the font size
  • command+shift+semi-colon (i.e. command+plus) enlarges the font
  • command+semi-colon also enlarges the font
  • command+shift+minus (i.e. command+equals) just beeps

Also, I thought it worth mentioning the plus/minus keys on the number-pad ought to work too - with an external Windows style USB keyboard and Ghosty v1.0.1, I can use Windows+num-pad-minus to shrink the text, and Windows+num-pad-zero to reset the size, but not the Windows+num-pad-plus to increase the text (which works in Apple Terminal).

@bennettp123
Copy link

bennettp123 commented Jan 2, 2025

FWIW, this works as expected for me on macOS 15.2 with Ghostty v1.0.1:

keybind = super+shift+plus=increase_font_size:1

With this enabled, cmd+shift+plus increases font size, otherwise it just prints a + character. I haven't disabled or replaced any other keybinds.

Not sure why this works when the defaults don't—+ is produced by shift+=, so super+plus should be the same as super+shift+plus (the extra shift is redundant).

But I'm happy to use this keybind as a workaround. 👍🏻

@peterjc
Copy link
Contributor

peterjc commented Jan 3, 2025

Good news, this works with the main keyboard's plus key:

keybind=super+shift+plus=increase_font_size:1

Bad news, it does not work with the numpad's plus on my external keyboard. So only a partial workaround for me.

@mitchellh
Copy link
Contributor Author

Bad news, it does not work with the numpad's plus on my external keyboard. So only a partial workaround for me.

That's a separate key: kp_add

@peterjc
Copy link
Contributor

peterjc commented Jan 3, 2025

Thanks! Add rather than plus, that's why I couldn't find it in https://github.com/ghostty-org/ghostty/blob/v1.0.1/src/input/key.zig (I did find a couple of typos - PR submitted) - this works for me:

keybind=super+kp_add=increase_font_size:1

@CanRau
Copy link

CanRau commented Jan 15, 2025

No idea why I've got it mapped to cmd+= I'm on Sequoia 15.2 & ghostty 1.0.1

Image

@peterjc
Copy link
Contributor

peterjc commented Feb 21, 2025

@CanRau on many layouts "+" is shift+"=" (they are the same key on the UK layout for example), so the shortcut is in fact command+"=" and typically command+shift+"=" works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly A well-scoped, approachable issue for someone looking to contributor. gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos
Projects
None yet
Development

No branches or pull requests

10 participants