xtermjs / xterm.js

A terminal for the web
https://xtermjs.org/
MIT License
17.33k stars 1.61k forks source link

expose API method for writing to application side #4948

Closed jerch closed 6 months ago

jerch commented 7 months ago

Coming from #4220 and this comment https://github.com/xtermjs/xterm.js/pull/4220#issuecomment-1793095087

It would be nice to have a method to write to application side from xterm.js' API. Internally xterm.js uses this.coreService.triggerDataEvent for this, which can easily be exposed at the API as well.

interface suggestion

  export class Terminal implements IDisposable {
    ...
    /**
     * Input data to application side.
     * The data is treated the same way as typed input at the terminal (will appear in the onData event).
     */
    input(data: string): void;
    ...
}

Such a method would help to automate data input programmatically, e.g. from the clipboard addon w'o hooking into hidden internals.

Tyriar commented 7 months ago

I like it 👍

jerch commented 7 months ago

@Tyriar I'd also need this for my proposal in #4943, but thats still at a very early stage... :sweat_smile: