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 keyboard shortcuts to increase and decrease font size #2700

Merged
merged 5 commits into from
Sep 30, 2019

Conversation

dsafa
Copy link
Contributor

@dsafa dsafa commented Sep 9, 2019

Summary of the Pull Request

This hooks up the already existing shortcut actions for increasing and decreasing font size so that keyboard shortcuts can be used. Also adds default shortcuts ctrl+= and ctrl+- for increasing and decreasing font size.

References

A previous PR was done for this feature but was closed and never completed: #1740 . This is a continuation of that work.

PR Checklist

  • Closes Add keyboard shortcuts to increase and decrease font size (or zoom) #1708
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed. No new tests added
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

There were already actions increaseFontSize and decreaseFontSize that existed but without anything to handle them. The handler shares existing functionality for adjusting font size that already exists with ctrl and scrolling.

Validation Steps Performed

  1. Add keybindings to profiles.json for decreaseFontSize and increaseFontSize
  2. Verified that both keybindings work.
  3. Verified that ctrl + scrolling still works.

1. Delete profiles.json and let terminal generate a default one.
2. Verified that the default keybindings are created. No longer needed with defaults.json

@dsafa
Copy link
Contributor Author

dsafa commented Sep 9, 2019

I've combined the IncreaseFontSize and DecreaseFontSize events into a AdjustFontSize event and added a AdjustfontSizeArgs that contains the delta.

@mdtauk
Copy link

mdtauk commented Sep 10, 2019

Does the feature get called Font Size, or would it be Zoom?

@dsafa
Copy link
Contributor Author

dsafa commented Sep 10, 2019

Thats a good question. I just left it as font size since that is how zooming works for the terminal control. I know there's future plans to possibly support non terminal panes so maybe zoom would be a better term.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

I'm a tiny bit worried about the choice of default keybinding here - ctrl+shift+plus/ctrl+shift+minus might be better.

Otherwise, lets just get the merge fixed and lets :shipit:

@@ -398,6 +398,13 @@ void CascadiaSettings::_CreateDefaultKeybindings()
keyBindings.SetKeyBinding(ShortcutAction::SwitchToTab8,
KeyChord{ KeyModifiers::Alt | KeyModifiers::Ctrl,
static_cast<int>('9') });

keyBindings.SetKeyBinding(ShortcutAction::IncreaseFontSize,
Copy link
Member

Choose a reason for hiding this comment

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

My only reservation is that as of #2515, the default keybindings aren't set here anymore. They should instead be included in src\cascadia\TerminalApp\defaults.json

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting conundrum here @zadjii-msft. To adjust text size / zoom using the mouse is ctrl + scroll. It would therefore, make sense if zoom via the keyboard was also ctrl + +/-.

What would also make THAT even more consistent with mouse scroll actions was if also ctrl + shift + +/- adjusted blur, but I may be pushing my luck here ... or am I? 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

So, it looks like there's no VT encoding for Ctrl-+, so it's free to be bound! Problem, though: Ctrl+- emits ^_.
We also do need to be considerate of the fact that + is Shift+-...
Perhaps we should follow suit with other zoomable things and make Ctrl+= the "zoom in" binding?

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. Ctrl+Shift+- emits ^_ in putty and conhost, but Ctrl+- only emits ^_ in putty. Perhaps the right behavior is that Ctrl alone doesn't do anything and is free to be bound for both?

Copy link
Contributor

Choose a reason for hiding this comment

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

So, like this then?

Key Chord Keys + Mouse Action
ctrl + =/- ctrl + mouse scroll up/down Zoom in/out
ctrl+shift + +/_ ctrl + shift + mouse scroll up/down Blur more/less

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the bindings to defaults.json as

{ "command": "decreaseFontSize", "keys": ["ctrl+-"] },
{ "command": "increaseFontSize", "keys": ["ctrl+="] }

If a different default is decided I'll be happy to change it.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

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

A comment indicating the requested changes.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

I don't want to block on a simple tabs-> spaces thing, but this is the only nit preventing me from signing off.

@@ -209,6 +209,8 @@
{ "command": "switchToTab5", "keys": ["ctrl+alt+6"] },
{ "command": "switchToTab6", "keys": ["ctrl+alt+7"] },
{ "command": "switchToTab7", "keys": ["ctrl+alt+8"] },
{ "command": "switchToTab8", "keys": ["ctrl+alt+9"] }
{ "command": "switchToTab8", "keys": ["ctrl+alt+9"] },
{ "command": "decreaseFontSize", "keys": ["ctrl+-"] },
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ "command": "decreaseFontSize", "keys": ["ctrl+-"] },
{ "command": "decreaseFontSize", "keys": ["ctrl+-"] },

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Shouldn't have to tell me this 😅. Fixed.

{ "command": "switchToTab8", "keys": ["ctrl+alt+9"] }
{ "command": "switchToTab8", "keys": ["ctrl+alt+9"] },
{ "command": "decreaseFontSize", "keys": ["ctrl+-"] },
{ "command": "increaseFontSize", "keys": ["ctrl+="] }
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{ "command": "increaseFontSize", "keys": ["ctrl+="] }
{ "command": "increaseFontSize", "keys": ["ctrl+="] }

@andrp92
Copy link

andrp92 commented Sep 29, 2019

So, is this ready to be merge?

@zadjii-msft zadjii-msft merged commit 083be43 into microsoft:master Sep 30, 2019
@bitcrazed
Copy link
Contributor

@dsafa - Thanks soooo much for implementing this feature :) Been wanting to get around to doing this myself - glad you got there first 😁

DHowett-MSFT pushed a commit that referenced this pull request Oct 3, 2019
@ghost
Copy link

ghost commented Oct 23, 2019

🎉Windows Terminal Preview v0.6.2951.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add keyboard shortcuts to increase and decrease font size (or zoom)
7 participants