mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
simplify
This commit is contained in:
@@ -300,8 +300,6 @@ ANSI_SEQUENCES_KEYS: Mapping[str, Tuple[Keys, ...]] = {
|
||||
"\x1b[1;8y": (Keys.Escape, Keys.ControlShift9),
|
||||
}
|
||||
|
||||
|
||||
TERMINAL_MODES_ANSI_SEQUENCES: Mapping[str, str] = {
|
||||
"sync_start": "\x1b[?2026h",
|
||||
"sync_stop": "\x1b[?2026l",
|
||||
}
|
||||
# https://gist.github.com/christianparpart/d8a62cc1ab659194337d73e399004036
|
||||
SYNC_START = "\x1b[?2026h"
|
||||
SYNC_END = "\x1b[?2026l"
|
||||
|
||||
@@ -254,12 +254,15 @@ class Compositor:
|
||||
if screen not in self._dirty_regions:
|
||||
crop_screen = screen.intersection
|
||||
changes = map.items() ^ old_map.items()
|
||||
self._dirty_regions.update(
|
||||
[
|
||||
regions = {
|
||||
region
|
||||
for region in (
|
||||
crop_screen(map_geometry.visible_region)
|
||||
for _, map_geometry in changes
|
||||
]
|
||||
)
|
||||
)
|
||||
if region
|
||||
}
|
||||
self._dirty_regions.update(regions)
|
||||
|
||||
return ReflowResult(
|
||||
hidden=hidden_widgets,
|
||||
|
||||
@@ -22,7 +22,7 @@ from typing import (
|
||||
TYPE_CHECKING,
|
||||
)
|
||||
|
||||
from ._ansi_sequences import TERMINAL_MODES_ANSI_SEQUENCES
|
||||
from ._ansi_sequences import SYNC_START, SYNC_END
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from typing import Literal
|
||||
@@ -897,10 +897,12 @@ class App(Generic[ReturnType], DOMNode):
|
||||
console = self.console
|
||||
self._begin_update()
|
||||
try:
|
||||
console.print(renderable)
|
||||
except Exception as error:
|
||||
self.on_exception(error)
|
||||
self._end_update()
|
||||
try:
|
||||
console.print(renderable)
|
||||
except Exception as error:
|
||||
self.on_exception(error)
|
||||
finally:
|
||||
self._end_update()
|
||||
console.file.flush()
|
||||
|
||||
def measure(self, renderable: RenderableType, max_width=100_000) -> int:
|
||||
@@ -1103,16 +1105,16 @@ class App(Generic[ReturnType], DOMNode):
|
||||
def handle_terminal_supports_synchronized_output(
|
||||
self, message: messages.TerminalSupportsSynchronizedOutput
|
||||
) -> None:
|
||||
log("SynchronizedOutput mode is supported by this terminal")
|
||||
log("[b green]SynchronizedOutput mode is supported")
|
||||
self._sync_available = True
|
||||
|
||||
def _begin_update(self) -> None:
|
||||
if self._sync_available:
|
||||
self.console.file.write(TERMINAL_MODES_ANSI_SEQUENCES["sync_start"])
|
||||
self.console.file.write(SYNC_START)
|
||||
|
||||
def _end_update(self) -> None:
|
||||
if self._sync_available:
|
||||
self.console.file.write(TERMINAL_MODES_ANSI_SEQUENCES["sync_stop"])
|
||||
self.console.file.write(SYNC_END)
|
||||
|
||||
|
||||
_uvloop_init_done: bool = False
|
||||
|
||||
@@ -9,7 +9,6 @@ from rich.style import Style
|
||||
|
||||
from . import events, messages, errors
|
||||
|
||||
from .color import Color
|
||||
from .geometry import Offset, Region, Size
|
||||
from ._compositor import Compositor, MapGeometry
|
||||
from .reactive import Reactive
|
||||
|
||||
Reference in New Issue
Block a user