Class: RawLine::Terminal
- Inherits:
-
Object
- Object
- RawLine::Terminal
- Includes:
- HighLine::SystemExtensions
- Defined in:
- lib/rawline/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 RawLine::Terminal is automatically instantiated by RawLine::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 RawLine::Terminal.
-
#update ⇒ Object
Update the terminal escape sequences.
Constructor Details
#initialize ⇒ Terminal
Create an instance of RawLine::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/rawline/terminal.rb', line 31 def initialize @keys = { :tab => [?\t.ord], :return => [?\r.ord], :newline => [?\n.ord], :escape => [?\e.ord], :ctrl_a => [?\C-a.ord], :ctrl_b => [?\C-b.ord], :ctrl_c => [?\C-c.ord], :ctrl_d => [?\C-d.ord], :ctrl_e => [?\C-e.ord], :ctrl_f => [?\C-f.ord], :ctrl_g => [?\C-g.ord], :ctrl_h => [?\C-h.ord], :ctrl_i => [?\C-i.ord], :ctrl_j => [?\C-j.ord], :ctrl_k => [?\C-k.ord], :ctrl_l => [?\C-l.ord], :ctrl_m => [?\C-m.ord], :ctrl_n => [?\C-n.ord], :ctrl_o => [?\C-o.ord], :ctrl_p => [?\C-p.ord], :ctrl_q => [?\C-q.ord], :ctrl_r => [?\C-r.ord], :ctrl_s => [?\C-s.ord], :ctrl_t => [?\C-t.ord], :ctrl_u => [?\C-u.ord], :ctrl_v => [?\C-v.ord], :ctrl_w => [?\C-w.ord], :ctrl_x => [?\C-x.ord], :ctrl_y => [?\C-y.ord], :ctrl_z => [?\C-z.ord] } @escape_codes = [] @escape_sequences = [] update end |
Instance Attribute Details
#escape_codes ⇒ Object
Returns the value of attribute escape_codes.
25 26 27 |
# File 'lib/rawline/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/rawline/terminal.rb', line 26 def escape_sequences @escape_sequences end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
26 27 28 |
# File 'lib/rawline/terminal.rb', line 26 def keys @keys end |
Instance Method Details
#update ⇒ Object
Update the terminal escape sequences. This method is called automatically by RawLine::Editor#bind().
75 76 77 78 79 80 81 82 |
# File 'lib/rawline/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 |