Module: Term::ANSIColor::Movement

Included in:
Term::ANSIColor
Defined in:
lib/term/ansicolor/movement.rb

Instance Method Summary collapse

Instance Method Details

#clear_screen(string = nil, &block) ⇒ Object



54
55
56
# File 'lib/term/ansicolor/movement.rb', line 54

def clear_screen(string = nil, &block)
  erase_in_display(2, string, &block)
end

#erase_in_display(n = 0, string = nil, &block) ⇒ Object



58
59
60
# File 'lib/term/ansicolor/movement.rb', line 58

def erase_in_display(n = 0, string = nil, &block)
  move_command("\e[#{n}J", string, &block)
end

#erase_in_line(n = 0, string = nil, &block) ⇒ Object



62
63
64
# File 'lib/term/ansicolor/movement.rb', line 62

def erase_in_line(n = 0, string = nil, &block)
  move_command("\e[#{n}K", string, &block)
end

#hide_cursor(string = nil, &block) ⇒ Object



90
91
92
# File 'lib/term/ansicolor/movement.rb', line 90

def hide_cursor(string = nil, &block)
  move_command("\e[?25l", string, &block)
end

#move_backward(columns = 1, string = nil, &block) ⇒ Object



38
39
40
# File 'lib/term/ansicolor/movement.rb', line 38

def move_backward(columns = 1, string = nil, &block)
  move_command("\e[#{columns.to_i}D", string, &block)
end

#move_down(lines = 1, string = nil, &block) ⇒ Object



30
31
32
# File 'lib/term/ansicolor/movement.rb', line 30

def move_down(lines = 1, string = nil, &block)
  move_command("\e[#{lines.to_i}B", string, &block)
end

#move_forward(columns = 1, string = nil, &block) ⇒ Object



34
35
36
# File 'lib/term/ansicolor/movement.rb', line 34

def move_forward(columns = 1, string = nil, &block)
  move_command("\e[#{columns.to_i}C", string, &block)
end

#move_home(string = nil, &block) ⇒ Object



50
51
52
# File 'lib/term/ansicolor/movement.rb', line 50

def move_home(string = nil, &block)
  move_to(1, 1, string, &block)
end

#move_to(line = 1, column = 1, string = nil, &block) ⇒ Object



14
15
16
# File 'lib/term/ansicolor/movement.rb', line 14

def move_to(line = 1, column = 1, string = nil, &block)
  move_command("\e[#{line.to_i};#{column.to_i}H", string, &block)
end

#move_to_column(column = 1, string = nil, &block) ⇒ Object



18
19
20
# File 'lib/term/ansicolor/movement.rb', line 18

def move_to_column(column = 1, string = nil, &block)
  move_command("\e[#{column.to_i}G", string, &block)
end

#move_to_line(line = 1, string = nil, &block) ⇒ Object



22
23
24
# File 'lib/term/ansicolor/movement.rb', line 22

def move_to_line(line = 1, string = nil, &block)
  move_command("\e[#{line.to_i}f", string, &block)
end

#move_to_next_line(lines = 1, string = nil, &block) ⇒ Object



42
43
44
# File 'lib/term/ansicolor/movement.rb', line 42

def move_to_next_line(lines = 1, string = nil, &block)
  move_command("\e[#{lines}E", string, &block)
end

#move_to_previous_line(lines = 1, string = nil, &block) ⇒ Object



46
47
48
# File 'lib/term/ansicolor/movement.rb', line 46

def move_to_previous_line(lines = 1, string = nil, &block)
  move_command("\e[#{lines}F", string, &block)
end

#move_up(lines = 1, string = nil, &block) ⇒ Object



26
27
28
# File 'lib/term/ansicolor/movement.rb', line 26

def move_up(lines = 1, string = nil, &block)
  move_command("\e[#{lines.to_i}A", string, &block)
end

#restore_position(string = nil, &block) ⇒ Object



78
79
80
# File 'lib/term/ansicolor/movement.rb', line 78

def restore_position(string = nil, &block)
  move_command("\e[u", string, &block)
end

#return_to_position(string = nil, &block) ⇒ Object



82
83
84
# File 'lib/term/ansicolor/movement.rb', line 82

def return_to_position(string = nil, &block)
  save_position("") << move_command("", string, &block) << restore_position("")
end

#save_position(string = nil, &block) ⇒ Object



74
75
76
# File 'lib/term/ansicolor/movement.rb', line 74

def save_position(string = nil, &block)
  move_command("\e[s", string, &block)
end

#scroll_down(pages = 1, string = nil, &block) ⇒ Object



70
71
72
# File 'lib/term/ansicolor/movement.rb', line 70

def scroll_down(pages = 1, string = nil, &block)
  move_command("\e[#{pages}T", string, &block)
end

#scroll_up(pages = 1, string = nil, &block) ⇒ Object



66
67
68
# File 'lib/term/ansicolor/movement.rb', line 66

def scroll_up(pages = 1, string = nil, &block)
  move_command("\e[#{pages}S", string, &block)
end

#show_cursor(string = nil, &block) ⇒ Object



86
87
88
# File 'lib/term/ansicolor/movement.rb', line 86

def show_cursor(string = nil, &block)
  move_command("\e[?25h", string, &block)
end

#terminal_columnsObject



10
11
12
# File 'lib/term/ansicolor/movement.rb', line 10

def terminal_columns
  Tins::Terminal.columns
end

#terminal_linesObject



6
7
8
# File 'lib/term/ansicolor/movement.rb', line 6

def terminal_lines
  Tins::Terminal.lines
end