Skip to content

Commit

Permalink
feat: Sync UrwidImageScreen with lock_tty()
Browse files Browse the repository at this point in the history
- Add: Synchronize the following I/O methods of `UrwidImageScreen`
  with `.utils.lock_tty()`:

  - `get_available_raw_input()`
  - `flush()`
  - `write()`

Refs: #73, #80
  • Loading branch information
AnonymouX47 committed Mar 26, 2023
1 parent fcbb8d6 commit 8e360c7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/term_image/widget/urwid.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@

from ..exceptions import UrwidImageError
from ..image import BaseImage, ITerm2Image, KittyImage, Size, TextImage, kitty
from ..utils import BEGIN_SYNCED_UPDATE, END_SYNCED_UPDATE, COLOR_RESET_b, ESC_b
from ..utils import (
BEGIN_SYNCED_UPDATE,
END_SYNCED_UPDATE,
COLOR_RESET_b,
ESC_b,
lock_tty,
)

# NOTE: Any new "private" attribute of any subclass of an urwid class should be
# prepended with "_ti" to prevent clashes with names used by urwid itself.
Expand Down Expand Up @@ -533,6 +539,21 @@ def draw_screen(self, maxres, canvas):
self.write(END_SYNCED_UPDATE)
self.flush()

@lock_tty
def flush(self):
"""See the baseclass' method for the description."""
return super().flush()

@lock_tty
def get_available_raw_input(self):
"""See the baseclass' method for the description."""
return super().get_available_raw_input()

@lock_tty
def write(self, data):
"""See the baseclass' method for the description."""
return super().write(data)

def _start(self, *args, **kwargs):
ret = super()._start(*args, **kwargs)
if KittyImage._forced_support or KittyImage.is_supported():
Expand Down

0 comments on commit 8e360c7

Please sign in to comment.