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

Hook up the keybindings to the SUI, redux #10121

Merged
4 commits merged into from
May 24, 2021
Merged

Hook up the keybindings to the SUI, redux #10121

4 commits merged into from
May 24, 2021

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

This is a redux of #8882.

From the original:

This is really similar to what we're doing with the CommandPalette. We're adding a PreviewKeyDown handler to the SUI MainPage, that connects to TerminalPage::_HandleKey. That allows the SUI a chance to search the keymap to dispatch actions for keybindings, similar to how the command palette does it.

This also means it's now possible for the SUI to invoke all the actions available to the Terminal. This includes the ones like IncreaseFontSize, which require a Terminal to actually do something. So we have to make sure all the calls to _GetActiveControl actually check that the result is non-null before using it.

A bunch of the actions do nothing now from a SUI tab, others behave weird. Like "Rename tab" / "Open Tab Renamer" do nothing. "Duplicate Tab" again does nothing - we try making a new settings tab, which just focuses the settings tab again. "Copy text" definitely does nothing, same with paste.

I don't know why I thought this wouldn't work. I thought we'd have to do this in PreviewKeyDown or something, which led to weirdness. Turns out, we don't need it to be in PreviewKeyDown. It can just be in the SUI's KeyDown.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

The special case handler from #8885 is no longer needed

Validation Steps Performed

  • Switching tabs with Ctrl+Tab works
  • Command palette works
  • fullscreen, focus mode works
  • close window works
  • copy paste on Ctrl+C/V works, even when bound
  • Select all text in textboxes works
  • tab navigation through UI elements works

@ghost ghost added Area-Settings UI Anything specific to the SUI Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. labels May 18, 2021
@DHowett
Copy link
Member

DHowett commented May 19, 2021

This is in selfhost today.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

huh, I can't remember why we didn't do this. I bet we'll find out and it will be catastrophic. 😄

@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label May 21, 2021
@DHowett
Copy link
Member

DHowett commented May 24, 2021

@carlos-zamora can you circle up on this?

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

LOVE IT! Tested it locally and it works well. Specifically kept an eye out for...

  • does "ctrl+c/v/a" still go through to the textbox when it's bound?

The only complaint I have is that the command palette is filled with some actions that don't do anything (i.e. "split pane"). It'd be nice to filter out the ones that don't do anything, but that's definitely complicated enough to be a follow-up. Mind filing that?

Comment on lines -2337 to +2323
sui.PreviewKeyDown({ this, &TerminalPage::_SUIPreviewKeyDownHandler });
// GH#8767 - let unhandled keys in the SUI try to run commands too.
sui.KeyDown({ this, &TerminalPage::_KeyDownHandler });
Copy link
Member

Choose a reason for hiding this comment

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

FYI: this seems like it was the only difference from #8882. We're doing a sui.KeyDown instead of a sui.PreviewKeyDown. That's probably why key chords like ctrl+c were being eaten by us instead of XAML controls (like text boxes).

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label May 24, 2021
@ghost
Copy link

ghost commented May 24, 2021

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 52560ff into main May 24, 2021
@ghost ghost deleted the dev/migrie/8767-take-two branch May 24, 2021 19:18
@zadjii-msft
Copy link
Member Author

does "ctrl+c/v/a" still go through to the textbox when it's bound?

yeppers

It'd be nice to filter out the ones that don't do anything, but that's definitely complicated enough to be a follow-up. Mind filing that?

-> #10169

@DHowett
Copy link
Member

DHowett commented May 24, 2021

There's enough user DSAT around this that I am backporting it into 1.8. We'll see how that goes!

DHowett pushed a commit that referenced this pull request May 24, 2021
## Summary of the Pull Request

This is a redux of #8882.

From the original:

>  This is really similar to what we're doing with the `CommandPalette`. We're adding a ~~Preview~~`KeyDown` handler to the SUI `MainPage`, that connects to `TerminalPage::_HandleKey`. That allows the SUI a chance to search the keymap to dispatch actions for keybindings, similar to how the command palette does it.
>
> This also means it's now possible for the SUI to invoke _all_ the actions available to the Terminal. This includes the ones like `IncreaseFontSize`, which require a _Terminal_ to actually do something. So we have to make sure all the calls to `_GetActiveControl` actually check that the result is non-null before using it.
>
> A bunch of the actions do nothing now from a SUI tab, others behave _weird_. Like "Rename tab" / "Open Tab Renamer" do nothing. "Duplicate Tab" again does nothing - we try making a new settings tab, which just focuses the settings tab again. "Copy text" definitely does nothing, same with paste.

I don't know why I thought this wouldn't work. I thought we'd have to do this in `PreviewKeyDown` or something, which led to [weirdness](#8882 (comment)). Turns out, we don't need it to be in `PreviewKeyDown`. It can just be in the SUI's `KeyDown`.

## References
* Original: #8882
* Workaround was in #8885

## PR Checklist
* [x] Closes #8767
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

The special case handler from #8885 is no longer needed

## Validation Steps Performed

* Switching tabs with Ctrl+Tab works
* Command palette works
* fullscreen, focus mode works
* close window works
* copy paste on Ctrl+C/V works, even when bound
* Select all text in textboxes works
* tab navigation through UI elements works

(cherry picked from commit 52560ff)

# Conflicts:
#	src/cascadia/TerminalApp/TerminalPage.cpp
#	src/cascadia/TerminalApp/TerminalPage.h
@ghost
Copy link

ghost commented May 25, 2021

🎉Windows Terminal v1.8.1444.0 has been released which incorporates this pull request.:tada:

Handy links:

@ghost ghost mentioned this pull request May 25, 2021
@ghost
Copy link

ghost commented May 25, 2021

🎉Windows Terminal Preview v1.9.1445.0 has been released which incorporates this pull request.:tada:

Handy links:

@tabedzki
Copy link

Thanks @DHowett and @zadjii-msft for working on this issue and fixing it. It works on the download from the msft store.
Just curious, what tools did you guys use to generate your avatar? Changing from the default github icon is a good idea

@zadjii-msft
Copy link
Member Author

I uh, drew it in paint.net IIRC 😆. Either paint.net or some other sprite editor that I've long since forgotten

@DHowett
Copy link
Member

DHowett commented May 26, 2021

@tabedzki I made mine at "FaceYourManga", which is pretty much an RPG character builder but for tiny avatar images

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings UI Anything specific to the SUI AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Second It's a PR that needs another sign-off Priority-1 A description (P1) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make SettingsTab respect keybindings
4 participants