selectel / pyte

Simple VTXXX-compatible linux terminal emulator
http://pyte.readthedocs.org/
GNU Lesser General Public License v3.0
649 stars 101 forks source link

Added UTF8 option in __init__ (constructor) to emulate terminals that do not start in UTF8 mode #140

Closed doctorjei closed 1 year ago

doctorjei commented 3 years ago

It was only after digging through a lot of pyte's code that I realized that it isn't "broken"; instead, it just starts in UTF8 mode. However, a lot of software out there runs in non-UTF8 mode from the start and never switches to it using the %@ command (in my case, this was the Python curses programs I've been working with.) This results in "boxes" and other DEC special graphics characters (usually supported by BVT100 terminals) showing up as lower-case Latin alphabetical characters (l,k,m, etc).

Adding a kwarg to the init of the Stream class allows the terminal to be explicitly started in ISO 2022 mode.

superbobry commented 1 year ago

Hey @doctorjei, thanks for the contribution! Unfortunately, I would rather not add features which can be implemented without modifying pyte, e.g. via subclassing. Here you could do

class CustomStream(pyte.Stream):
    def __init__(self, ..., start_utf8=True):
        super().__init__(...)
        self.use_utf8 = start_utf8