1
|
|
|
"""API for working with Nvim windows.""" |
2
|
6 |
|
from .common import Remote |
3
|
|
|
|
4
|
|
|
|
5
|
6 |
|
__all__ = ('Window') |
6
|
|
|
|
7
|
|
|
|
8
|
6 |
|
class Window(Remote): |
9
|
|
|
|
10
|
|
|
"""A remote Nvim window.""" |
11
|
|
|
|
12
|
6 |
|
_api_prefix = "window_" |
13
|
|
|
|
14
|
6 |
|
@property |
15
|
|
|
def buffer(self): |
16
|
|
|
"""Get the `Buffer` currently being displayed by the window.""" |
17
|
6 |
|
return self.request('window_get_buffer') |
18
|
|
|
|
19
|
6 |
|
@property |
20
|
|
|
def cursor(self): |
21
|
|
|
"""Get the (row, col) tuple with the current cursor position.""" |
22
|
6 |
|
return self.request('window_get_cursor') |
23
|
|
|
|
24
|
6 |
|
@cursor.setter |
25
|
|
|
def cursor(self, pos): |
26
|
|
|
"""Set the (row, col) tuple as the new cursor position.""" |
27
|
6 |
|
return self.request('window_set_cursor', pos) |
28
|
|
|
|
29
|
6 |
|
@property |
30
|
|
|
def height(self): |
31
|
|
|
"""Get the window height in rows.""" |
32
|
6 |
|
return self.request('window_get_height') |
33
|
|
|
|
34
|
6 |
|
@height.setter |
35
|
|
|
def height(self, height): |
36
|
|
|
"""Set the window height in rows.""" |
37
|
6 |
|
return self.request('window_set_height', height) |
38
|
|
|
|
39
|
6 |
|
@property |
40
|
|
|
def width(self): |
41
|
|
|
"""Get the window width in rows.""" |
42
|
6 |
|
return self.request('window_get_width') |
43
|
|
|
|
44
|
6 |
|
@width.setter |
45
|
|
|
def width(self, width): |
46
|
|
|
"""Set the window height in rows.""" |
47
|
6 |
|
return self.request('window_set_width', width) |
48
|
|
|
|
49
|
6 |
|
@property |
50
|
|
|
def row(self): |
51
|
|
|
"""0-indexed, on-screen window position(row) in display cells.""" |
52
|
6 |
|
return self.request('window_get_position')[0] |
53
|
|
|
|
54
|
6 |
|
@property |
55
|
|
|
def col(self): |
56
|
|
|
"""0-indexed, on-screen window position(col) in display cells.""" |
57
|
6 |
|
return self.request('window_get_position')[1] |
58
|
|
|
|
59
|
6 |
|
@property |
60
|
|
|
def tabpage(self): |
61
|
|
|
"""Get the `Tabpage` that contains the window.""" |
62
|
6 |
|
return self.request('window_get_tabpage') |
63
|
|
|
|
64
|
6 |
|
@property |
65
|
|
|
def valid(self): |
66
|
|
|
"""Return True if the window still exists.""" |
67
|
6 |
|
return self.request('window_is_valid') |
68
|
|
|
|
69
|
6 |
|
@property |
70
|
|
|
def number(self): |
71
|
|
|
"""Get the window number.""" |
72
|
|
|
return self.request('nvim_win_get_number') |
73
|
|
|
|