Use pending updates for unicode input kitten

Avoids all possibility of flicker
This commit is contained in:
Kovid Goyal 2021-09-27 11:33:21 +05:30
parent 9cb5f6d9d7
commit b1f4b2d8ed
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 11 additions and 0 deletions

View File

@ -147,6 +147,16 @@ class Handler:
def pending_update(self) -> ContextManager[None]: def pending_update(self) -> ContextManager[None]:
return pending_update(self.write) return pending_update(self.write)
@classmethod
def with_pending_update(cls, func: Callable) -> Callable:
from functools import wraps
@wraps(func)
def f(*a: Any, **kw: Any) -> Any:
with a[0].pending_update():
return func(*a, **kw)
return f
class HandleResult: class HandleResult:

View File

@ -391,6 +391,7 @@ class UnicodeInput(Handler):
text += ' ' * extra text += ' ' * extra
self.print(styled(text, reverse=True)) self.print(styled(text, reverse=True))
@Handler.with_pending_update
def draw_screen(self) -> None: def draw_screen(self) -> None:
self.write(clear_screen()) self.write(clear_screen())
self.draw_title_bar() self.draw_title_bar()