Skip to content

Add the ability to select a whole command (or its output)#14807

Merged
zadjii-msft merged 24 commits intomainfrom
dev/migrie/f/4588-select-shell-output
Apr 20, 2023
Merged

Add the ability to select a whole command (or its output)#14807
zadjii-msft merged 24 commits intomainfrom
dev/migrie/f/4588-select-shell-output

Conversation

@zadjii-msft
Copy link
Member

Adds two new commands, selectOutput and selectCommand. 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.

prompt $e]133;D$e\$e]133;A$e\$e\$e]9;9;$P$e\$e[30;107m[$T]$e[97;46m$g$P$e[36;49m$g$e[0m$e[K$_$e[0m$e[94m%username%$e[0m@$e[32m%computername%$e[0m$G$e]133;B$e\

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Feb 7, 2023
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.

Just nits, honestly

@zadjii-msft zadjii-msft added this to the Terminal v1.18 milestone Mar 30, 2023
Copy link
Member

@lhecker lhecker 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 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).

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 11, 2023
@zadjii-msft zadjii-msft removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 19, 2023
@zadjii-msft zadjii-msft merged commit 0e86ce5 into main Apr 20, 2023
@zadjii-msft zadjii-msft deleted the dev/migrie/f/4588-select-shell-output branch April 20, 2023 12:35
void ControlCore::SelectCommand(const bool goUp)
{
const til::point start = HasSelection() ? (goUp ? _terminal->GetSelectionAnchor() : _terminal->GetSelectionEnd()) :
_terminal->GetTextBuffer().GetCursor().GetPosition();
Copy link
Member

Choose a reason for hiding this comment

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

i wonder if this should have anchored near the bottom of the viewport instead - wdyt?

}
}

void ControlCore::SelectOutput(const bool goUp)
Copy link
Member

Choose a reason for hiding this comment

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

these seem to be the same function with a one-line difference

Comment on lines +84 to +85
void SelectCommand(const bool goUp);
void SelectOutput(const bool goUp);
Copy link
Member

Choose a reason for hiding this comment

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

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 },
Copy link
Member

Choose a reason for hiding this comment

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

clever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI to Page / up and down by command + copy all output

4 participants