Sha256: 3d6938500fed664851d723e3ff72d58a736c1bf51d1435b91845c9a03c62c72d
Contents?: true
Size: 823 Bytes
Versions: 2
Compression:
Stored size: 823 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) 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 end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubytext-0.0.97 | lib/widgets.rb |
rubytext-0.0.96 | lib/widgets.rb |