1414
1515from libtmux .common import has_gte_version , has_lt_version , tmux_cmd
1616from libtmux .constants import (
17+ PANE_DIRECTION_FLAG_MAP ,
1718 RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP ,
19+ PaneDirection ,
1820 ResizeAdjustmentDirection ,
1921)
2022from libtmux .formats import FORMAT_SEPARATOR
@@ -489,15 +491,14 @@ def split(
489491 self ,
490492 start_directory : t .Optional [str ] = None ,
491493 attach : bool = False ,
492- vertical : bool = True ,
494+ direction : t . Optional [ PaneDirection ] = None ,
493495 shell : t .Optional [str ] = None ,
494496 size : t .Optional [t .Union [str , int ]] = None ,
495- percent : t .Optional [int ] = None , # deprecated
496497 environment : t .Optional [t .Dict [str , str ]] = None ,
498+ percent : t .Optional [int ] = None , # deprecated
499+ vertical : t .Optional [bool ] = None , # deprecated
497500 ) -> "Pane" :
498- """Split window and return the created :class:`Pane`.
499-
500- Used for splitting window and holding in a python object.
501+ """Split window and return :class:`Pane`, by default beneath current pane.
501502
502503 Parameters
503504 ----------
@@ -506,8 +507,8 @@ def split(
506507 True.
507508 start_directory : str, optional
508509 specifies the working directory in which the new window is created.
509- vertical : bool , optional
510- split vertically
510+ direction : PaneDirection , optional
511+ split in direction. If none is specified, assume down.
511512 shell : str, optional
512513 execute a command on splitting the window. The pane will close
513514 when the command exits.
@@ -522,6 +523,8 @@ def split(
522523 window.
523524 environment: dict, optional
524525 Environmental variables for new pane. tmux 3.0+ only. Passthrough to ``-e``.
526+ vertical : bool, optional
527+ split vertically, deprecated by ``direction``.
525528
526529 Notes
527530 -----
@@ -534,6 +537,11 @@ def split(
534537 active. To remain on the same window and split the pane in another
535538 target window, pass in ``attach=False``.
536539
540+ .. deprecated:: 0.33.0
541+
542+ ``vertical=True`` deprecated in favor of
543+ ``direction=PaneDirection.Below``.
544+
537545 .. versionchanged:: 0.28.0
538546
539547 ``attach`` default changed from ``True`` to ``False``.
@@ -546,10 +554,26 @@ def split(
546554
547555 tmux_args : t .Tuple [str , ...] = ()
548556
549- if vertical :
550- tmux_args += ("-v" ,)
557+ if direction :
558+ tmux_args += tuple (PANE_DIRECTION_FLAG_MAP [direction ])
559+ if vertical is not None :
560+ warnings .warn (
561+ "vertical is not required to pass with direction." ,
562+ category = DeprecationWarning ,
563+ stacklevel = 2 ,
564+ )
565+ elif vertical is not None :
566+ warnings .warn (
567+ "vertical is deprecated in favor of direction." ,
568+ category = DeprecationWarning ,
569+ stacklevel = 2 ,
570+ )
571+ if vertical :
572+ tmux_args += ("-v" ,)
573+ else :
574+ tmux_args += ("-h" ,)
551575 else :
552- tmux_args += ( "-h" , )
576+ tmux_args += tuple ( PANE_DIRECTION_FLAG_MAP [ PaneDirection . Below ] )
553577
554578 if size is not None :
555579 if has_lt_version ("3.1" ):
0 commit comments