diff --git a/pyte/streams.py b/pyte/streams.py index cd0f51c..8417042 100644 --- a/pyte/streams.py +++ b/pyte/streams.py @@ -139,10 +139,11 @@ class Stream: "[^" + "".join(map(re.escape, _special)) + "]+") del _special - def __init__(self, screen: Optional[Screen] = None, strict: bool = True) -> None: + def __init__(self, screen: Optional[Screen] = None, strict: bool = True, use_c1: bool = True) -> None: self.listener: Optional[Screen] = None self.strict = strict self.use_utf8: bool = True + self.use_c1: bool = use_c1 self._taking_plain_text: Optional[bool] = None @@ -304,7 +305,7 @@ def create_dispatcher(mapping: Mapping[str, str]) -> Dict[str, Callable[..., Non continue basic_dispatch[char]() - elif char == CSI_C1: + elif char == CSI_C1 and self.use_c1: # All parameters are unsigned, positive decimal integers, with # the most significant digit sent first. Any parameter greater # than 9999 is set to 9999. If you do not specify a value, a 0 @@ -354,7 +355,7 @@ def create_dispatcher(mapping: Mapping[str, str]) -> Dict[str, Callable[..., Non else: csi_dispatch[char](*params) break # CSI is finished. - elif char == OSC_C1: + elif char == OSC_C1 and self.use_c1: code = yield None if code == "R": continue # Reset palette. Not implemented. diff --git a/tests/test_stream.py b/tests/test_stream.py index 7a3ad92..79b6a57 100644 --- a/tests/test_stream.py +++ b/tests/test_stream.py @@ -332,3 +332,13 @@ def test_byte_stream_select_other_charset(): # c) enable utf-8 stream.select_other_charset("G") assert stream.use_utf8 + + +def test_byte_stream_without_c1() -> None: + screen = pyte.ByteScreen(3, 3) + stream = pyte.ByteStream(screen, use_c1=False) + stream.select_other_charset("@") + b = '𡶐'.encode("big5-hkscs") + stream.feed(b) + assert screen.display[0] == "\x9b\xf3 " + assert stream.use_c1 == False