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

#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.



107
108
109
110
# File 'lib/flatito/renderer.rb', line 107

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

Instance Method Details

#clear_lineObject



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

def clear_line
  stdout.print CLEAR_LINE
end

#endingObject



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

def ending
  clear_line
  show_cursor
  stdout.puts
end

#hide_cursorObject



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

def hide_cursor
  stdout.print HIDE_CURSOR
end

#prepareObject



112
113
114
115
# File 'lib/flatito/renderer.rb', line 112

def prepare
  listen_for_stdout_width_change
  hide_cursor
end


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


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

def print_pathname(pathname)
  clear_line
  super
end

#show_cursorObject



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

def show_cursor
  stdout.print SHOW_CURSOR
end