gabe565 / ascii-movie

🌌 Star Wars SSH + Telnet server written in Go
GNU General Public License v3.0
214 stars 10 forks source link

No-decoration mode #35

Open colinleroy opened 1 year ago

colinleroy commented 1 year ago

Hi, Thanks for making this live :) This does need a fullscreen, no-decoration mode though, for old monochrome terminals that don't like UTF-8 and color codes.

gabe565 commented 1 year ago

Hey! Thanks for opening this. I was pretty sure that the tool I used would detect supported terminal colors. It definitely supports detection of true color vs 256. I'd like to reproduce but my terminals are too fancy...I'll do some testing.

colinleroy commented 1 year ago

To be more precise, there's no TERM set, it's over telnet. You would have to implement (a subset of) https://www.rfc-editor.org/rfc/rfc1091.html (see also https://www.omnisecu.com/tcpip/telnet-negotiation.php) basically you have to send IAC DO TERMINAL-TYPE

hope to receive IAC WILL TERMINAL-TYPE

In which case you can open subnegotiation and send IAC SB TERMINAL-TYPE SEND IAC SE

and the client will reply IAC SB TERMINAL_TYPE IS VT100 IAC SBE

as octal strings, this looks like: IAC DO TERMINAL-TYPE = "\377\373\30" IAC WILL TERMINAL-TYPE = "\377\373\30" etc. You can find the list of codes at https://www.ibm.com/docs/en/zos/2.1.0?topic=problems-telnet-commands-options

You can also negotiate the window size with the same system, basically. (Or, you could be lazy and assume VT100, 80x24 over telnet, but that wouldn't be fun, would it? :)

(I'd love to have opened a PR but I do suck at Go and I'm already in another rabbit hole at the moment, learning 6502 assembly :laughing:)

colinleroy commented 1 year ago

If you want tests, I do have a vt100 implementation working well enough to handle vim and mc on my Apple II, so it should do the right thing :)

gabe565 commented 1 year ago

Oh ok that makes total sense. Terminal detection works pretty well locally or over SSH, but I wrote the Telnet implementation from scratch, so it's not perfect yet. It already performs some detection so Telnet escape codes don't get sent if someone uses something like nc instead of the actual telnet command, so I'll see if I can hook into that. I'll let you know when I have something ready to test!

Also, completely off topic, but I recently tried my hand at writing an NES emulator in Go and was exposed to 6502 assembly more than I had been in the past...that seems like a pretty tough rabbit hole 😂

gabe565 commented 10 months ago

@colinleroy Non-color terms are now supported! When a device connects, ascii-movie attempts to grab the current TERM, and depending on the value it will choose ANSI256, ANSI, or ASCII colors. This works for both telnet and SSH. If it is unable to fetch the current TERM, it will default to ANSI.

The overall look has some tweaks so the buttons still make sense. Here's what non-color mode looks like:

image

Would you mind testing on your old terminal? There may still be some UTF-8 characters I need to remove, but we'll see.

colinleroy commented 10 months ago

Hi Gabe! Thanks! I'll test that as soon as possible, should be in a few days 🙂

colinleroy commented 10 months ago

Hi Gabe! I've tested and it gives this :) https://www.colino.net/tmp/vt100.mp4 I think it will really need a no-decoration mode for vt100. Maybe I should implement this to inform the server of the window size (80x24 in my case) :https://datatracker.ietf.org/doc/html/rfc1073#section-2

gabe565 commented 9 months ago

@colinleroy I love the video, but that's not as nice as I had hoped...I'll have to look at the vt100 spec some more!