Class: Flatito::Renderer::TTY

Inherits:
Base
  • Object
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

#marker_prefix, #print_item, #print_items

Methods included from Flatito::RegexFromSearch

#regex, #value_regex

Methods included from Utils

#truncate

Constructor Details

#initialize(options) ⇒ TTY

Returns a new instance of TTY.



116
117
118
119
# File 'lib/flatito/renderer.rb', line 116

def initialize(options)
  super
  require "io/console"
end

Instance Method Details

#clear_lineObject



150
151
152
# File 'lib/flatito/renderer.rb', line 150

def clear_line
  stdout.print CLEAR_LINE
end

#endingObject



136
137
138
139
140
# File 'lib/flatito/renderer.rb', line 136

def ending
  clear_line
  show_cursor
  stdout.puts
end

#hide_cursorObject



142
143
144
# File 'lib/flatito/renderer.rb', line 142

def hide_cursor
  stdout.print HIDE_CURSOR
end

#prepareObject



121
122
123
124
# File 'lib/flatito/renderer.rb', line 121

def prepare
  listen_for_stdout_width_change
  hide_cursor
end


126
127
128
129
# File 'lib/flatito/renderer.rb', line 126

def print_file_progress(pathname)
  stdout.print truncate(pathname.to_s, max: stdout_width - 4)
  clear_line
end


131
132
133
134
# File 'lib/flatito/renderer.rb', line 131

def print_pathname(pathname)
  clear_line
  super
end

#show_cursorObject



146
147
148
# File 'lib/flatito/renderer.rb', line 146

def show_cursor
  stdout.print SHOW_CURSOR
end