Skip to content
New issue

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

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

Already on GitHub? # to your account

Support to capture terminal contents #13085

Closed
Tracked by #13192
kavitha-subr opened this issue Nov 21, 2023 · 5 comments
Closed
Tracked by #13192

Support to capture terminal contents #13085

kavitha-subr opened this issue Nov 21, 2023 · 5 comments
Assignees
Labels
terminal issues related to the terminal

Comments

@kavitha-subr
Copy link

Feature Description:

As a developer, I would like the ability to capture the contents of the terminal so that I can identify errors and warnings for further action.
Currently, the only possible way to get terminal contents is to spawn a new terminal and have an event listener listen to the output data. I would like to have this feature without having to create a new terminal.

@tsmaeder
Copy link
Contributor

Would something like this work?

    export interface TerminalObserver {

        /**
         * A regex to match against the latest terminal output.
         */
        readonly outputMatcherRegex: string;
        /**
         * The maximum number of lines to match the regex against. Maximum is 40 lines.
         */
        readonly nrOfLinesToMatch: number;
        /**
         * Invoked when the regex matched against the terminal contents.
         * @param groups The matched groups
         */
        matchOccurred(groups: RegExpMatchArray): void;
    }

    export namespace window {
        export function registerTerminalObserver(observer: TerminalObserver): void;
    }

@kavitha-subr
Copy link
Author

Yup, this looks great!

@tsmaeder
Copy link
Contributor

I've made a branch at https://github.com/tsmaeder/theia/tree/13085_terminal_observer with the necessary changes. Here's the source for a plugin using the API:

terminalobserver.zip

@tsmaeder
Copy link
Contributor

To test, you'll have to build & run theia from the branch. To build the plugin, you will have to yarn link the @theia/plugin package. In order to do so, you have to

  1. go into the <theia>/packages/plugin folder and type yarn link
  2. go in the root folder of the example plugin source and type 'yarn link @theia/plugin`

Then you can just build the plugin and copy the resulting *.theia file into the theia plugins folder.

@kavitha-subr
Copy link
Author

Thank you so much! I'll verify if everything works as expected.

@tsmaeder tsmaeder added the terminal issues related to the terminal label Feb 19, 2024
@tsmaeder tsmaeder self-assigned this Feb 28, 2024
@JonasHelming JonasHelming mentioned this issue Apr 1, 2024
67 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
terminal issues related to the terminal
Projects
None yet
Development

No branches or pull requests

3 participants