Can CURSES do a simple scroll?
Adam Bryant
adb at cs.bu.edu
Thu Sep 13 02:18:09 AEST 1990
In article <1990Sep12.051641.11113 at rodan.acs.syr.edu> nicktrou at rodan.acs.syr.edu (Nikos B. Troullinos) writes:
+
+ Path: bu.edu!rpi!uupsi!rodan.acs.syr.edu!nicktrou
+ From: nicktrou at rodan.acs.syr.edu (Nikos B. Troullinos)
+ Newsgroups: comp.unix.programmer
+ Keywords: curses
+ Date: 12 Sep 90 05:16:41 GMT
+ Organization: Syracuse University, Syracuse, NY
+ Lines: 49
+
+ I am trying to use CURSES in a program where decent scrolling off the
+ screen is required when the cursor is in the last line and a newline
+ is echoed (how unusual!)
+
+ void main()
+ {
+ int c;
+
+ initscr();
+ cbreak();
+ noecho();
+ nl();
+ idlok(stdscr, TRUE);
+ scrollok(stdscr, TRUE);
+ refresh();
+
+ while ((c=getch()) != EOT)
+ {addch(c);refresh();}
+ refresh();
+ endwin();
+ }
Try changing the line:
{addch(c); refresh(); }
to
{
if ((c == '\n') || (c == '\r'))
scroll(stdscr);
else
addch(c);
refresh();
}
I have only made a little use of the scrolling functionality of curses
myself, and have found that it often makes mistakes, such as when you
scroll up a line that has the same characters on the line about, it
forgets to redraw those characters during the scroll.
[I get around that by redrawing the entire screen all over again in
memory and then issuing a refresh(). The way to do that is to use:
move(0, 0);
clrtobot();
in place of 'clear()'. Only use 'clear()' when you absolutely know
that the screen will be greatly changed, since this tremendously
increased display speed]
Hope this correctly answers your question.
adam
ps. Now, if only curses would implement backward scrolling, my built
in pager would be really efficient.
--
Adam Bryant INTERNET: adb at cs.bu.edu
Conquer Hack'n'Slasher BITNET: adb at buenga
list: conquer-news-request at cs.bu.edu UUCP: ...!harvard!bu-cs!adb
More information about the Comp.unix.programmer
mailing list