re-construct console

This commit is contained in:
Will McGugan
2022-01-28 10:13:30 +00:00
parent 988838a872
commit b4358f887b
4 changed files with 15 additions and 7 deletions

View File

@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.1.15] - Unreleased
### Added
- Added Windows Driver
## [1.1.14] - 2022-01-09
### Changed

View File

@@ -32,7 +32,7 @@ class SmoothApp(App):
self.bar.layout_offset_x = -40
self.set_timer(10, lambda: self.action("quit"))
# self.set_timer(10, lambda: self.action("quit"))
SmoothApp.run(log="textual.log", log_verbosity=2)

View File

@@ -2,7 +2,6 @@ from __future__ import annotations
import os
import asyncio
from functools import partial
import platform
from typing import Any, Callable, ClassVar, Type, TypeVar
import warnings
@@ -31,6 +30,8 @@ from .view import View
from .views import DockView
from .widget import Widget, Reactive
PLATFORM = platform.system()
WINDOWS = PLATFORM == "Windows"
# asyncio will warn against resources not being cleared
warnings.simplefilter("always", ResourceWarning)
@@ -118,7 +119,7 @@ class App(MessagePump):
Returns:
Driver: A Driver class which manages input and display.
"""
if platform.system() == "Windows":
if WINDOWS:
from .drivers.windows_driver import WindowsDriver
driver_class = WindowsDriver
@@ -302,6 +303,7 @@ class App(MessagePump):
self.console.print_exception()
else:
try:
self.console = Console()
self.title = self._title
self.refresh()
await self.animator.start()
@@ -344,7 +346,9 @@ class App(MessagePump):
await self.close_messages()
def refresh(self, repaint: bool = True, layout: bool = False) -> None:
sync_available = os.environ.get("TERM_PROGRAM", "") != "Apple_Terminal"
sync_available = (
os.environ.get("TERM_PROGRAM", "") != "Apple_Terminal" and not WINDOWS
)
if not self._closed:
console = self.console
try:

View File

@@ -1,5 +1,4 @@
from asyncio import AbstractEventLoop, run_coroutine_threadsafe
from codecs import getincrementaldecoder
import ctypes
from ctypes import byref, Structure, Union, wintypes
@@ -9,11 +8,10 @@ import os
import sys
import threading
from tkinter.tix import WINDOW
from typing import IO, Callable, List, Optional
from ..geometry import Size
from ..events import Event, Key, Resize
from ..events import Event, Resize
from .._types import EventTarget
from .._xterm_parser import XTermParser