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

re-create term obj ,no mouse event repsoned. Is there some re-enter limitation existed in xterm.js #5161

Open
wellcomez opened this issue Sep 19, 2024 · 3 comments

Comments

@wellcomez
Copy link

wellcomez commented Sep 19, 2024

Details

  • Browser and browser version: chrome 127.0.6533.99
  • OS version: linux
  • xterm.js version: 5.5.0

Steps to reproduce

  1. clear and close term obj
  • xterm.js and add-on
   <script src="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/xterm.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/css/xterm.min.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/addon-webgl.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@xterm/[email protected]/lib/addon-fit.min.js"></script>
  • clean code
//clean object
        this.term.clear();
        this.term.dispose();
        this.term.reset()
//remove node
        let terminalContainer = document.getElementById('terminal');
        let parent = terminalContainer.parentElement;
        terminalContainer.remove();
        terminalContainer = document.createElement('div');
        terminalContainer.id = "terminal";
  1. Then create obj again
    let term = new Terminal({
        allowProposedApi: true,
        cursorStyle: 'bar',  
        allowTransparency: true,
        cursorBlink: false,
        cursorWidth: 4,
        rows: rows,
        cols: cols,
        vt200Mouse: true,
        x10Mouse: true,
        vt300Mouse: true,
        MouseEvent: true,
        fontSize: fontSize,
        // fontFamily: 'SymbolsNerdFontMono "Fira Code", courier-new, courier, monospace, "Powerline Extra Symbols"',
        // fontFamily: 'Hack, "Fira Code", monospace',
        // fontFamily: 'HackNerdFontMono,monospace'
        fontFamily: 'SymbolsNerdFontMono,courier-new, courier, monospace'

        // minimumContrastRatio: 1,
    });
  1. term key event still ok but mouse event not
  2. About mouse support

After I read and trace xterm.js, it will be enable after v100/drag protocol is registered .
First time create term object , register will be called but second time not.
So I wonder whether there are global variables existed which prevent call re-enter

@jerch
Copy link
Member

jerch commented Sep 19, 2024

So I wonder whether there are global variables existed which prevent call re-enter

I dont think so, if there is, than it is prolly a dangling listener, that should have been disposed.

Its not clear, what you do on initial startup, because none of the mouse tracking protocols are active on startup by default. There has to be some payload triggering a mouse tracking sequence. Otherwise mouse tracking is always off after startup.

@Tyriar
Copy link
Member

Tyriar commented Sep 20, 2024

        //clean object
        this.term.clear();
        this.term.dispose();
        this.term.reset()

term.dispose() is all you need here, dispose is for when you want to dispose the object and all its components and never use it again. clear clears the buffer (keeps modes, etc.), reset resets it to a clean slate (similar to calling dispose and new Terminal).

@wellcomez
Copy link
Author

        //clean object
        this.term.clear();
        this.term.dispose();
        this.term.reset()

term.dispose() is all you need here, dispose is for when you want to dispose the object and all its components and never use it again. clear clears the buffer (keeps modes, etc.), reset resets it to a clean slate (similar to calling dispose and new Terminal).

It looks , necessary function is called, is there any other step should be done ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@Tyriar @wellcomez @jerch and others