[PR #6537] [MERGED] Add support for running a wt commandline in the curent window WITH A KEYBINDING #26730

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/6537
Author: @zadjii-msft
Created: 6/16/2020
Status: Merged
Merged: 7/17/2020
Merged by: @undefined

Base: masterHead: dev/migrie/f/execute-order-66


📝 Commits (10+)

  • a0f5935 git cherry-pick 2cf69338cd
  • 3fa4687 Whoop, this works for parsing a single command! This code's horribly dirty, but it works
  • beec8d0 do it with multiple args
  • 349a0e6 Cleanup for review
  • fa5ecdf split-pane ; split-pane at runtime doesn't work, pt1
  • 0622233 split-pane ; split-pane at runtime doesn't work, pt2
  • 2221764 This works but it's dirty
  • 030a91a A bunch of cleanup for review
  • c5613b5 more polish for review
  • e1eef62 add tests

📊 Changes

29 files changed (+582 additions, -115 deletions)

View changed files

📝 doc/cascadia/profiles.schema.json (+19 -0)
📝 src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp (+68 -0)
📝 src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp (+53 -0)
📝 src/cascadia/TerminalApp/ActionAndArgs.cpp (+5 -0)
📝 src/cascadia/TerminalApp/ActionArgs.cpp (+14 -0)
📝 src/cascadia/TerminalApp/ActionArgs.h (+34 -0)
📝 src/cascadia/TerminalApp/ActionArgs.idl (+5 -0)
📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+17 -0)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.cpp (+52 -2)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.h (+4 -2)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+4 -51)
📝 src/cascadia/TerminalApp/AppLogic.h (+1 -1)
📝 src/cascadia/TerminalApp/AppLogic.idl (+2 -1)
📝 src/cascadia/TerminalApp/GlobalAppSettings.cpp (+0 -1)
📝 src/cascadia/TerminalApp/Pane.cpp (+97 -0)
📝 src/cascadia/TerminalApp/Pane.h (+3 -1)
📝 src/cascadia/TerminalApp/Resources/en-US/Resources.resw (+4 -0)
📝 src/cascadia/TerminalApp/ShortcutActionDispatch.cpp (+4 -0)
📝 src/cascadia/TerminalApp/ShortcutActionDispatch.h (+1 -0)
📝 src/cascadia/TerminalApp/ShortcutActionDispatch.idl (+3 -1)

...and 9 more files

📄 Description

Summary of the Pull Request

Adds a execute commandline action (wt), which lets a user bind a key to a specific wt commandline. This commandline will get parsed and run in the current window.

References

PR Checklist

  • Closes oh, there's not actually an issue for this.
  • I work here
  • Tests added/passed
  • Requires documentation to be updated - yes it does

Detailed Description of the Pull Request / Additional comments

One important part of this change concerns how panes are initialized at runtime. We've had some persistent trouble with initializing multiple panes, because they rely on knowing how big they'll actually be, to be able to determine if they can split again.

We previously worked around this by ignoring the size check when we were in "startup", processing an initial commandline. This PR however requires us to be able to know the initial size of a pane at runtime, but before the parents have necessarily been added to the tree, or had their renderer's set up.

This led to the development of Pane::PreCalculateCanSplit, which is very highly similar to Pane::PreCalculateAutoSplit. This method attempts to figure out how big a pane will take, before the parent has necessarily laid out.

This also involves a small change to TermControl, because if its renderer hasn't been set up yet, it'll always think the font is {0, fontHeight}, which will let the Terminal keep splitting in the x direction. This change also makes the TermControl set up a renderer to get the real font size when it hasn't yet been initialized.

Validation Steps Performed

This was what the json blob I was using for testing evolved into

        {
            "command": {
                "action":"wt",
                "commandline": "new-tab cmd.exe /k #work 15 ; split-pane cmd.exe /k #work 15 ; split-pane cmd.exe /k media-commandline ; new-tab powershell dev\\symbols.ps1 ; new-tab -p \"Ubuntu\" ; new-tab -p \"haunter.gif\" ; focus-tab -t 0",

            },
            "keys": ["ctrl+shift+n"]
        }

I also added some tests.

TODO

  • Creating a { "command": "wt" } action without a commandline will spawn a new wt.exe process?
    • Probably should just do nothing for the empty string

