Home:ALL Converter>Curses Pad strange behivour

Curses Pad strange behivour

Ask Time:2014-06-29T13:54:51         Author:Mattan

Json Formatter

I'm trying to create a text viewer that is wider than the screen so that I can scroll right and left. I'm using Curses::Pad for this. The documentation states that Pad can be bigger than the screen.

Please consider the following code:

#!/usr/bin/ruby2.1

require 'curses'

Curses.init_screen

pad = Curses::Pad.new Curses.lines, Curses.cols * 10

0.upto(200) do |i|
  pad.setpos(i, 0)
  pad.addstr(0.upto(600).to_a.join(","))
end

pad.refresh 0,0,0,0,Curses.lines,Curses.cols
sleep(3)
pad.refresh 0,200,0,0,Curses.lines,Curses.cols

sleep(200)

When the Pad size is bigger than the screen size, nothing is shown. When the Pad size is the same as the screen size, the second refresh fails unless min_pad_col is smaller than pad.

Cab anyone point what am I doing wrong?

Author:Mattan,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/24473539/curses-pad-strange-behivour
yy