diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2015-02-04 10:09:12 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-02-07 18:52:44 +0000 |
commit | d7ef9e49b1c687279f6eb2c7abc32ff915714177 (patch) | |
tree | 07290ed3031202e1d6846f25caa087eeaf650b16 | |
parent | b2cee9b9f08dff41e46e227b1ffa5e46e98faa89 (diff) | |
download | openembedded-core-d7ef9e49b1c687279f6eb2c7abc32ff915714177.tar.gz openembedded-core-d7ef9e49b1c687279f6eb2c7abc32ff915714177.tar.bz2 openembedded-core-d7ef9e49b1c687279f6eb2c7abc32ff915714177.zip |
terminal.py: add tmux new window option
Add a new terminal type that makes a new window in the running tmux
session instead of splitting the window. 80x25 is not enough to run
menuconfig inside a split window, so add the option to create a new
window instead.
Use the new window option by default when the split window would be
less than 19 lines high.
Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r-- | meta/lib/oe/terminal.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py index 17d09045e4..54e3ffc1e8 100644 --- a/meta/lib/oe/terminal.py +++ b/meta/lib/oe/terminal.py @@ -116,6 +116,24 @@ class TmuxRunning(Terminal): if not os.getenv('TMUX'): raise UnsupportedTerminal('tmux is not running') + if not check_tmux_pane_size('tmux'): + raise UnsupportedTerminal('tmux pane too small') + + Terminal.__init__(self, sh_cmd, title, env, d) + +class TmuxNewWindow(Terminal): + """Open a new window in the current running tmux session""" + name = 'tmux-new-window' + command = 'tmux new-window -n "{title}" "{command}"' + priority = 2.70 + + def __init__(self, sh_cmd, title=None, env=None, d=None): + if not bb.utils.which(os.getenv('PATH'), 'tmux'): + raise UnsupportedTerminal('tmux is not installed') + + if not os.getenv('TMUX'): + raise UnsupportedTerminal('tmux is not running') + Terminal.__init__(self, sh_cmd, title, env, d) class Tmux(Terminal): @@ -184,6 +202,23 @@ def spawn(name, sh_cmd, title=None, env=None, d=None): if pipe.returncode != 0: raise ExecutionError(sh_cmd, pipe.returncode, output) +def check_tmux_pane_size(tmux): + import subprocess as sub + try: + p = sub.Popen('%s list-panes -F "#{?pane_active,#{pane_height},}"' % tmux, + shell=True,stdout=sub.PIPE,stderr=sub.PIPE) + out, err = p.communicate() + size = int(out.strip()) + except OSError as exc: + import errno + if exc.errno == errno.ENOENT: + return None + else: + raise + if size/2 >= 19: + return True + return False + def check_konsole_version(konsole): import subprocess as sub try: |