Class: RawLine::VT220Terminal

Inherits:
Terminal
  • Object
show all
Defined in:
lib/rawline/terminal/vt220_terminal.rb

Overview

This class is used to define all the most common character codes and escape sequences used on *nix systems.

Instance Attribute Summary

Attributes inherited from Terminal

#escape_codes, #escape_sequences, #input, #keys, #output

Instance Method Summary collapse

Methods inherited from Terminal

#clear_screen, #clear_screen_down, #clear_to_beginning_of_line, #cooked!, #cursor_position, #height, #move_down_n_rows, #move_left, #move_left_n_characters, #move_right_n_characters, #move_to_beginning_of_row, #move_to_column, #move_to_column_and_row, #move_up_n_rows, #preserve_cursor, #pseudo_cooked!, #puts, #raw!, #restore_tty_attrs, #snapshot_tty_attrs, #term_info, #update, #width

Constructor Details

#initialize(*args) ⇒ VT220Terminal

Returns a new instance of VT220Terminal.



20
21
22
23
24
25
26
27
28
29
30
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
# File 'lib/rawline/terminal/vt220_terminal.rb', line 20

def initialize(*args)
  super(*args)
  @escape_codes = [?\e.ord]
  @keys.merge!(
    {
      :alt_up_arrow => [?\e.ord, ?\e.ord, ?[.ord, ?A.ord],
      :alt_down_arrow => [?\e.ord, ?\e.ord, ?[.ord, ?B.ord],
      :alt_right_arrow => [?\e.ord, ?\e.ord, ?[.ord, ?C.ord],
      :alt_left_arrow => [?\e.ord, ?\e.ord, ?[.ord, ?D.ord],
      :up_arrow => [?\e.ord, ?[.ord, ?A.ord],
      :down_arrow => [?\e.ord, ?[.ord, ?B.ord],
      :right_arrow => [?\e.ord, ?[.ord, ?C.ord],
      :left_arrow => [?\e.ord, ?[.ord, ?D.ord],
      :insert => [?\e.ord, ?[, ?2.ord, ?~.ord],
      :delete => [?\e.ord, ?[, ?3.ord, ?~.ord],
      :backspace => [?\C-?.ord],
      :enter => (HighLine::SystemExtensions::CHARACTER_MODE == 'termios' ? [?\n.ord] : [?\r.ord]),

      :ctrl_alt_a => [?\e.ord, ?\C-a.ord],
      :ctrl_alt_b => [?\e.ord, ?\C-b.ord],
      :ctrl_alt_c => [?\e.ord, ?\C-c.ord],
      :ctrl_alt_d => [?\e.ord, ?\C-d.ord],
      :ctrl_alt_e => [?\e.ord, ?\C-e.ord],
      :ctrl_alt_f => [?\e.ord, ?\C-f.ord],
      :ctrl_alt_g => [?\e.ord, ?\C-g.ord],
      :ctrl_alt_h => [?\e.ord, ?\C-h.ord],
      :ctrl_alt_i => [?\e.ord, ?\C-i.ord],
      :ctrl_alt_j => [?\e.ord, ?\C-j.ord],
      :ctrl_alt_k => [?\e.ord, ?\C-k.ord],
      :ctrl_alt_l => [?\e.ord, ?\C-l.ord],
      :ctrl_alt_m => [?\e.ord, ?\C-m.ord],
      :ctrl_alt_n => [?\e.ord, ?\C-n.ord],
      :ctrl_alt_o => [?\e.ord, ?\C-o.ord],
      :ctrl_alt_p => [?\e.ord, ?\C-p.ord],
      :ctrl_alt_q => [?\e.ord, ?\C-q.ord],
      :ctrl_alt_r => [?\e.ord, ?\C-r.ord],
      :ctrl_alt_s => [?\e.ord, ?\C-s.ord],
      :ctrl_alt_t => [?\e.ord, ?\C-t.ord],
      :ctrl_alt_u => [?\e.ord, ?\C-u.ord],
      :ctrl_alt_v => [?\e.ord, ?\C-v.ord],
      :ctrl_alt_w => [?\e.ord, ?\C-w.ord],
      :ctrl_alt_x => [?\e.ord, ?\C-x.ord],
      :ctrl_alt_y => [?\e.ord, ?\C-y.ord],
      :ctrl_alt_z => [?\e.ord, ?\C-z.ord]
    })
end