Task is to print to the screen some continuously changing information without user input for some period of time using curses lib.
Following code illustrates idea.
require 'curses'
include Curses
str = String.new
init_screen()
5.times do |val|
str << "This is the #{val} time we've done something.\n"
addstr(str)
getstr
sleep 1
clear
end
close_screen
After pressing Enter 4th times out put is:
This is the 0 time we've done something.
This is the 1 time we've done something.
This is the 2 time we've done something.
This is the 3 time we've done something.
This is the 4 time we've done something.
But when i remove 'getstr', which i don't need, there is nothing prints out.
I would be greatful for advice or clue how to deal with curses in such situation. Thanks in advance.
You have to call refresh, to update the screen content:
init_screen()
5.times do |val|
str << "This is the #{val} time we've done something.\n"
addstr(str)
refresh
sleep 1
clear
end