Skip to content

Commit

Permalink
refactor: write characters to screen one at a time. While this seems …
Browse files Browse the repository at this point in the history
…like it would decrease performance, the python file.write method is buffered, so it shouldn't make a difference
  • Loading branch information
mecaneer23 committed Apr 18, 2024
1 parent 3fb064f commit e3a367b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/acurses.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ def addstr(self, *args: Any, **kwargs: Any) -> None:
@_addstr.register(str)
def _(self, text: str, attr: int = 0) -> None:
ansi_attrs = self._parse_attrs(attr)
stdout.write(
f"{ansi_attrs}{text[:self._width]}{_ANSI_RESET if ansi_attrs else ''}"
)
stdout.write(ansi_attrs)
for char in text[:self._width]:
stdout.write(char)
if ansi_attrs:
stdout.write(_ANSI_RESET)
stdout.flush()

@_addstr.register(int)
Expand Down

0 comments on commit e3a367b

Please sign in to comment.