From b94a396e34635df5c7c452746de6031552f3f492 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Thu, 31 Oct 2013 12:07:24 +0800 Subject: [PATCH] Fix bug where windows 1 and 2 load reversed. Add Window.move_window(). Remove superfluous log msg --- CHANGES | 2 ++ tmuxp/__init__.py | 2 +- tmuxp/window.py | 23 +++++++++++++++++++++-- tmuxp/workspacebuilder.py | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 1e7a36eef5..fa37e3be57 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,8 @@ Here you can find the recent changes to tmuxp. - [internal]: fix :meth:``Window.kill_window()`` target to ``session_id:window_index`` for compatibility and pass tests. - [docs] [examples]: Example for ``start_directory``. +- [internal] fix bug where first and second window would load in mixed order +- [internal] :class:`Window.move_window()` for moving window. 2013-10-30 ---------- diff --git a/tmuxp/__init__.py b/tmuxp/__init__.py index 652168471b..e3a93b35ae 100644 --- a/tmuxp/__init__.py +++ b/tmuxp/__init__.py @@ -22,4 +22,4 @@ import logging -__version__ = '0.0.29' +__version__ = '0.0.30' diff --git a/tmuxp/window.py b/tmuxp/window.py index 1a223ea71b..d805a4111e 100644 --- a/tmuxp/window.py +++ b/tmuxp/window.py @@ -251,8 +251,6 @@ def kill_window(self): Kill the current :class:`Window` object. - :param target_window: the ``target window``. - :type target_window: string ''' proc = self.tmux( @@ -266,6 +264,27 @@ def kill_window(self): self.server._update_windows() + def move_window(self, destination): + ''' + ``$ tmux move-window`` + + move the current :class:`Window` object. + + :param destination: the ``target window`` or index to move the window + to. + :type target_window: string + ''' + + proc = self.tmux( + 'move-window', + '-s%s:%s' % (self.get('session_id'), self.get('window_index')), + '-t%s' % destination, + ) + + if proc.stderr: + raise Exception(proc.stderr) + + self.server._update_windows() def select_pane(self, target_pane): ''' diff --git a/tmuxp/workspacebuilder.py b/tmuxp/workspacebuilder.py index 9287615c0f..dcaffe0f0c 100644 --- a/tmuxp/workspacebuilder.py +++ b/tmuxp/workspacebuilder.py @@ -164,7 +164,7 @@ def iter_create_windows(self, s): w1 = None if i == int(1): # if first window, use window 1 w1 = s.attached_window() - w1.attached_pane().send_keys('la') + w1.move_window(99) w = s.new_window( window_name=window_name, start_directory=wconf['start_directory'] if 'start_directory' in wconf else None,