🔄 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/6537 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 6/16/2020 **Status:** ✅ Merged **Merged:** 7/17/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/migrie/f/execute-order-66` --- ### 📝 Commits (10+) - [`a0f5935`](https://github.com/microsoft/terminal/commit/a0f593535ca930e4412ae20ddfb07470463bc151) git cherry-pick 2cf69338cddb8e7bf1f50235e23a2cf9ae18791d - [`3fa4687`](https://github.com/microsoft/terminal/commit/3fa4687be79d5a2b978c6d2e035c974da14ce982) Whoop, this works for parsing a single command! This code's horribly dirty, but _it works_ - [`beec8d0`](https://github.com/microsoft/terminal/commit/beec8d0fca11173e9ffffa90401edbada7575cd4) do it with multiple args - [`349a0e6`](https://github.com/microsoft/terminal/commit/349a0e6ed939d0377b36bd441f0c5fe46923e2de) Cleanup for review - [`fa5ecdf`](https://github.com/microsoft/terminal/commit/fa5ecdf055d2ba38b21fc37247cee194e445a2ee) `split-pane ; split-pane` at runtime doesn't work, pt1 - [`0622233`](https://github.com/microsoft/terminal/commit/0622233a21af8c596b3c4346246d5319024d06eb) `split-pane ; split-pane` at runtime doesn't work, pt2 - [`2221764`](https://github.com/microsoft/terminal/commit/2221764a3900fecf4724b71370d71a25b49cc620) This works but it's dirty - [`030a91a`](https://github.com/microsoft/terminal/commit/030a91a9c1fa27e7d751576fff9faccd608c54dc) A bunch of cleanup for review - [`c5613b5`](https://github.com/microsoft/terminal/commit/c5613b595ddeca9a8727ee6ca0f7249e658b60b5) more polish for review - [`e1eef62`](https://github.com/microsoft/terminal/commit/e1eef62d4ded79e256144b0cfde018fd358b6147) add tests ### 📊 Changes **29 files changed** (+582 additions, -115 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/profiles.schema.json` (+19 -0) 📝 `src/cascadia/LocalTests_TerminalApp/CommandlineTest.cpp` (+68 -0) 📝 `src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp` (+53 -0) 📝 `src/cascadia/TerminalApp/ActionAndArgs.cpp` (+5 -0) 📝 `src/cascadia/TerminalApp/ActionArgs.cpp` (+14 -0) 📝 `src/cascadia/TerminalApp/ActionArgs.h` (+34 -0) 📝 `src/cascadia/TerminalApp/ActionArgs.idl` (+5 -0) 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+17 -0) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.cpp` (+52 -2) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.h` (+4 -2) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+4 -51) 📝 `src/cascadia/TerminalApp/AppLogic.h` (+1 -1) 📝 `src/cascadia/TerminalApp/AppLogic.idl` (+2 -1) 📝 `src/cascadia/TerminalApp/GlobalAppSettings.cpp` (+0 -1) 📝 `src/cascadia/TerminalApp/Pane.cpp` (+97 -0) 📝 `src/cascadia/TerminalApp/Pane.h` (+3 -1) 📝 `src/cascadia/TerminalApp/Resources/en-US/Resources.resw` (+4 -0) 📝 `src/cascadia/TerminalApp/ShortcutActionDispatch.cpp` (+4 -0) 📝 `src/cascadia/TerminalApp/ShortcutActionDispatch.h` (+1 -0) 📝 `src/cascadia/TerminalApp/ShortcutActionDispatch.idl` (+3 -1) _...and 9 more files_ </details> ### 📄 Description ## Summary of the Pull Request Adds a execute commandline action (`wt`), which lets a user bind a key to a specific `wt` commandline. This commandline will get parsed and run _in the current window_. ## References * Related to #4472 * Related to #5400 - I need this for the commandline mode of the Command Palette * Related to #5970 ## PR Checklist * [x] Closes oh, there's not actually an issue for this. * [x] I work here * [x] Tests added/passed * [ ] Requires documentation to be updated - yes it does ## Detailed Description of the Pull Request / Additional comments One important part of this change concerns how panes are initialized at runtime. We've had some persistent trouble with initializing multiple panes, because they rely on knowing how big they'll actually be, to be able to determine if they can split again. We previously worked around this by ignoring the size check when we were in "startup", processing an initial commandline. This PR however requires us to be able to know the initial size of a pane at runtime, but before the parents have necessarily been added to the tree, or had their renderer's set up. This led to the development of `Pane::PreCalculateCanSplit`, which is very highly similar to `Pane::PreCalculateAutoSplit`. This method attempts to figure out how big a pane _will_ take, before the parent has necessarily laid out. This also involves a small change to `TermControl`, because if its renderer hasn't been set up yet, it'll always think the font is `{0, fontHeight}`, which will let the Terminal keep splitting in the x direction. This change also makes the TermControl set up a renderer to get the real font size when it hasn't yet been initialized. ## Validation Steps Performed This was what the json blob I was using for testing evolved into ```json { "command": { "action":"wt", "commandline": "new-tab cmd.exe /k #work 15 ; split-pane cmd.exe /k #work 15 ; split-pane cmd.exe /k media-commandline ; new-tab powershell dev\\symbols.ps1 ; new-tab -p \"Ubuntu\" ; new-tab -p \"haunter.gif\" ; focus-tab -t 0", }, "keys": ["ctrl+shift+n"] } ``` I also added some tests. # TODO * [x] Creating a `{ "command": "wt" }` action without a commandline will spawn a new `wt.exe` process? - Probably should just do nothing for the empty string --- <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:17:48 +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#26730