Class: Flatito::Renderer::TTY
- Inherits:
-
Base
- Object
- Base
- Flatito::Renderer::TTY
show all
- Defined in:
- lib/flatito/renderer.rb
Constant Summary
collapse
- CSI =
"\e["
- CLEAR_LINE =
"#{CSI}K\e[0G".freeze
- HIDE_CURSOR =
"#{CSI}?25l".freeze
- SHOW_CURSOR =
"#{CSI}?25h".freeze
Instance Attribute Summary
Attributes inherited from Base
#case_sensitive, #no_color, #search, #search_value
Instance Method Summary
collapse
Methods inherited from Base
#print_item, #print_items
#regex, #value_regex
Methods included from Utils
#truncate
Constructor Details
#initialize(options) ⇒ TTY
Returns a new instance of TTY.
107
108
109
110
|
# File 'lib/flatito/renderer.rb', line 107
def initialize(options)
super
require "io/console"
end
|
Instance Method Details
#clear_line ⇒ Object
141
142
143
|
# File 'lib/flatito/renderer.rb', line 141
def clear_line
stdout.print CLEAR_LINE
end
|
#ending ⇒ Object
127
128
129
130
131
|
# File 'lib/flatito/renderer.rb', line 127
def ending
clear_line
show_cursor
stdout.puts
end
|
#hide_cursor ⇒ Object
133
134
135
|
# File 'lib/flatito/renderer.rb', line 133
def hide_cursor
stdout.print HIDE_CURSOR
end
|
#prepare ⇒ Object
112
113
114
115
|
# File 'lib/flatito/renderer.rb', line 112
def prepare
listen_for_stdout_width_change
hide_cursor
end
|
#print_file_progress(pathname) ⇒ Object
117
118
119
120
|
# File 'lib/flatito/renderer.rb', line 117
def print_file_progress(pathname)
stdout.print truncate(pathname.to_s, max: stdout_width - 4)
clear_line
end
|
#print_pathname(pathname) ⇒ Object
122
123
124
125
|
# File 'lib/flatito/renderer.rb', line 122
def print_pathname(pathname)
clear_line
super
end
|
#show_cursor ⇒ Object
137
138
139
|
# File 'lib/flatito/renderer.rb', line 137
def show_cursor
stdout.print SHOW_CURSOR
end
|