diff --git a/pyte/screens.py b/pyte/screens.py index 384542f..1907617 100644 --- a/pyte/screens.py +++ b/pyte/screens.py @@ -971,11 +971,15 @@ def alignment_display(self) -> None: for x in range(self.columns): self.buffer[y][x] = self.buffer[y][x]._replace(data="E") - def select_graphic_rendition(self, *attrs: int) -> None: + def select_graphic_rendition(self, *attrs: int, private: bool = False) -> None: """Set display attributes. :param list attrs: a list of display attributes to set. + :param bool private: if True, ignore the SGR sequence (private sequences are not supported). """ + if private: + return + replace = {} # Fast path for resetting all attributes. diff --git a/tests/test_screen.py b/tests/test_screen.py index 7626f61..d7a7a1d 100644 --- a/tests/test_screen.py +++ b/tests/test_screen.py @@ -1583,3 +1583,24 @@ def test_screen_set_icon_name_title(): screen.set_title(text) assert screen.title == text + + +def test_private_sgr_sequence_ignored(): + def cursor_state(cursor): + return (cursor.x, cursor.y, cursor.attrs, cursor.hidden) + + screen = pyte.HistoryScreen(2, 2) + stream = pyte.ByteStream(screen) + + # Capture initial state + display = screen.display + mode = screen.mode.copy() + cursor = cursor_state(screen.cursor) + + # Vim 9.0+ sends this to query modifyOtherKeys capability - should be ignored + stream.feed(b'\x1b[?4m') + + # Verify nothing changed + assert screen.display == display + assert screen.mode == mode + assert cursor_state(screen.cursor) == cursor