Add the ability to select a whole command (or its output)#14807
Add the ability to select a whole command (or its output)#14807zadjii-msft merged 24 commits intomainfrom
Conversation
…b.com/microsoft/terminal into dev/migrie/f/4588-select-shell-output
(cherry picked from commit 275f3de)
lhecker
left a comment
There was a problem hiding this comment.
I'm not particularly comfortable with the boolean logic in the loops. I feel like they're fairly hard to understand and reason about. Unless my suggestion is incorrect, I would personally strongly prefer if something that's more arithmetic was used (like in my suggestion).
| void ControlCore::SelectCommand(const bool goUp) | ||
| { | ||
| const til::point start = HasSelection() ? (goUp ? _terminal->GetSelectionAnchor() : _terminal->GetSelectionEnd()) : | ||
| _terminal->GetTextBuffer().GetCursor().GetPosition(); |
There was a problem hiding this comment.
i wonder if this should have anchored near the bottom of the viewport instead - wdyt?
| } | ||
| } | ||
|
|
||
| void ControlCore::SelectOutput(const bool goUp) |
There was a problem hiding this comment.
these seem to be the same function with a one-line difference
| void SelectCommand(const bool goUp); | ||
| void SelectOutput(const bool goUp); |
There was a problem hiding this comment.
IMO these two names are too generic for the "public" interface of TermControl, and should be made more specific. SelectMarkedCommand or SelectMarkedOutput or something (though, mark mode makes the distinction confusing)
| { ShortcutAction::AdjustFontSize, RS_(L"AdjustFontSizeCommandKey") }, | ||
| { ShortcutAction::CloseOtherPanes, RS_(L"CloseOtherPanesCommandKey") }, | ||
| { ShortcutAction::CloseOtherTabs, L"" }, // Intentionally omitted, must be generated by GenerateName | ||
| { ShortcutAction::CloseOtherTabs, MustGenerate }, |
Adds two new commands,
selectOutputandselectCommand. These don't do much without shell integration enabled, unfortunately. If you do enable it, however, you can use these commands to quickly navigate the history to select whole commands (or their output).Some sample JSON:
{ "keys": "ctrl+shift+<", "command": { "action": "selectCommand", "direction": "prev" } }, { "keys": "ctrl+shift+>", "command": { "action": "selectCommand", "direction": "next" } }, { "keys": "ctrl+shift+[", "command": { "action": "selectOutput", "direction": "prev" } }, { "keys": "ctrl+shift+]", "command": { "action": "selectOutput", "direction": "next" } },Demo gifs in #4588 (comment)
closes #4588
Tested manually.
CMD.exe user? It's dangerous to go alone! Take this.
Surely, there's a simpler way to do it, this is adapted from my own script.