lib/whirled_peas/ui/screen.rb in whirled_peas-0.2.0 vs lib/whirled_peas/ui/screen.rb in whirled_peas-0.3.0

- old
+ new

@@ -1,18 +1,16 @@ require 'highline' -require 'tty-cursor' require_relative 'ansi' require_relative 'painter' module WhirledPeas module UI class Screen def initialize(print_output=true) @print_output = print_output @terminal = HighLine.new.terminal - @cursor = TTY::Cursor @strokes = [] refresh_size! Signal.trap('SIGWINCH', proc { self.refresh_size! }) end @@ -24,14 +22,14 @@ def needs_refresh? @refreshed_width != width || @refreshed_height != height end def refresh - strokes = [cursor.hide, cursor.move_to(0, 0), cursor.clear_screen_down] + strokes = [Ansi.cursor_visible(false), Ansi.cursor_pos, Ansi.clear_down] Painter.paint(@template, Canvas.new(0, 0, width, height)) do |stroke| unless stroke.chars.nil? - strokes << cursor.move_to(stroke.left, stroke.top) + strokes << Ansi.cursor_pos(left: stroke.left, top: stroke.top) strokes << stroke.chars end end return unless @print_output strokes.each(&method(:print)) @@ -40,12 +38,12 @@ @refreshed_height = height end def finalize return unless @print_output - print UI::Ansi.clear - print cursor.move_to(0, height - 1) - print cursor.show + print Ansi.clear + print Ansi.cursor_pos(top: height - 1) + print Ansi.cursor_visible(true) STDOUT.flush end protected