tags:

views:

129

answers:

2

I need to implement a simple text reader, sort of like less for unix, using ncurses.

I'm having problems understanding how to do so. I currently have a window, and everytime I press the down key (for example) I refresh all the lines at the appropriate starting point, giving it a scrolling-like feel. The problem comes with text-wrapping, which unfortunately screws up my current system.

I was wondering if some of you already did something like this and could help me out. I frankly can't find anything related to this on Google other than "pad"s, which apparently aren't scrollable.

A: 

How do you have your curses window set up? Are you using stdscr? Have you played around with scrollok() ?

Gabe
A: 
   int prefresh(WINDOW *pad, int pminrow, int pmincol,
         int sminrow, int smincol, int smaxrow, int smaxcol);

prefresh's 2nd and 3rd parameters are its positioning values. With a little math you can increase/decrease pminrow for a vertical scrolling effect.

Luca Matteis