mirror of
https://github.com/Textualize/textual.git
synced 2025-10-17 02:38:12 +03:00
windows driver abstraction
This commit is contained in:
12
src/textual/_windows_driver.py
Normal file
12
src/textual/_windows_driver.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from .driver import Driver
|
||||
|
||||
|
||||
class WindowsDriver(Driver):
|
||||
def start_application_mode(self) -> None:
|
||||
pass
|
||||
|
||||
def disable_input(self) -> None:
|
||||
pass
|
||||
|
||||
def stop_application_mode(self) -> None:
|
||||
pass
|
||||
@@ -3,6 +3,7 @@ import os
|
||||
|
||||
import asyncio
|
||||
from functools import partial
|
||||
import platform
|
||||
from typing import Any, Callable, ClassVar, Type, TypeVar
|
||||
import warnings
|
||||
|
||||
@@ -24,7 +25,6 @@ from ._context import active_app
|
||||
from ._event_broker import extract_handler_actions, NoHandler
|
||||
from .driver import Driver
|
||||
from .layouts.dock import DockLayout, Dock
|
||||
from ._linux_driver import LinuxDriver
|
||||
from .message_pump import MessagePump
|
||||
from ._profile import timer
|
||||
from .view import View
|
||||
@@ -78,7 +78,7 @@ class App(MessagePump):
|
||||
self.console = console or Console()
|
||||
self.error_console = Console(stderr=True)
|
||||
self._screen = screen
|
||||
self.driver_class = driver_class or LinuxDriver
|
||||
self.driver_class = driver_class or self.get_driver_class()
|
||||
self._title = title
|
||||
self._layout = DockLayout()
|
||||
self._view_stack: list[DockView] = []
|
||||
@@ -110,6 +110,24 @@ class App(MessagePump):
|
||||
sub_title: Reactive[str] = Reactive("")
|
||||
background: Reactive[str] = Reactive("black")
|
||||
|
||||
def get_driver_class(self) -> Type[Driver]:
|
||||
"""Get a driver class for this platform.
|
||||
|
||||
Called by the constructor.
|
||||
|
||||
Returns:
|
||||
Driver: A Driver class which manages input and display.
|
||||
"""
|
||||
if platform.system() == "Windows":
|
||||
from ._windows_driver import WindowsDriver
|
||||
|
||||
driver_class = WindowsDriver
|
||||
else:
|
||||
from ._linux_driver import LinuxDriver
|
||||
|
||||
driver_class = LinuxDriver
|
||||
return driver_class
|
||||
|
||||
def __rich_repr__(self) -> rich.repr.Result:
|
||||
yield "title", self.title
|
||||
|
||||
|
||||
Reference in New Issue
Block a user