Commit 80a7babc authored by mathieui's avatar mathieui

Type curses windows

parent 2f4651d0
......@@ -21,7 +21,15 @@ import time
from math import ceil, log10
from datetime import datetime
from xml.etree import cElementTree as ET
from typing import Any, Callable, Dict, List, Optional, Union
from typing import (
Any,
Callable,
Dict,
List,
Optional,
Union,
TYPE_CHECKING,
)
from poezio import mam, poopt, timed_events, xhtml, windows
from poezio.core.structs import Command, Completion, Status
......@@ -35,6 +43,9 @@ from poezio.windows.funcs import truncate_nick
from slixmpp import JID, InvalidJID, Message
if TYPE_CHECKING:
from _curses import _CursesWindow
log = logging.getLogger(__name__)
# getters for tab colors (lambdas, so that they are dynamic)
......@@ -176,7 +187,7 @@ class Tab:
self._state = 'normal'
@staticmethod
def resize(scr):
def resize(scr: '_CursesWindow'):
Tab.height, Tab.width = scr.getmaxyx()
windows.base_wins.TAB_WIN = scr
......
......@@ -7,7 +7,7 @@ the text window, the roster window, etc.
A Tab (see the poezio.tabs module) is composed of multiple Windows
"""
TAB_WIN = None
TAB_WIN = None # type: _CursesWindow
import logging
log = logging.getLogger(__name__)
......@@ -15,7 +15,8 @@ log = logging.getLogger(__name__)
import curses
import string
from typing import Optional, Tuple
from contextlib import contextmanager
from typing import Optional, Tuple, TYPE_CHECKING
from poezio.theming import to_curses_attr, read_tuple
......@@ -24,6 +25,9 @@ FORMAT_CHAR = '\x19'
# I guess. But maybe we can find better chars that are even less risky.
format_chars = '\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x1A'
if TYPE_CHECKING:
from _curses import _CursesWindow
class DummyWin:
def __getattribute__(self, name: str):
......@@ -40,7 +44,7 @@ class Win:
__slots__ = ('_win', 'height', 'width', 'y', 'x')
def __init__(self) -> None:
self._win = None
self._win = None # type: _CursesWindow
self.height, self.width = 0, 0
def _resize(self, height: int, width: int, y: int, x: int) -> None:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment