File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -104,17 +104,20 @@ def reset(self):
104104
105105 self .cmd ('send-keys' , '-R \; clear-history' )
106106
107- def split_window (self , attach = False ):
107+ def split_window (self , attach = False , vertical = True ):
108108 """Split window at pane and return newly created :class:`Pane`.
109109
110110 :param attach: Attach / select pane after creation.
111111 :type attach: bool
112+ :param vertical: split vertically
113+ :type vertical: bool
112114 :rtype: :class:`Pane`.
113115
114116 """
115117 return self .window .split_window (
116118 target = self .get ('pane_id' ),
117- attach = attach
119+ attach = attach ,
120+ vertical = vertical
118121 )
119122
120123 def set_width (self , width ):
Original file line number Diff line number Diff line change @@ -346,7 +346,8 @@ def split_window(
346346 self ,
347347 target = None ,
348348 start_directory = None ,
349- attach = True
349+ attach = True ,
350+ vertical = True
350351 ):
351352 """Split window and return the created :class:`Pane`.
352353
@@ -372,6 +373,8 @@ def split_window(
372373 :type start_directory: string
373374 :param target: ``target_pane`` to split.
374375 :type target: bool
376+ :param vertical: split vertically
377+ :type vertical: bool
375378
376379 :rtype: :class:`Pane`
377380
@@ -390,6 +393,11 @@ def split_window(
390393 else :
391394 tmux_args += ('-t%s' % self .panes [0 ].get ('pane_id' ),)
392395
396+ if vertical :
397+ tmux_args += ('-v' ,)
398+ else :
399+ tmux_args += ('-h' ,)
400+
393401 tmux_args += (
394402 '-P' , '-F%s' % '' .join (tmux_formats ) # output
395403 )
Original file line number Diff line number Diff line change @@ -100,12 +100,23 @@ def test_attached_pane(session):
100100
101101
102102def test_split_window (session ):
103- """Window.split_window() splits window, returns new Pane. """
103+ """Window.split_window() splits window, returns new Pane, vertical. """
104104 window_name = 'test split window'
105105 window = session .new_window (window_name = window_name , attach = True )
106106 pane = window .split_window ()
107107 assert len (window .panes ) == 2
108108 assert isinstance (pane , Pane )
109+ assert float (window .panes [0 ].height ) <= ((float (window .width ) + 1 ) / 2 )
110+
111+
112+ def test_split_window_horizontal (session ):
113+ """Window.split_window() splits window, returns new Pane, horizontal. """
114+ window_name = 'test split window'
115+ window = session .new_window (window_name = window_name , attach = True )
116+ pane = window .split_window (vertical = False )
117+ assert len (window .panes ) == 2
118+ assert isinstance (pane , Pane )
119+ assert float (window .panes [0 ].width ) <= ((float (window .width ) + 1 ) / 2 )
109120
110121
111122@pytest .mark .parametrize ("window_name_before,window_name_after" , [
You can’t perform that action at this time.
0 commit comments