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

#no_color, #search

Instance Method Summary collapse

Methods inherited from Base

#print_item, #print_items

Constructor Details

#initialize(options) ⇒ TTY

Returns a new instance of TTY.



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

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

Instance Method Details

#clear_lineObject



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

def clear_line
  print CLEAR_LINE
end

#endingObject



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

def ending
  clear_line
  show_cursor
  puts
end

#hide_cursorObject



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

def hide_cursor
  print HIDE_CURSOR
end

#prepareObject



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

def prepare
  listen_for_stdout_width_change
  hide_cursor
end


118
119
120
121
# File 'lib/flatito/renderer.rb', line 118

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


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

def print_pathname(pathname)
  clear_line
  super
end

#show_cursorObject



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

def show_cursor
  print SHOW_CURSOR
end