rickparrish / fTelnet

fTelnet: An HTML5 WebSocket client
GNU Affero General Public License v3.0
70 stars 38 forks source link

ANSI Resize Terminal ESC[8;height;width Possible? #28

Open maliciouspastry opened 3 months ago

maliciouspastry commented 3 months ago

Rick,

Wondering if this is possible with fTelnet? If I am using a session with 132x52 and then load up a door game which will not fill the entire area, could I clear the screen and then send the ANSI resize string and have fTelnet run some code to set the terminal size back down to 80x25 and when exiting the game, I can then clear the screen again send the command to set back to 132x52.

I'm aware it would probably also need to change the font, maybe a resize or something of the applet itself but it would be really nice to be able to do this, I would love to start using 132x52 but I know most users are going to not understand why the game won't fill the screen.

Does this seem possible to do from the server size using the ANSI string ESC[8;w;h?

I am fully hosting the css, scripts and proxies.

As usual thanks for fTelnet!

rickparrish commented 2 months ago

So just to confirm, you'd send something like ESC[8;80;25 before launching the door to have fTelnet resize to 80x25, and then ESC[8;132;52 when it exits to go back to 132x52?

In theory that sounds doable, although that escape sequence looks different in that it doesn't end with a "code" (eg the "J" in ESC[2J), so if that's the actual sequence then I may need to adjust the ANSI parser in fTelnet to support it.

maliciouspastry commented 2 months ago

Correct since most door games only run in 80x25, loading them in a 132x??? usually looks really bad or just messes things up.

I have hacked up using a custom ANSI code for my board and fTelnet, you can see it in action on my site/board. If you choose a size and then login, you can use !80 or !132 to swap dynamically and fTelnet will respond. Load a door if your on 132 and it will resize to 80, and back when you exit, I am just doing it with a completely non-standard ANSI code.

I don't know of any other ANSI-BBS compatible terminal program that can do this. I raised it with the SyncTERM suggestions page but due to something in the library he uses, he replied probably wont happen. I have pushed all my users to using the website for this feature alone. Most already use the site, so it was not hard to suggest that they can get full 132 and the features of 80 in games without disconnecting, changing sizes etc.

rickparrish commented 2 months ago

Googled a bit, and found this bug report that mentions a resize code: https://github.com/microsoft/terminal/issues/8673

Documentation: from https://invisible-island.net/xterm/ctlseqs/ctlseqs.html CSI Ps ; Ps ; Ps t Ps = 8 ; height ; width ⇒ Resize the text area to given height and width in characters. Omitted parameters reuse the current height or width. Zero parameters use the display's height or width.

So it seems like ESC[8;25;80t should work. Looks like fTelnet already has a handler for the t command (24bit colour), but it requires four parameters while resize only requires three, so I don't think it'll be a problem to support both commands. Should have time to add support later tonight.

rickparrish commented 2 months ago

Had time on my lunch, so just pushed a new commit for fTelnet as well as the v2 embed wizard. Let me know if you run into any problems using it.

maliciouspastry commented 2 months ago

Awesome, I'll load this up when I get home. I've made the changes to my code and will push it tonight. This should add more then 80x25 and 132x52 to the options I can provide and start expanding into supporting all of them.

Now if I could just get Netrunner and SyncTERM to listen to the spec. Lots of boards are going into 132 and its nice to have something that will change on the fly.

Update: Updated fTelnet, updated my code. Works correctly. I was able to force fTelnet into a specific size by sending Door.Write(ESC + "[8;52;132t");