Skip to content

Commit 6882aad

Browse files
committed
p.split_window() for splitting window at Pane
1 parent c159acb commit 6882aad

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

tmuxp/pane.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,19 @@ def reset(self):
9696

9797
self.tmux('send-keys', '-R \; clear-history')
9898

99+
def split_window(self, attach=False):
100+
"""Split window at pane and return newly created :class:`Pane`.
101+
102+
:param attach: Attach / select pane after creation.
103+
:type attach: bool
104+
:rtype: :class:`Pane`.
105+
106+
"""
107+
return self.window.split_window(
108+
target=self.get('pane_id'),
109+
attach=attach
110+
)
111+
99112
def set_width(self, width):
100113
"""Set width of pane.
101114

tmuxp/window.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def select_pane(self, target_pane):
290290

291291
return self.attached_pane()
292292

293-
def split_window(self, attach=True):
293+
def split_window(self, target=None, attach=True):
294294
"""Split window and return the created :class:`Pane`.
295295
296296
.. note::
@@ -309,7 +309,9 @@ def split_window(self, attach=True):
309309
310310
:param attach: make new window the current window after creating it,
311311
default True.
312-
:param type: bool
312+
:type attach: bool
313+
:param target: ``target_pane`` to split.
314+
:type target: bool
313315
314316
:rtype: :class:`Pane`
315317
@@ -321,10 +323,15 @@ def split_window(self, attach=True):
321323

322324
#'-t%s' % self.attached_pane().get('pane_id'),
323325
# 2013-10-18 LOOK AT THIS, rm'd it..
326+
tmux_args = tuple()
324327

325-
tmux_args = (
326-
'-t%s' % self.panes[0].get('pane_id'),
327-
'-P', '-F%s' % ''.join(tmux_formats), # output
328+
if target:
329+
tmux_args += ('-t%s' % target,)
330+
else:
331+
tmux_args += ('-t%s' % self.panes[-1].get('pane_index'),)
332+
333+
tmux_args += (
334+
'-P', '-F%s' % ''.join(tmux_formats) # output
328335
)
329336

330337
if not attach:

0 commit comments

Comments
 (0)