Curses_overkill
Sometimes Curses or Ncurses is overkill. Ansi escape sequences will suffice. Here’s how to set that up with Ruby.
I only use Curses when I need pads or mouse-support.
require 'ostruct'
# -------------------------------------------
# Setup .. add more sequences and calls
# maybe -> { `tput lines` }
# and -> { `tput cols` }
Cur = OpenStruct.new(
save: -> { print "\e[s" },
restore: -> { print "\e[u" },
hide: -> { print "\e[?25l" },
show: -> { print "\e[?25h" },
goto: ->(x=0, y=0) { print "\e[#{y};#{x}H" },
up: ->(p=1) { print "\e[#{p}A" },
down: ->(p=1) { print "\e[#{p}B" },
right: ->(p=1) { print "\e[#{p}C" },
left: ->(p=1) { print "\e[#{p}D" },
)
Scr = OpenStruct.new(
cls: -> { print "\e[2J" },
)
# -----------------------------------------
# Usage :
Scr.cls[]
Cur.hide[]
Cur.goto[5,5]
print 'hejsan'
Cur.down[2]
print 'svejsan'
sleep(2)
Cur.show[]