Skip to content

Terminal: provide an action to clear the terminal #6603

Closed

Description

Similar to the output panel would be nice to have an action top right to clear the terminal contents.

Activity

  1. added
    feature-request
    on May 21, 2016
  2. added
    terminal
    on May 21, 2016
  3. Tyriar commented on Jun 30, 2016

    @Tyriar
    Contributor

    This will probably involve sending a particular key sequence to the xterm object.

  4. chrmarti commented on Jul 11, 2016

    @chrmarti
    Collaborator

    The following clears the terminal with two (related) issues:

    • There will be no prompt after clearing (like: bash-3.2$ )

    • Clearing while running something like vim or top will leave the terminal unusable.

      const esc = String.fromCharCode(27);
      this.xterm.write(${esc}[H${esc}[2J);

    I'd suggest to not implement this and rely on the shell's built-in clearing (like clear in bash).

  5. Tyriar commented on Jul 11, 2016

    @Tyriar
    Contributor

    How about calling into eraseInDisplay with Erase All arguments?

  6. chrmarti commented on Jul 11, 2016

    @chrmarti
    Collaborator

    That's what esc[2J does. esc[H additionally positions the caret in the top left corner. The problem remains that we don't know in what context we clear the terminal and therefore don't know how to properly prompt for input or if we even should clear the terminal in the first place.

  7. Tyriar commented on Jul 11, 2016

    @Tyriar
    Contributor

    You're right, I still think this should be done but it will need to be done upstream xtermjs/xterm.js#173

  8. added
    upstream
    on Jul 11, 2016
  9. chrmarti commented on Jul 11, 2016

    @chrmarti
    Collaborator

    There is a CSI code to lookup the current cursor position. That and a few others could potentially be used to delete all lines except the current one.

  10. Tyriar commented on Jul 11, 2016

    @Tyriar
    Contributor

    Exposing this in upstream would make things a lot more convenient for consumers, all they will need to do it xterm.clear() then. It should also be much safer since eraseInDisplay should really not be exposed, also sending key codes will fail if the terminal is currently executing a process.

  11. Tyriar commented on Sep 17, 2016

    @Tyriar
    Contributor

    Added the API in upstream and implemented the command. The ⌘K keybinding on mac is still blocked by #12187

  12. removed
    upstream
    on Sep 17, 2016
  13. Tyriar commented on Sep 25, 2016

    @Tyriar
    Contributor

    Moved the keybinding to #12585 as it's not going to land for Sept.

  14. locked and limited conversation to collaborators on Nov 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requestterminal

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions