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

resize on the pty (almost there) #225

Open
keesj opened this issue Jul 12, 2021 · 1 comment
Open

resize on the pty (almost there) #225

keesj opened this issue Jul 12, 2021 · 1 comment

Comments

@keesj
Copy link

keesj commented Jul 12, 2021

Hi,

Resize is almost working but not quite fully. I am creating a website based in the JS/HTML/CSS code in this repository.
The terminal resizing using jquery (but also when resizing the window) causes calls to pwd.resize. Here I see client that the terminal is resized on the client side and I do not observe any communication to the server (monitoring websockets).

As a result of that the doing something like vim the terminal does not have the correct size. Interestingly enough if I type "resize" in the terminal the correct size is detected. I think that a signal needs to be sent to the backed and a signal need to be send to the PTY process.

Searching for an answer I do see some hints this is indeed what is needed

xtermjs/xterm.js#3092
https://stackoverflow.com/questions/63230001/how-does-sigwinch-pass-through-bash

@keesj
Copy link
Author

keesj commented Jul 12, 2021

More debugging shows the code worked on pwd. I created the following "fix" to send a "instance viewport resize on resize".

diff --git a/src/index.ts b/src/index.ts
index 29e51ee..aa767ff 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -237,10 +237,10 @@ class PWD extends EventEmitter {
         self.instanceBuffer[name] += data;
       }
     });
     // Resize all terminals
     this.socket.on("instance viewport resize", function (cols, rows) {
       // Resize all terminals
       for (var name in self.instances) {
         self.instances[name].terms.forEach(function (term) {
           term.resize(cols, rows);
@@ -286,6 +286,8 @@ class PWD extends EventEmitter {
           if (t.element.clientWidth) {
             t.fitAddon.fit();
           }
+          const dim = t.fitAddon.proposeDimensions();
+          this.socket.emit('instance viewport resize', dim.cols, dim.rows);
         }, 300);
       });
     });

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

No branches or pull requests

1 participant