Path: utzoo!attcan!uunet!snorkelwacker!bu.edu!nntp-read!adb From: adb@cs.bu.edu (Adam Bryant) Newsgroups: comp.unix.programmer Subject: Re: Can CURSES do a simple scroll? Message-ID: Date: 12 Sep 90 16:18:09 GMT References: <1990Sep12.051641.11113@rodan.acs.syr.edu> Sender: news@bu.edu.bu.edu Distribution: comp Organization: Boston University Lines: 69 In-reply-to: nicktrou@rodan.acs.syr.edu's message of 12 Sep 90 05:16:41 GMT In article <1990Sep12.051641.11113@rodan.acs.syr.edu> nicktrou@rodan.acs.syr.edu (Nikos B. Troullinos) writes: + + Path: bu.edu!rpi!uupsi!rodan.acs.syr.edu!nicktrou + From: nicktrou@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@cs.bu.edu Conquer Hack'n'Slasher BITNET: adb@buenga list: conquer-news-request@cs.bu.edu UUCP: ...!harvard!bu-cs!adb