[PR #10121] [MERGED] Hook up the keybindings to the SUI, redux #27905

Open
opened 2026-01-31 09:25:03 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10121
Author: @zadjii-msft
Created: 5/18/2021
Status: Merged
Merged: 5/24/2021
Merged by: @undefined

Base: mainHead: dev/migrie/8767-take-two


📝 Commits (4)

  • f6898bc That was suspiciously easy
  • c27b17c take one down, pass it around, 137 bugs on the wall
  • aebff36 Huh, this works shockingly well
  • 958d115 remove dead code

📊 Changes

3 files changed (+41 additions, -48 deletions)

View changed files

📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+20 -12)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+21 -35)
📝 src/cascadia/TerminalApp/TerminalPage.h (+0 -1)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/10121 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 5/18/2021 **Status:** ✅ Merged **Merged:** 5/24/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/8767-take-two` --- ### 📝 Commits (4) - [`f6898bc`](https://github.com/microsoft/terminal/commit/f6898bcf13798471f952053455b677c96f6e0937) That was suspiciously easy - [`c27b17c`](https://github.com/microsoft/terminal/commit/c27b17cc518e69ae3b1643c4502396a8e0cf7aac) take one down, pass it around, 137 bugs on the wall - [`aebff36`](https://github.com/microsoft/terminal/commit/aebff364006696694e08c8bff9cf5c69f12fb1e9) Huh, this works shockingly well - [`958d115`](https://github.com/microsoft/terminal/commit/958d1157867a41821d19bb7604e8fe63e6ab2031) remove dead code ### 📊 Changes **3 files changed** (+41 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+20 -12) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+21 -35) 📝 `src/cascadia/TerminalApp/TerminalPage.h` (+0 -1) </details> ### 📄 Description ## 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](https://github.com/microsoft/terminal/pull/8882#issuecomment-767088554). 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:25:03 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27905