15
15
from libtmux .common import has_gte_version , has_lt_version , tmux_cmd
16
16
from libtmux .constants import (
17
17
RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP ,
18
+ SPLIT_WINDOW_DIRECTION_FLAG_MAP ,
18
19
ResizeAdjustmentDirection ,
20
+ SplitWindowDirection ,
19
21
)
20
22
from libtmux .formats import FORMAT_SEPARATOR
21
23
from libtmux .neo import Obj , fetch_obj
@@ -489,15 +491,14 @@ def split(
489
491
self ,
490
492
start_directory : t .Optional [str ] = None ,
491
493
attach : bool = False ,
492
- vertical : bool = True ,
494
+ direction : t . Optional [ SplitWindowDirection ] = None ,
493
495
shell : t .Optional [str ] = None ,
494
496
size : t .Optional [t .Union [str , int ]] = None ,
495
- percent : t .Optional [int ] = None , # deprecated
496
497
environment : t .Optional [t .Dict [str , str ]] = None ,
498
+ percent : t .Optional [int ] = None , # deprecated
499
+ vertical : t .Optional [bool ] = None ,
497
500
) -> "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.
501
502
502
503
Parameters
503
504
----------
@@ -506,8 +507,8 @@ def split(
506
507
True.
507
508
start_directory : str, optional
508
509
specifies the working directory in which the new window is created.
509
- vertical : bool , optional
510
- split vertically
510
+ direction : SplitWindowDirection , optional
511
+ split in direction. If none is specified, assume down.
511
512
shell : str, optional
512
513
execute a command on splitting the window. The pane will close
513
514
when the command exits.
@@ -522,6 +523,8 @@ def split(
522
523
window.
523
524
environment: dict, optional
524
525
Environmental variables for new pane. tmux 3.0+ only. Passthrough to ``-e``.
526
+ vertical : bool, optional
527
+ split vertically, deprecated by ``direction``.
525
528
526
529
Notes
527
530
-----
@@ -534,6 +537,11 @@ def split(
534
537
active. To remain on the same window and split the pane in another
535
538
target window, pass in ``attach=False``.
536
539
540
+ .. deprecated:: 0.33.0
541
+
542
+ ``vertical=True`` deprecated in favor of
543
+ ``direction=SplitWindowDirection.Below``.
544
+
537
545
.. versionchanged:: 0.28.0
538
546
539
547
``attach`` default changed from ``True`` to ``False``.
@@ -546,10 +554,28 @@ def split(
546
554
547
555
tmux_args : t .Tuple [str , ...] = ()
548
556
549
- if vertical :
550
- tmux_args += ("-v" ,)
557
+ if direction :
558
+ tmux_args += tuple (SPLIT_WINDOW_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" ,)
551
575
else :
552
- tmux_args += ("-h" ,)
576
+ tmux_args += tuple (
577
+ SPLIT_WINDOW_DIRECTION_FLAG_MAP [SplitWindowDirection .Below ]
578
+ )
553
579
554
580
if size is not None :
555
581
if has_lt_version ("3.1" ):
0 commit comments