Completed
Pull Request — master (#328)
by
unknown
20:55
created

Window.__repr__()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
"""API for working with Nvim windows."""
2 5
from .common import Remote
3
4
5 5
__all__ = ('Window')
6
7
8 5
class Window(Remote):
9
10
    """A remote Nvim window."""
11
12 5
    _api_prefix = "nvim_win_"
13
14 5
    def __repr__(self):
15
        """Get text representation of the window."""
16
        return 'Window(handle=%r)' % (
17 5
            self.handle,
18
        )
19 5
20
    @property
21
    def buffer(self):
22 5
        """Get the `Buffer` currently being displayed by the window."""
23
        return self.request('nvim_win_get_buf')
24 5
25
    @property
26
    def cursor(self):
27 5
        """Get the (row, col) tuple with the current cursor position."""
28
        return self.request('nvim_win_get_cursor')
29 5
30
    @cursor.setter
31
    def cursor(self, pos):
32 5
        """Set the (row, col) tuple as the new cursor position."""
33
        return self.request('nvim_win_set_cursor', pos)
34 5
35
    @property
36
    def height(self):
37 5
        """Get the window height in rows."""
38
        return self.request('nvim_win_get_height')
39 5
40
    @height.setter
41
    def height(self, height):
42 5
        """Set the window height in rows."""
43
        return self.request('nvim_win_set_height', height)
44 5
45
    @property
46
    def width(self):
47 5
        """Get the window width in rows."""
48
        return self.request('nvim_win_get_width')
49 5
50
    @width.setter
51
    def width(self, width):
52 5
        """Set the window height in rows."""
53
        return self.request('nvim_win_set_width', width)
54 5
55
    @property
56
    def row(self):
57 5
        """0-indexed, on-screen window position(row) in display cells."""
58
        return self.request('nvim_win_get_position')[0]
59 5
60
    @property
61
    def col(self):
62 5
        """0-indexed, on-screen window position(col) in display cells."""
63
        return self.request('nvim_win_get_position')[1]
64 5
65
    @property
66
    def tabpage(self):
67 5
        """Get the `Tabpage` that contains the window."""
68
        return self.request('nvim_win_get_tabpage')
69 5
70
    @property
71
    def valid(self):
72 5
        """Return True if the window still exists."""
73
        return self.request('nvim_win_is_valid')
74
75
    @property
76
    def number(self):
77
        """Get the window number."""
78
        return self.request('nvim_win_get_number')
79