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

Methods included from Flatito::RegexFromSearch

#regex

Methods included from Utils

#truncate

Constructor Details

#initialize(options) ⇒ TTY

Returns a new instance of TTY.



94
95
96
97
# File 'lib/flatito/renderer.rb', line 94

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

Instance Method Details

#clear_lineObject



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

def clear_line
  stdout.print CLEAR_LINE
end

#endingObject



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

def ending
  clear_line
  show_cursor
  stdout.puts
end

#hide_cursorObject



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

def hide_cursor
  stdout.print HIDE_CURSOR
end

#prepareObject



99
100
101
102
# File 'lib/flatito/renderer.rb', line 99

def prepare
  listen_for_stdout_width_change
  hide_cursor
end


104
105
106
107
# File 'lib/flatito/renderer.rb', line 104

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


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

def print_pathname(pathname)
  clear_line
  super
end

#show_cursorObject



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

def show_cursor
  stdout.print SHOW_CURSOR
end