Use a pending update when drawing the screen
This commit is contained in:
parent
9b7899780b
commit
96326280e5
@ -278,12 +278,13 @@ class ThemesHandler(Handler):
|
|||||||
self.on_browsing_key_event(key_event, in_bracketed_paste)
|
self.on_browsing_key_event(key_event, in_bracketed_paste)
|
||||||
|
|
||||||
def draw_screen(self) -> None:
|
def draw_screen(self) -> None:
|
||||||
self.cmd.clear_screen()
|
with self.pending_update():
|
||||||
self.enforce_cursor_state()
|
self.cmd.clear_screen()
|
||||||
if self.state is State.fetching:
|
self.enforce_cursor_state()
|
||||||
self.draw_fetching_screen()
|
if self.state is State.fetching:
|
||||||
elif self.state is State.browsing:
|
self.draw_fetching_screen()
|
||||||
self.draw_browsing_screen()
|
elif self.state is State.browsing:
|
||||||
|
self.draw_browsing_screen()
|
||||||
|
|
||||||
def on_resize(self, screen_size: ScreenSize) -> None:
|
def on_resize(self, screen_size: ScreenSize) -> None:
|
||||||
self.screen_size = screen_size
|
self.screen_size = screen_size
|
||||||
|
|||||||
@ -10,10 +10,12 @@ from typing import (
|
|||||||
|
|
||||||
from kitty.types import ParsedShortcut
|
from kitty.types import ParsedShortcut
|
||||||
from kitty.typing import (
|
from kitty.typing import (
|
||||||
AbstractEventLoop, BossType, Debug, ImageManagerType, KeyEventType,
|
AbstractEventLoop, BossType, Debug, ImageManagerType, KeyActionType,
|
||||||
KeyActionType, LoopType, MouseEvent, ScreenSize, TermManagerType
|
KeyEventType, LoopType, MouseEvent, ScreenSize, TermManagerType
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .operations import pending_update
|
||||||
|
|
||||||
|
|
||||||
class Handler:
|
class Handler:
|
||||||
|
|
||||||
@ -134,6 +136,9 @@ class Handler:
|
|||||||
def suspend(self) -> ContextManager[TermManagerType]:
|
def suspend(self) -> ContextManager[TermManagerType]:
|
||||||
return self._term_manager.suspend()
|
return self._term_manager.suspend()
|
||||||
|
|
||||||
|
def pending_update(self) -> ContextManager[None]:
|
||||||
|
return pending_update(self.write)
|
||||||
|
|
||||||
|
|
||||||
class HandleResult:
|
class HandleResult:
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ MODES = dict(
|
|||||||
MOUSE_URXVT_MODE=(1015, '?'),
|
MOUSE_URXVT_MODE=(1015, '?'),
|
||||||
ALTERNATE_SCREEN=(1049, '?'),
|
ALTERNATE_SCREEN=(1049, '?'),
|
||||||
BRACKETED_PASTE=(2004, '?'),
|
BRACKETED_PASTE=(2004, '?'),
|
||||||
|
PENDING_UPDATE=(2026, '?'),
|
||||||
)
|
)
|
||||||
|
|
||||||
F = TypeVar('F')
|
F = TypeVar('F')
|
||||||
@ -290,6 +291,13 @@ def reset_state(normal_screen: bool = True) -> str:
|
|||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def pending_update(write: Callable[[str], None]) -> Generator[None, None, None]:
|
||||||
|
write(set_mode('PENDING_UPDATE'))
|
||||||
|
yield
|
||||||
|
write(reset_mode('PENDING_UPDATE'))
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def cursor(write: Callable[[str], None]) -> Generator[None, None, None]:
|
def cursor(write: Callable[[str], None]) -> Generator[None, None, None]:
|
||||||
write(SAVE_CURSOR)
|
write(SAVE_CURSOR)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user