nicktrou@rodan.acs.syr.edu (Nikos B. Troullinos) (09/12/90)
Can anyone shed some light in the following perplexing problem?
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!)
Compiling with cc under SUN OS 4.1 I get scrolling but also repainting
of the whole screen for each and every scroll! (whether idlok() is there or
not)
Compiling with /usr/5bin/cc (and the corresponding library) things
improve but instead of a simple echoing of a nl/cr, the insert/delete
capabilities of the terminal (vt100) are used and the cursor is sent for
a brief time on the upper left 'home' position. This is very noticeable
at a low baud rate.
Is it too much to ask for curses to behave reasonably and just send a nl/cr?
Or am I missing something really obvious? My little test program follows:
Nikos Troullinos, CIS
Syracuse University
---------------------------------------------------------------------------
#include <curses.h>
#define EOT 0x4
/*
Minimum curses program to make curses do A SIMPLE SCROLLING
under SUN OS 4.1 and with a vt100 terminal setting.
*/
void main()
{
int c;
initscr();
cbreak();
noecho();
nl();
idlok(stdscr, TRUE);
scrollok(stdscr, TRUE);
refresh();
while ((c=getch()) != EOT)
{addch(c);refresh();}
refresh();
endwin();
}
adb@cs.bu.edu (Adam Bryant) (09/12/90)
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