File: tabpage.py

package info (click to toggle)
python-pynvim 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: python: 3,067; makefile: 4
file content (46 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""API for working with Nvim tabpages."""

from __future__ import annotations

from typing import Any, TYPE_CHECKING, Tuple

from pynvim.api.common import Remote, RemoteSequence
from pynvim.api.window import Window

if TYPE_CHECKING:
    from pynvim.api.nvim import Nvim


__all__ = ['Tabpage']


class Tabpage(Remote):
    """A remote Nvim tabpage."""

    _api_prefix = "nvim_tabpage_"

    def __init__(self, session: Nvim, code_data: Tuple[int, Any]):
        """Initialize from session and code_data immutable object.

        The `code_data` contains serialization information required for
        msgpack-rpc calls. It must be immutable for Buffer equality to work.
        """
        super(Tabpage, self).__init__(session, code_data)
        self.windows: RemoteSequence[Window] = RemoteSequence(
            self, "nvim_tabpage_list_wins"
        )

    @property
    def window(self) -> Window:
        """Get the `Window` currently focused on the tabpage."""
        return self.request('nvim_tabpage_get_win')

    @property
    def valid(self) -> bool:
        """Return True if the tabpage still exists."""
        return self.request('nvim_tabpage_is_valid')

    @property
    def number(self) -> int:
        """Get the tabpage number."""
        return self.request('nvim_tabpage_get_number')