Skip to content

Commit

Permalink
feat(Window): Aliases, deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Sep 19, 2022
1 parent e96a8fd commit ec65979
Showing 1 changed file with 50 additions and 2 deletions.
52 changes: 50 additions & 2 deletions src/libtmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,16 +533,25 @@ def attached_pane(self) -> t.Optional["Pane"]:
# Redundant stuff we want to remove
#
def _list_panes(self) -> t.List[PaneDict]:
"""
.. deprecated:: 0.16
"""
return [pane.__dict__ for pane in self.panes]

@property
def _panes(self) -> t.List[PaneDict]:
"""Property / alias to return :meth:`~._list_panes`."""
"""Property / alias to return :meth:`~._list_panes`.
.. deprecated:: 0.16
"""

return self._list_panes()

def list_panes(self) -> t.List["Pane"]:
"""Return list of :class:`Pane` for the window."""
"""Return list of :class:`Pane` for the window.
.. deprecated:: 0.16
"""

return self.panes

Expand All @@ -565,3 +574,42 @@ def __repr__(self) -> str:
self.window_name,
self.session,
)

#
# Aliases
#
@property
def id(self) -> str | None:
"""Alias of :attr:`Window.window_id`
>>> window.id
'@1'
>>> window.id == window.window_id
True
"""
return self.window_id

@property
def name(self) -> str | None:
"""Alias of :attr:`Window.window_name`
>>> window.name
'tmux'
>>> window.name == window.window_name
True
"""
return self.window_name

@property
def index(self) -> str | None:
"""Alias of :attr:`Window.window_index`
>>> window.index
'1'
>>> window.index == window.window_index
True
"""
return self.window_index

0 comments on commit ec65979

Please sign in to comment.