Class: TermDump::Terminal
- Inherits:
-
BasicTerminal
- Object
- BasicTerminal
- TermDump::Terminal
- Defined in:
- lib/termdump/terminal/guake.rb,
lib/termdump/terminal/tilda.rb,
lib/termdump/terminal/urxvt.rb,
lib/termdump/terminal/xterm.rb,
lib/termdump/terminal/konsole.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.
Attributes inherited from BasicTerminal
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
Each tilda’s window is toggled by different key binding, For example, first tilda window is toggled by F1, second one by F2, …
Methods inherited from BasicTerminal
#configure, #wait_for_launching
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 super config @keybindings = '/apps/guake/keybindings/local' @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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/termdump/terminal/terminator.rb', line 43 def parse_configure lines config = {} lines.each do |line| line.lstrip! unless line.start_with?('#') key, value = line.split('=', 2) key.strip! key = @@CONFIGURE_KEY_MAPPER[key] value = value.match('\A\s*"(.*?)"') unless key.nil? || value.nil? config[key] = convert_key_sequence(value[1]) end # need to handle key end # not a comment line 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
Each tilda’s window is toggled by different key binding, For example, first tilda window is toggled by F1, second one by F2, … To keep simple, treat window as tab
28 29 30 |
# File 'lib/termdump/terminal/guake.rb', line 28 def window name, cwd, cmd tab name, cwd, cmd end |