Completed
Pull Request — master (#223)
by Björn
02:49
created

Window.cursor()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1.125

Importance

Changes 2
Bugs 0 Features 2
Metric Value
cc 1
dl 0
loc 4
ccs 1
cts 2
cp 0.5
crap 1.125
rs 10
c 2
b 0
f 2
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
        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
        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
        return self.request('window_set_cursor', pos)
28
29 6
    @property
30
    def height(self):
31
        """Get the window height in rows."""
32
        return self.request('window_get_height')
33
34 6
    @height.setter
35
    def height(self, height):
36
        """Set the window height in rows."""
37
        return self.request('window_set_height', height)
38
39 6
    @property
40
    def width(self):
41
        """Get the window width in rows."""
42
        return self.request('window_get_width')
43
44 6
    @width.setter
45
    def width(self, width):
46
        """Set the window height in rows."""
47
        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
        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
        return self.request('window_get_position')[1]
58
59 6
    @property
60
    def tabpage(self):
61
        """Get the `Tabpage` that contains the window."""
62
        return self.request('window_get_tabpage')
63
64 6
    @property
65
    def valid(self):
66
        """Return True if the window still exists."""
67
        return self.request('window_is_valid')
68