Using Ratatui with TCP + Telnet #1000
Replies: 1 comment 5 replies
-
Issue number #1000 🎉
Sounds like you're writing something similar to https://github.com/charmbracelet/wish perhaps?
The terminal and backend does most of this diff logic for you already. It will only write the delta of the changes necessary to update its idea of what is currently on the screen. Take a read of I'm assuming you're possibly using "Telnet" here generically to mean you're listening on TCP and not that you're fully implementing RFC 854, 1073 etc. Actual telnet / ssh clients will send resize commands (more info https://unix.stackexchange.com/questions/207782/how-are-terminal-length-and-width-forwarded-over-ssh-and-telnet). It sounds like your app isn't running connected a pseudo-terminal that is allocated for the session, and so you have to handle this sort of thing manually instead of letting the protocol layer handle the interaction with pty sizing. Perhaps there's a part of your architecture choice that's missing there (or a constraint that means this is not relevant?)
You might be able to skip creating a backend and just use If that doesn't work for you, then I don't see any problem with the approach you mentioned. Wrapping the crossterm backend with another custom backend struct and add your own logic for window size call. All the functional code is implemented on traits, so there likely isn't any problem with private methods that can't be overridden which is nice. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm constructing a Telnet server and using ratatui to render the client. To achieve this, I use ratatui to redraw and then diff the terminal buffer with the buffer from the previous redraw to get the changed cells. I then convert these changes into crossterm commands and write the ansi bytes to a buffer which is sent down the TCP stream. This works nicely however I can't set a custom size for the terminal window for each client, it just uses the size from the terminal that I run the server with since I'm using the CrosstermBackend.
Do I need to construct a custom backend to allow me to set the size or is there an easier way to accomplish this?
EDIT:
I've constructed a sort-of mock backend that relies on a CrosstermBackend for most of the trait implementation but using my own sizing for
backend.size()
. Is this a valid solution or will I run into issues?Beta Was this translation helpful? Give feedback.
All reactions