|
1 | | -from contextlib import contextmanager |
2 | 1 | from typing import Tuple |
3 | 2 |
|
4 | | -from ..sess import lua_context_object, ContextObject |
| 3 | +from ..sess import lua_context_object, ReferenceObject |
5 | 4 | from .term import TermMixin, TermTarget |
6 | 5 |
|
7 | 6 |
|
8 | | -__all__ = ( |
9 | | - 'create', |
10 | | -) |
| 7 | +__all__ = ('create', ) |
11 | 8 |
|
12 | 9 |
|
13 | | -class TermWindow(ContextObject, TermMixin): |
| 10 | +class TermWindow(ReferenceObject, TermMixin): |
14 | 11 | def setVisible(self, visibility: bool) -> None: |
15 | | - return self._call(b'.setVisible', visibility).take_none() |
| 12 | + return self._call(b'setVisible', visibility).take_none() |
16 | 13 |
|
17 | 14 | def redraw(self) -> None: |
18 | | - return self._call(b'.redraw').take_none() |
| 15 | + return self._call(b'redraw').take_none() |
19 | 16 |
|
20 | 17 | def restoreCursor(self) -> None: |
21 | | - return self._call(b'.restoreCursor').take_none() |
| 18 | + return self._call(b'restoreCursor').take_none() |
22 | 19 |
|
23 | 20 | def getPosition(self) -> Tuple[int, int]: |
24 | | - rp = self._call(b'.getPosition') |
| 21 | + rp = self._call(b'getPosition') |
25 | 22 | return tuple(rp.take_int() for _ in range(2)) |
26 | 23 |
|
27 | 24 | def reposition(self, x: int, y: int, width: int = None, height: int = None, parent: TermTarget = None) -> None: |
28 | | - return self._call('.reposition', x, y, width, height, parent).take_none() |
| 25 | + return self._call(b'reposition', x, y, width, height, parent).take_none() |
29 | 26 |
|
30 | 27 | def getLine(self, y: int) -> Tuple[str, bytes, bytes]: |
31 | | - rp = self._call(b'.getLine', y) |
| 28 | + rp = self._call(b'getLine', y) |
32 | 29 | return rp.take_string(), rp.take_bytes(), rp.take_bytes() |
33 | 30 |
|
34 | 31 |
|
35 | | -@contextmanager |
36 | 32 | def create( |
37 | 33 | parentTerm: TermTarget, x: int, y: int, width: int, height: int, visible: bool = None, |
38 | 34 | ) -> TermWindow: |
39 | | - with lua_context_object( |
| 35 | + return TermWindow(lua_context_object( |
40 | 36 | b'window.create(...)', |
41 | | - (parentTerm, x, y, width, height, visible), |
42 | | - ) as fid: |
43 | | - yield TermWindow(fid) |
| 37 | + (parentTerm, x, y, width, height, visible))) |
0 commit comments