Module: Remedy::ANSI::Cursor

Extended by:
Remedy::ANSI
Defined in:
lib/remedy/ansi.rb

Class Method Summary collapse

Methods included from Remedy::ANSI

color, command, cursor, e, esc, push, pushe, pushesc, screen

Class Method Details

.beginning_of_line!Object



140
141
142
# File 'lib/remedy/ansi.rb', line 140

def beginning_of_line!
  to_column 0
end

.codeObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/remedy/ansi.rb', line 80

def code
  {
    # Movement
    home: 'H',
    up: '%{lines}A',
    down: '%{lines}B',
    to_column: '%{column}G',

    # May not work on all terminals.
    next_line: '%{lines}E',
    prev_line: '%{lines}F',

    # Visiblity
    show: '?25h',
    hide: '?25l'
  }
end

.down(lines = 1) ⇒ Object



102
103
104
# File 'lib/remedy/ansi.rb', line 102

def down lines = 1
  esc code[:down] % {lines: lines}
end

.hide!Object



124
125
126
# File 'lib/remedy/ansi.rb', line 124

def hide!
  pushesc code[:hide]
end

.home!Object



120
121
122
# File 'lib/remedy/ansi.rb', line 120

def home!
  pushesc code[:home]
end

.next_line(lines = 1) ⇒ Object



110
111
112
113
# File 'lib/remedy/ansi.rb', line 110

def next_line lines = 1
  #esc code[:next_line] % {lines: lines}
  down(lines) + to_column(0)
end

.next_line!(lines = 1) ⇒ Object



132
133
134
# File 'lib/remedy/ansi.rb', line 132

def next_line! lines = 1
  push next_line(lines)
end

.prev_line(lines = 1) ⇒ Object



115
116
117
118
# File 'lib/remedy/ansi.rb', line 115

def prev_line lines = 1
  #esc code[:prev_line] % {lines: lines}
  up(lines) + to_column(0)
end

.prev_line!(lines = 1) ⇒ Object



136
137
138
# File 'lib/remedy/ansi.rb', line 136

def prev_line! lines = 1
  push prev_line(lines)
end

.show!Object



128
129
130
# File 'lib/remedy/ansi.rb', line 128

def show!
  pushesc code[:show]
end

.to_column(column) ⇒ Object



98
99
100
# File 'lib/remedy/ansi.rb', line 98

def to_column column
  esc code[:to_column] % {column: column}
end

.up(lines = 1) ⇒ Object



106
107
108
# File 'lib/remedy/ansi.rb', line 106

def up lines = 1
  esc code[:up] % {lines: lines}
end