Ruby 诅咒中的退格字符
及Ruby 诅咒中的退格字符,ruby,curses,Ruby,Curses,及 我想打印一个0,0消失,然后是1,然后是1消失,然后是2,然后是2消失,一直到6,delch删除光标下的字符。您只需重置光标位置: 6.times do |i| win2.addstr i.to_s win2.addstr '\b' sleep 0.6 win2.refresh end #=> 0\n,1\n,2\n,3\n,4\n,5\n,6\n 6.times do |i| w
我想打印一个0,0消失,然后是1,然后是1消失,然后是2,然后是2消失,一直到6,delch删除光标下的字符。您只需重置光标位置:
6.times do |i|
win2.addstr i.to_s
win2.addstr '\b'
sleep 0.6
win2.refresh
end #=> 0\n,1\n,2\n,3\n,4\n,5\n,6\n
6.times do |i|
win2.addstr i.to_s
win2.addstr '\b'
sleep 0.6
win2.refresh
end #=> 0\n,1\n,2\n,3\n,4\n,5\n,6\n
6.times do |i|
win2.setpos(1, 1)
win2.addstr i.to_s
win2.refresh
sleep 0.6
end