Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support keybindings for sending custom sequences to the terminal #56024

Closed
Tyriar opened this issue Aug 8, 2018 · 9 comments · Fixed by #56962
Closed

Support keybindings for sending custom sequences to the terminal #56024

Tyriar opened this issue Aug 8, 2018 · 9 comments · Fixed by #56962
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities terminal Integrated terminal issues verification-needed Verification of issue is requested verified Verification succeeded

Comments

@Tyriar
Copy link
Member

Tyriar commented Aug 8, 2018

Example send ctrl+c, up, enter to re-run a command.

@Tyriar Tyriar added feature-request Request for new features or functionality terminal Integrated terminal issues labels Aug 8, 2018
@Tyriar Tyriar added this to the Backlog milestone Aug 8, 2018
@Tyriar Tyriar self-assigned this Aug 8, 2018
@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Aug 8, 2018
@Baitula
Copy link

Baitula commented Aug 9, 2018

Nice

@njkevlani
Copy link
Contributor

I'd like to work on this.

Need some more information.

  1. How user will add new keybindings for "custom sequences to the terminal".
  2. Currently,(as of my knowledge) we can assign keybindings to predefined Actions. How do we emulate terminal key presses with actions?

@Tyriar
Copy link
Member Author

Tyriar commented Aug 14, 2018

@njkevlani cool! Keybindings/commands can have arguments pass to them, we would want to leverage this https://code.visualstudio.com/docs/getstarted/keybindings#_command-arguments, basically we want expose a command similar to MoveToLineEndTerminalAction and its super class BaseSendTextTerminalAction (inside terminalActions.ts)

@njkevlani
Copy link
Contributor

njkevlani commented Aug 15, 2018

Didn't know this till now, good to know :) I'll look into it, put my suggestion/questions and open PR soon!

@njkevlani
Copy link
Contributor

Hey @Tyriar, I've coded a class SendSequenceTerminalCommand that extends Command. It takes user defined arguments from keybindings.json. I have some questions.

  1. What custom sequences are we going to support? Like ctrl+c up enter, ctrl+r ls enter (To ls last lsed directory). What I mean to say is that can you provide more cases like ctrl+c up enter?

  2. Currently, I'm using terminalInstance.sendText multiple time to send a sequence. That is for example ctrl+c up enter goes as

    1. ctrl+c using sendText(String.fromCharCode('C'.charCodeAt(0)) - 64, false)
    2. up + enter using sendText(String.fromCharCode(KeyCode.UpArrow), true)

Is there any better way?

@njkevlani
Copy link
Contributor

Reminder @Tyriar

@Tyriar
Copy link
Member Author

Tyriar commented Aug 20, 2018

@njkevlani I would expect hex to be accepted, for example \x1b is the escape character, as well as the slash key codes like \n, \a, \t, etc. (see https://github.com/xtermjs/xterm.js/blob/0e45909c7e79c83452493d2cd46d99c0a0bb585f/src/common/data/EscapeSequences.ts#L31), the args can contain a string with a bunch of data in it which is sent. So you could for example send "ctrl+c, up, enter", or "hello world" just by tweaking the args on the keybinding.

@Tyriar Tyriar modified the milestones: Backlog, September 2018 Sep 8, 2018
Tyriar added a commit to microsoft/vscode-docs that referenced this issue Sep 8, 2018
@Tyriar Tyriar added the verification-needed Verification of issue is requested label Sep 24, 2018
@Tyriar
Copy link
Member Author

Tyriar commented Sep 24, 2018

Verifier: Please test on Linux or macOS that you can send text and sequences using a keybinding like this:

{ "key": "ctrl+shift+a",           "command": "workbench.action.terminal.sendSequence", "args": { "text": "abc" } },

@njkevlani
Copy link
Contributor

Working on linux. Verified

@roblourens roblourens added the verified Verification succeeded label Sep 26, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities terminal Integrated terminal issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants