Fixed crash bug. Wide characters were sometimes causing an index out of range error. Now they are just treated as spaces.
This commit is contained in:
@@ -4,5 +4,5 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
version = "2026.08.14"
|
||||
version = "2026.08.17"
|
||||
code_name = "testing"
|
||||
|
||||
@@ -49,6 +49,23 @@ class PTYConstants:
|
||||
|
||||
|
||||
class FenrirScreen(pyte.Screen):
|
||||
@property
|
||||
def display(self):
|
||||
def render(line):
|
||||
skip_stub = False
|
||||
for x in range(self.columns):
|
||||
if skip_stub:
|
||||
skip_stub = False
|
||||
continue
|
||||
char = line[x].data
|
||||
if not char:
|
||||
yield " "
|
||||
continue
|
||||
skip_stub = pyte.screens.wcwidth(char[0]) == 2
|
||||
yield char
|
||||
|
||||
return ["".join(render(self.buffer[y])) for y in range(self.lines)]
|
||||
|
||||
def set_margins(self, *args, **kwargs):
|
||||
kwargs.pop("private", None)
|
||||
super(FenrirScreen, self).set_margins(*args, **kwargs)
|
||||
|
||||
@@ -39,6 +39,26 @@ def test_private_sgr_sequence_from_fullscreen_apps_does_not_crash():
|
||||
assert screen["text"].splitlines()[0] == "X "
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_overwritten_wide_character_stub_renders_as_space():
|
||||
terminal = Terminal(4, 1, DummyProcessInput())
|
||||
|
||||
terminal.feed("界\rX".encode())
|
||||
screen = terminal.get_screen_content()
|
||||
|
||||
assert screen["text"] == "X "
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_wide_character_and_stub_keep_terminal_width():
|
||||
terminal = Terminal(4, 1, DummyProcessInput())
|
||||
|
||||
terminal.feed("界".encode())
|
||||
screen = terminal.get_screen_content()
|
||||
|
||||
assert screen["text"] == "界 "
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_optional_float_setting_uses_default_when_missing():
|
||||
settings_manager = type(
|
||||
|
||||
Reference in New Issue
Block a user