Class: InLine::Terminal
- Inherits:
-
Object
- Object
- InLine::Terminal
- Includes:
- HighLine::SystemExtensions
- Defined in:
- lib/inline/terminal.rb
Overview
The Terminal class defines character codes and code sequences which can be bound to actions by editors. An OS-dependent subclass of InLine::Terminal is automatically instantiated by InLine::Editor.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#escape_codes ⇒ Object
Returns the value of attribute escape_codes.
-
#escape_sequences ⇒ Object
readonly
Returns the value of attribute escape_sequences.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
Instance Method Summary collapse
-
#initialize ⇒ Terminal
constructor
Create an instance of InLine::Terminal.
-
#update ⇒ Object
Update the terminal escape sequences.
Constructor Details
#initialize ⇒ Terminal
Create an instance of InLine::Terminal.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/inline/terminal.rb', line 31 def initialize @keys = { :tab => [?\t], :return => [?\r], :newline => [?\n], :escape => [?\e], :ctrl_a => [?\C-a], :ctrl_b => [?\C-b], :ctrl_c => [?\C-c], :ctrl_d => [?\C-d], :ctrl_e => [?\C-e], :ctrl_f => [?\C-f], :ctrl_g => [?\C-g], :ctrl_h => [?\C-h], :ctrl_i => [?\C-i], :ctrl_j => [?\C-j], :ctrl_k => [?\C-k], :ctrl_l => [?\C-l], :ctrl_m => [?\C-m], :ctrl_n => [?\C-n], :ctrl_o => [?\C-o], :ctrl_p => [?\C-p], :ctrl_q => [?\C-q], :ctrl_r => [?\C-r], :ctrl_s => [?\C-s], :ctrl_t => [?\C-t], :ctrl_u => [?\C-u], :ctrl_v => [?\C-v], :ctrl_w => [?\C-w], :ctrl_x => [?\C-x], :ctrl_y => [?\C-y], :ctrl_z => [?\C-z] } @escape_codes = [] @escape_sequences = [] update end |
Instance Attribute Details
#escape_codes ⇒ Object
Returns the value of attribute escape_codes.
25 26 27 |
# File 'lib/inline/terminal.rb', line 25 def escape_codes @escape_codes end |
#escape_sequences ⇒ Object (readonly)
Returns the value of attribute escape_sequences.
26 27 28 |
# File 'lib/inline/terminal.rb', line 26 def escape_sequences @escape_sequences end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
26 27 28 |
# File 'lib/inline/terminal.rb', line 26 def keys @keys end |
Instance Method Details
#update ⇒ Object
Update the terminal escape sequences. This method is called automatically by InLine::Editor#bind().
75 76 77 78 79 80 81 82 |
# File 'lib/inline/terminal.rb', line 75 def update @keys.each_value do |k| l = k.length if l > 1 then @escape_sequences << k unless @escape_sequences.include? k end end end |