Skip to content

Commit ffd9b74

Browse files
committed
Pane(split): Clean up signature, use direction
1 parent 2297232 commit ffd9b74

File tree

1 file changed

+3
-59
lines changed

1 file changed

+3
-59
lines changed

src/libtmux/pane.py

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,6 @@ def split(
496496
shell: t.Optional[str] = None,
497497
size: t.Optional[t.Union[str, int]] = None,
498498
environment: t.Optional[t.Dict[str, str]] = None,
499-
percent: t.Optional[int] = None, # deprecated
500-
vertical: t.Optional[bool] = None, # deprecated
501499
) -> "Pane":
502500
"""Split window and return :class:`Pane`, by default beneath current pane.
503501
@@ -521,60 +519,15 @@ def split(
521519
window upon completion is desired.
522520
size: int, optional
523521
Cell/row or percentage to occupy with respect to current window.
524-
percent: int, optional
525-
Deprecated in favor of size. Percentage to occupy with respect to current
526-
window.
527522
environment: dict, optional
528523
Environmental variables for new pane. tmux 3.0+ only. Passthrough to ``-e``.
529-
vertical : bool, optional
530-
split vertically, deprecated by ``direction``.
531-
532-
Notes
533-
-----
534-
:term:`tmux(1)` will move window to the new pane if the
535-
``split-window`` target is off screen. tmux handles the ``-d`` the
536-
same way as ``new-window`` and ``attach`` in
537-
:class:`Session.new_window`.
538-
539-
By default, this will make the window the pane is created in
540-
active. To remain on the same window and split the pane in another
541-
target window, pass in ``attach=False``.
542-
543-
.. deprecated:: 0.33.0
544-
545-
``vertical=True`` deprecated in favor of
546-
``direction=PaneDirection.Below``.
547-
548-
.. versionchanged:: 0.28.0
549-
550-
``attach`` default changed from ``True`` to ``False``.
551-
552-
.. deprecated:: 0.28.0
553-
554-
``percent=25`` deprecated in favor of ``size="25%"``.
555524
"""
556525
tmux_formats = ["#{pane_id}" + FORMAT_SEPARATOR]
557526

558527
tmux_args: t.Tuple[str, ...] = ()
559528

560529
if direction:
561530
tmux_args += tuple(PANE_DIRECTION_FLAG_MAP[direction])
562-
if vertical is not None:
563-
warnings.warn(
564-
"vertical is not required to pass with direction.",
565-
category=DeprecationWarning,
566-
stacklevel=2,
567-
)
568-
elif vertical is not None:
569-
warnings.warn(
570-
"vertical is deprecated in favor of direction.",
571-
category=DeprecationWarning,
572-
stacklevel=2,
573-
)
574-
if vertical:
575-
tmux_args += ("-v",)
576-
else:
577-
tmux_args += ("-h",)
578531
else:
579532
tmux_args += tuple(PANE_DIRECTION_FLAG_MAP[PaneDirection.Below])
580533

@@ -593,16 +546,6 @@ def split(
593546
if full_window_split:
594547
tmux_args += ("-f",)
595548

596-
if percent is not None:
597-
# Deprecated in 3.1 in favor of -l
598-
warnings.warn(
599-
f'Deprecated in favor of size="{str(percent).rstrip("%")}%" '
600-
+ ' ("-l" flag) in tmux 3.1+.',
601-
category=DeprecationWarning,
602-
stacklevel=2,
603-
)
604-
tmux_args += (f"-p{percent}",)
605-
606549
tmux_args += ("-P", "-F%s" % "".join(tmux_formats)) # output
607550

608551
if start_directory is not None:
@@ -789,13 +732,14 @@ def split_window(
789732
category=DeprecationWarning,
790733
stacklevel=2,
791734
)
735+
if size is None and percent is not None:
736+
size = f'{str(percent).rstrip("%")}%'
792737
return self.split(
793738
attach=attach,
794739
start_directory=start_directory,
795-
vertical=vertical,
740+
direction=PaneDirection.Below if vertical else PaneDirection.Right,
796741
shell=shell,
797742
size=size,
798-
percent=percent,
799743
environment=environment,
800744
)
801745

0 commit comments

Comments
 (0)