Skip to content

Ability to save selected text as a sendInput action #12857

@zadjii-msft

Description

@zadjii-msft

I write some long command. I need to use this frequently (or infrequently), but I don't want to have to remember all the args. I want to be able to pull it up straight from the command palette. So I want to write the command once, select it, and {perform some action}1 that lets me save it as a sendInput action.

The action should

  • immediately save it.
  • provide a UI2 for immediately editing3 the name, contents of this action, because Send "git log --graph --abbrev-commit --decorate..." to the Terminal is not useful to anyone.

Just doing the immediate save would be a good enough start on this, to the point I'd consider that an easy starter. The UI - that's Hard, for reasons listed below.

Note

Walkthrough

As an initial version of this, it's more than good enough to just save the selected text as an action without the UI. We can iterate on the UI in follow-ups.

  • Probably start with something like dev/migrie/fhl/save-command
  • We probably want to skip all the AppCommandlineArgs stuff for now. That's spicier.
  • in TerminalPage::_HandleSaveTask, we will want to try and save the current selection as a sendInput action, if there's no commandline specified.
  • AppActionHandlers.cpp has plenty of examples of getting the active control. Should be easy enough to get the selected text from it.
  • We'll probably want to generate the name of this action (without a commandline) as "Save Task..."
  • Over and above: It would be valuable to Toast the user with a message "Saved selected text as a new action". TerminalPage::IdentifyWindow has an example of a Toast

Footnotes

  1. Obviously, easiest way is via cmdpal or keybinding. Also consider a right-click context menu entry, Request: Right-click menu inside TerminalControl (w/ Copy & Paste?) #3337

  2. This has it's own challenges. It can't be a ContentDialog (https://github.com/microsoft/microsoft-ui-xaml/issues/3804). It could be nested in a Flyout, maybe. Hopefully the dialog thing is limited just to ContentDialogs and not all Flyouts. It probably shouldn't be a TeachingTip (Auto-focus window renamer textbox on open #12798). We could roll our own ContentDialog for this of course (Warn before the user runs a new commandline elevated #11308).

  3. Might be tricky - we'd have to hand on to an instance of the actual Command itself, so we can edit it... in place? and hopefully writing to the settings would then just refresh all the other name->command maps instantly.

Metadata

Metadata

Assignees

Labels

Area-SettingsIssues related to settings and customizability, for console or terminalHelp WantedWe encourage anyone to jump in on these.In-PRThis issue has a related PRIssue-TaskIt's a feature request, but it doesn't really need a major design.Needs-Tag-FixDoesn't match tag requirementsProduct-TerminalThe new Windows Terminal.good first issueThis is a fix that might be easier for someone to do as a first contribution

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions