terminal: Open a new window instead of split on older tmux versions (<1.9)
PATCH v2 1/1 terminal: Open a new window instead of split on older tmux versions (<1.9)
From: Leonardo Sandoval <[email protected]>
If an old version is detected (<1.9), create a new window instead of split:
the reason is that there is no easy way to get the active pane height if no nested formats are supported.
--- meta/lib/oe/terminal.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
meta/lib/oe/terminal.py +15 -5
@@ -131,7 +131,7 @@ class TmuxRunning(Terminal): raise UnsupportedTerminal('tmux is not running') if not check_tmux_pane_size('tmux'): - raise UnsupportedTerminal('tmux pane too small') + raise UnsupportedTerminal('tmux pane too small or tmux < 1.9 version is being used') Terminal.__init__(self, sh_cmd, title, env, d)
@@ -218,6 +218,12 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): def check_tmux_pane_size(tmux): import subprocess as sub + # On older tmux versions (<1.9), return false. The reason + # is that there is no easy way to get the height of the active panel + # on current window without nested formats (available from version 1.9) + vernum = check_terminal_version("tmux") + if vernum and LooseVersion(vernum) < '1.9': + return False try: p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, shell=True,stdout=sub.PIPE,stderr=sub.PIPE)
@@ -229,14 +235,16 @@ def check_tmux_pane_size(tmux): return None else: raise - if size/2 >= 19: - return True - return False + + return size/2 >= 19 def check_terminal_version(terminalName): import subprocess as sub try: - p = sub.Popen(['sh', '-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) + cmdversion = '%s --version' % terminalName + if terminalName.startswith('tmux'): + cmdversion = '%s -V' % terminalName + p = sub.Popen(['sh', '-c', cmdversion], stdout=sub.PIPE,stderr=sub.PIPE) out, err = p.communicate() ver_info = out.rstrip().split('\n') except OSError as exc:
@@ -251,6 +259,8 @@ def check_terminal_version(terminalName): vernum = ver.split(' ')[-1] if ver.startswith('GNOME Terminal'): vernum = ver.split(' ')[-1] + if ver.startswith('tmux'): + vernum = ver.split()[-1] return vernum def distro_name():
Signature · 1 line
1.7.10.4
I verified this does work under tmux v1.8 with latest poky jethro.
Quoted 75 lines · On Fri, Nov 6, 2015 at 6:25 PM, <[email protected]>…
From: Leonardo Sandoval <[email protected]>
If an old version is detected (<1.9), create a new window instead of split:
the reason is that there is no easy way to get the active pane height if no nested formats are supported.Signed-off-by Leonardo Sandoval <[email protected]>--- meta/lib/oe/terminal.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)meta/lib/oe/terminal.py +15
-6@@ -131,7 +131,7 @@ class TmuxRunning(Terminal): raise UnsupportedTerminal('tmux is not running') if not check_tmux_pane_size('tmux'): - raise UnsupportedTerminal('tmux pane too small') + raise UnsupportedTerminal('tmux pane too small or tmux < 1.9 version is being used') Terminal.__init__(self, sh_cmd, title, env, d)@@ -218,6 +218,12 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): def check_tmux_pane_size(tmux): import subprocess as sub + # On older tmux versions (<1.9), return false. The reason + # is that there is no easy way to get the height of the active panel + # on current window without nested formats (available from version 1.9) + vernum = check_terminal_version("tmux") + if vernum and LooseVersion(vernum) < '1.9': + return False try: p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, shell=True,stdout=sub.PIPE,stderr=sub.PIPE)@@ -229,14 +235,16 @@ def check_tmux_pane_size(tmux): return None else: raise - if size/2 >= 19: - return True - return False + + return size/2 >= 19 def check_terminal_version(terminalName): import subprocess as sub try: - p = sub.Popen(['sh', '-c', '%s --version' % terminalName],stdout=sub.PIPE,stderr=sub.PIPE) + cmdversion = '%s --version' % terminalName + if terminalName.startswith('tmux'): + cmdversion = '%s -V' % terminalName + p = sub.Popen(['sh', '-c', cmdversion], stdout=sub.PIPE,stderr=sub.PIPE) out, err = p.communicate() ver_info = out.rstrip().split('\n') except OSError as exc:@@ -251,6 +259,8 @@ def check_terminal_version(terminalName): vernum = ver.split(' ')[-1] if ver.startswith('GNOME Terminal'): vernum = ver.split(' ')[-1] + if ver.startswith('tmux'): + vernum = ver.split()[-1] return vernum def distro_name(): --1.7.10.4
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Quoted 7 lines · On Fri, Nov 06, 2015 at 05:25:08PM -0600…
From: Leonardo Sandoval <[email protected]>
If an old version is detected (<1.9), create a new window instead of split:
the reason is that there is no easy way to get the active pane height if no nested formats are supported.Signed-off-by Leonardo Sandoval <[email protected]>
I gave the new release a spin over the weekend on Centos 7 which uses tmux 1.8. I couldn't run 'bitbake linux-yocto -c menuconfig' inside my tmux session due to this issue. Applying this patch fixed it though so I'd definitely recommend this for jethro as well as master.
Thanks,
Signature · 4 lines
Paul Barker Email: [email protected] http://www.paulbarker.me.uk