3

Rephrasing my issue here.

I have a web-app using 'xterm.js', 'ws', and 'ssh2' node modules. Everything works great. Except one thing:

SIGWINCH window resize signal won't make it to the sshd server, or the ssh2 stream. Other sigs, esc, ansi work fine. Esc[8 just disappears.

In a real xterm, echo -e "\e[8;30;120t" resizes the terminal on both ends. Not here. sock.send("\u001b[8;30;120t") won't do anything either.

Console.log on the my node app server shows Escape[8 (or \e, \u001b, or \x1b) doesn't make it. Other escape codes work-- arrows, mouse-clicks etc.

I can do term.resize(x,y) on the client, but currently have to use stty on the server. Ssh2's pty sets them at login only. How do I propagate SIGWINCH? Where is it being trapped?

jdmayfield
  • 1,400
  • 1
  • 14
  • 26

1 Answers1

3

Ok. So my own answer to this question: In the browser, use term.resize(cols,rows) to resize the local terminal. Transmit the cols and rows via the ansi escape sequence over websocket. Then, on the node server app, in the ssh2 client, use Regexp to match resize escape sequence and extract the second and third numbers, which are the number of cols and rows (the '8' is the code for resize). Use the ssh2 client resize function with extracted cols and rows (tells the ssh2 psuedoterminal to send sigwinch and cols/rows to the ssh server). Not ideal, I know there is a better way if I could find it, but it works beautifully if you make a function in the browser for it and add it to an event listener for window resize. Now my terminal session will resize appropriately on both the client and server ends when I resize the browser window, or when the soft keyboard pops up or hides on mobile.

jdmayfield
  • 1,400
  • 1
  • 14
  • 26
  • Sorry, didn't mean to answer with a question. In terms of source, mostly just working parts to answer questions on Stack. As far as the end product, I have a site with several webapps (including the http/s server as well). I don't generally share them out publicly as yet, but I do use them regularly for actual work. I am trying to contribute some code to the xtermjs project itself though-- basically the touch functionality I already have for my own. At present it's dependent on parts of my ssh webapp, so I need to basically port if over when I get time free of fighting botnets. – jdmayfield Oct 25 '18 at 12:20
  • ooooo! I like the sound of the touch stuff... definitely interesting. I don't remember posting this comment originally... but thanks for the response! – Joshua F. Rountree Oct 25 '18 at 17:13
  • Yup! Yeah, definitely makes it a lot easier to work on a phone, but is nice on anything with a touchscreen. I based my controls on the Termux terminal for Android, with some extras. So you can use swiping motions for mouse-wheel or arrow-keys, depedending on context and whether you swipe in the middle or on left or right edge. Also you touch to position your cursor if your in a curses-type application. – jdmayfield Oct 25 '18 at 20:08