Module: TermDump::TerminalHelper
- Included in:
- BasicTerminal
- Defined in:
- lib/termdump/terminal/base/terminal_helper.rb
Instance Method Summary collapse
-
#convert_key_sequence(in_sequence) ⇒ Object
Doing convertion below and join them with ‘+’ case 0 : <Ctrl><Shift><Alt><Super> => Ctrl Shift Alt Super case 1 : [A-Z] => [a-z] case 2 : <Primary> => Ctrl case 3 : [0-9] [a-z] UpDownLeftRight F Return space…
-
#escape(cmd) ⇒ Object
escape the command string so that it can be executed safily in the shell.
Instance Method Details
#convert_key_sequence(in_sequence) ⇒ Object
Doing convertion below and join them with ‘+’ case 0 : <Ctrl><Shift><Alt><Super> => Ctrl Shift Alt Super case 1 : [A-Z] => [a-z] case 2 : <Primary> => Ctrl case 3 : [0-9] [a-z] UpDownLeftRight F Return space… => not changed case 4 : <Control> => Ctrl For example, ‘<Primary><Shift>A’ => ‘Ctrl+Shift+a’ ‘<Alt>space’ => ‘Alt+space’
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/termdump/terminal/base/terminal_helper.rb', line 15 def convert_key_sequence in_sequence in_sequence.tr_s!('[<>]', ' ') out_sequence = in_sequence.split.map do |key| if /^[[:upper:]]$/.match(key) key.downcase elsif key == 'Primary' 'Ctrl' elsif key == 'Control' 'Ctrl' else key end end out_sequence.join('+') end |
#escape(cmd) ⇒ Object
escape the command string so that it can be executed safily in the shell
32 33 34 35 |
# File 'lib/termdump/terminal/base/terminal_helper.rb', line 32 def escape cmd # not woking under windows, but I don't think I will support windows :) Shellwords.escape cmd end |