Sha256: 1b6d5d4317195f4639a25dab1fd3718989c32b40977b83d5a827baad3ac95f85
Contents?: true
Size: 863 Bytes
Versions: 1
Compression:
Stored size: 863 Bytes
Contents
module RubyText def self.ticker(row: STDSCR.rows-1, col: 0, width: STDSCR.cols, fg: White, bg: Blue, text:, delay: 0.1) text = text.gsub("\n", " ") + " " win = RubyText.window(1, width, r: row, c: col, border: false, fg: fg, bg: bg) leader = " "*width + text leader = text.chars.cycle.each_cons(width) width.times { win.rcprint 0, 0, leader.next.join } repeat = text.chars.cycle.each_cons(width) loop do # Warning: loops forever win.rcprint 0, 0, repeat.next.join sleep delay end end def self.spinner(win: STDSCR, &block) # TODO delay, etc. chars = "-\\|/" RubyText.hide_cursor thread = Thread.new { i=0; loop { i = (i+1) % 4; win.print chars[i]; win.left; sleep 0.1 } } block.call win.puts Thread.kill(thread) RubyText.show_cursor end # TODO add splash end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubytext-0.0.98 | lib/widgets.rb |