5 ms·
What I could really use would be a terminal emulator that is: a library that I can feed data directly into (without a pty) LGPL, MIT, or BSD able to quickly
by burfog 8y ago
What I could really use would be a terminal emulator that is:
a library that I can feed data directly into (without a pty)
LGPL, MIT, or BSD
able to quickly serialize its internal state (make me a blob)
able to restore state if I feed it a blob of saved state, even across different software builds
portable to recent versions of Linux and Windows
- 8_hours_ago 8y agoThat sounds interesting! Out of curiosity, what is your use case for those features?
- burfog 8y agoIt is useful for backwards execution. This is supported in various ways by Simics, gdb, SID simulator, rr, the Moxielogic emulator, and others. It is useful for virtual machine snapshots. You can restore the virtual machine with the terminal state intact.
- gear54rus 8y agoAm I missing something? VM snapshots also save memory, any terminal will be intact after this?
- burfog 8y agoThat would be true if the terminal were within the VM, for example if the VM was a graphical OS running a terminal program. It isn't true if the VM is communicating over an emulated serial port. In that case, the VM software must provide a terminal as hardware. Typically the VM software only provides a serial port to the VM, which the user will then associate with something else via the VM configuration. This fails when loading a snapshot because the terminal isn't part of the snapshot. For example, suppose that the VM is a PC-AT running DR-DOS and a BBS. (from the pre-internet days, with a modem for users to dial in on) At minimum, the VM software must provide a serial port for the VM. You could configure this to connect with a real physical modem and then connect to that with another modem and some dial-up software, but then you'd have a problem with snapshots. Loading a snapshot would place the BBS in a state that is inconsistent with the dial-up software. What you really need is for the terminal emulator to be part of the hardware that the VM is emulating. It would then be properly snapshotted.
- grp 8y agotcl.tk ?
- monetus 8y agoThat's what I was thinking, it sounds like the wish terminal.
- laumars 8y agoTheres no way you can build a terminal emulator without a PTY and still expect terminal UIs (eg stuff that uses ncursors) to work. Moreover, the session state saving is not possible either since you need to save the internal state of running programs as well as their cached output (saving the output is really very easy but it's the least of your worries given the specifications you've described). You might also find this problem is better solved with a $SHELL replacement rather than a terminal emulator.
- burfog 8y agoYes you can. I want to hook this up to an emulator (like qemu or MAME) with an emulated serial port. That is the PTY equivalent. I'm writing this emulator. So the emulator gets bytes from the emulated virtual machine, and then what? This needs to get fed into a terminal. While it is possible to invoke xterm with the very buggy -S option, there is no way for the emulator to suck the state back out of xterm for coherent snapshots. Simics uses xterm with the -S option. It sucks. A library interface is required. The whole point of a library interface is to allow session state saving. Using a $SHELL replacement is way off. That has nothing to do with the problem. So, if you were hacking on an emulator (qemu, MAME, Simics, VirtualBox, etc.) and you were trying to emulate a device with a serial port or even a modem, how would you get snapshots to contain the terminal state? To make this work, you need that state within the emulator. Passing stuff over a PTY is not going to work.
- Liquid_Fire 8y agoJust capture the output from the serial port in a buffer inside the emulator, and use that to save snapshots. You can then also forward any output to a file/terminal emulator/whatever is convenient, but relying on the terminal emulator to save part of your emulator's state seems weird to me, unless you are going to ship the two bundled together.
- burfog 8y agoTerminal state is far more than just text on the screen. For example, an escape code could change the color. After that, there could be megabytes of output created over many hours. Loading a snapshot should not require replaying all that data. The point of a library is that the two are more than just bundled together. They are linked together, making one executable. The terminal window is a part of the emulator.