12
12
import warnings
13
13
from typing import overload
14
14
15
+ from _pytest import cacheprovider
16
+
15
17
from libtmux .common import has_gte_version , has_lt_version , tmux_cmd
16
18
from libtmux .constants import (
17
19
RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP ,
20
+ SPLIT_WINDOW_DIRECTION_FLAG_MAP ,
18
21
ResizeAdjustmentDirection ,
22
+ SplitWindowDirection ,
19
23
)
20
24
from libtmux .formats import FORMAT_SEPARATOR
21
25
from libtmux .neo import Obj , fetch_obj
@@ -489,15 +493,14 @@ def split(
489
493
self ,
490
494
start_directory : t .Optional [str ] = None ,
491
495
attach : bool = False ,
492
- vertical : bool = True ,
496
+ direction : t . Optional [ SplitWindowDirection ] = None ,
493
497
shell : t .Optional [str ] = None ,
494
498
size : t .Optional [t .Union [str , int ]] = None ,
495
- percent : t .Optional [int ] = None , # deprecated
496
499
environment : t .Optional [t .Dict [str , str ]] = None ,
500
+ percent : t .Optional [int ] = None , # deprecated
501
+ vertical : t .Optional [bool ] = None ,
497
502
) -> "Pane" :
498
- """Split window and return the created :class:`Pane`.
499
-
500
- Used for splitting window and holding in a python object.
503
+ """Split window and return :class:`Pane`, by default beneath current pane.
501
504
502
505
Parameters
503
506
----------
@@ -506,8 +509,8 @@ def split(
506
509
True.
507
510
start_directory : str, optional
508
511
specifies the working directory in which the new window is created.
509
- vertical : bool , optional
510
- split vertically
512
+ direction : SplitWindowDirection , optional
513
+ split in direction. If none is specified, assume down.
511
514
shell : str, optional
512
515
execute a command on splitting the window. The pane will close
513
516
when the command exits.
@@ -522,6 +525,8 @@ def split(
522
525
window.
523
526
environment: dict, optional
524
527
Environmental variables for new pane. tmux 3.0+ only. Passthrough to ``-e``.
528
+ vertical : bool, optional
529
+ split vertically, deprecated by ``direction``.
525
530
526
531
Notes
527
532
-----
@@ -534,6 +539,11 @@ def split(
534
539
active. To remain on the same window and split the pane in another
535
540
target window, pass in ``attach=False``.
536
541
542
+ .. deprecated:: 0.33.0
543
+
544
+ ``vertical=True`` deprecated in favor of
545
+ ``direction=SplitWindowDirection.Below``.
546
+
537
547
.. versionchanged:: 0.28.0
538
548
539
549
``attach`` default changed from ``True`` to ``False``.
@@ -546,10 +556,28 @@ def split(
546
556
547
557
tmux_args : t .Tuple [str , ...] = ()
548
558
549
- if vertical :
550
- tmux_args += ("-v" ,)
559
+ if direction :
560
+ tmux_args += tuple (SPLIT_WINDOW_DIRECTION_FLAG_MAP [direction ])
561
+ if vertical is not None :
562
+ warnings .warn (
563
+ "vertical is not required to pass with direction." ,
564
+ category = DeprecationWarning ,
565
+ stacklevel = 2 ,
566
+ )
567
+ elif vertical is not None :
568
+ warnings .warn (
569
+ "vertical is deprecated in favor of direction." ,
570
+ category = DeprecationWarning ,
571
+ stacklevel = 2 ,
572
+ )
573
+ if vertical :
574
+ tmux_args += ("-v" ,)
575
+ else :
576
+ tmux_args += ("-h" ,)
551
577
else :
552
- tmux_args += ("-h" ,)
578
+ tmux_args += tuple (
579
+ SPLIT_WINDOW_DIRECTION_FLAG_MAP [SplitWindowDirection .Below ]
580
+ )
553
581
554
582
if size is not None :
555
583
if has_lt_version ("3.1" ):
0 commit comments