Class: TermDump::Terminal
- Inherits:
-
BasicTerminal
- Object
- BasicTerminal
- TermDump::Terminal
- Defined in:
- lib/termdump/terminal/guake.rb,
lib/termdump/terminal/xterm.rb,
lib/termdump/terminal/base/mock.rb,
lib/termdump/terminal/terminator.rb,
lib/termdump/terminal/base/default.rb,
lib/termdump/terminal/gnome_terminal.rb
Overview
This Terminal class is for [gnome-terminal](wiki.gnome.org/Apps/Terminal)
Constant Summary collapse
- CONFIGURE_KEY_MAPPER =
{ 'new_tab' => 'new_tab', 'split_vert' => 'new_vsplit', 'split_horiz' => 'new_hsplit', 'new_window' => 'new_window' }
Instance Attribute Summary collapse
-
#done_actions ⇒ Object
readonly
Returns the value of attribute done_actions.
Instance Method Summary collapse
- #exec(cwd, cmd) ⇒ Object
- #get_configure_key(key) ⇒ Object
- #hsplit(name, cwd, cmd) ⇒ Object
-
#initialize(config) ⇒ Terminal
constructor
A new instance of Terminal.
-
#parse_configure(lines) ⇒ Object
Parse lines and fill @config with key mapper result.
- #tab(name, cwd, cmd) ⇒ Object
- #vsplit(name, cwd, cmd) ⇒ Object
-
#window(name, cwd, cmd) ⇒ Object
There is no ‘window’ concept in guake.
Methods inherited from BasicTerminal
Methods included from TerminalHelper
#convert_key_sequence, #escape
Constructor Details
#initialize(config) ⇒ Terminal
Returns a new instance of Terminal.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/termdump/terminal/guake.rb', line 7 def initialize config @user_defined_config = config @keybindings = '/apps/guake/keybindings' @config = { 'new_tab' => get_configure_key('new_tab') } @default_config = { 'new_window' => 'F12', 'new_tab' => 'ctrl+shift+t' } end |
Instance Attribute Details
#done_actions ⇒ Object (readonly)
Returns the value of attribute done_actions.
5 6 7 |
# File 'lib/termdump/terminal/base/mock.rb', line 5 def done_actions @done_actions end |
Instance Method Details
#exec(cwd, cmd) ⇒ Object
42 43 44 45 46 |
# File 'lib/termdump/terminal/guake.rb', line 42 def exec cwd, cmd exec_cmd = "cd #{cwd}" exec_cmd += " && #{cmd}" unless cmd.nil? || cmd == '' `guake -e #{escape(exec_cmd)}` end |
#get_configure_key(key) ⇒ Object
20 21 22 23 24 |
# File 'lib/termdump/terminal/guake.rb', line 20 def get_configure_key key value = IO.popen( "gconftool -g '#{@keybindings}/#{key}' 2>/dev/null").read.chomp value if value != '' end |
#hsplit(name, cwd, cmd) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/termdump/terminal/base/mock.rb', line 42 def hsplit name, cwd, cmd if cmd.nil? @done_actions.push(:hsplit, name, cwd) else @done_actions.push(:hsplit, name, cwd, cmd) end end |
#parse_configure(lines) ⇒ Object
Parse lines and fill @config with key mapper result.
The configure format of terminator:
- keybindings
-
full_screen = <Ctrl><Shift>F11
We only care about the keybindings.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/termdump/terminal/terminator.rb', line 44 def parse_configure lines config = {} in_keybindings = false lines.each do |line| line.rstrip! if in_keybindings if line.start_with?('[') || line == '' in_keybindings = false else key, value = line.split('=', 2) key.strip! first, _, third = value.rpartition('#') value = (first != "" ? first.strip : third.strip) key = CONFIGURE_KEY_MAPPER[key] unless key.nil? || value == '' config[key] = convert_key_sequence(value) end end end in_keybindings = true if line == '[keybindings]' end config end |
#tab(name, cwd, cmd) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/termdump/terminal/guake.rb', line 32 def tab name, cwd, cmd with_name = '' with_cwd = '' with_cmd = '' with_name = "-r #{escape(name)}" unless name.nil? || name == '' with_cwd = "-n #{escape(cwd)}" unless cwd.nil? || cwd == '' with_cmd = "-e #{escape(cmd)}" unless cmd.nil? || cmd == '' `guake #{with_name} #{with_cwd} #{with_cmd}` end |
#vsplit(name, cwd, cmd) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/termdump/terminal/base/mock.rb', line 34 def vsplit name, cwd, cmd if cmd.nil? @done_actions.push(:vsplit, name, cwd) else @done_actions.push(:vsplit, name, cwd, cmd) end end |
#window(name, cwd, cmd) ⇒ Object
There is no ‘window’ concept in guake. Only one terminal instance exists all the time. So treat it as tab
28 29 30 |
# File 'lib/termdump/terminal/guake.rb', line 28 def window name, cwd, cmd tab name, cwd, cmd end |