ncurses 1.9.9e stdscr refresh

ncurses 1.9.9e stdscr refresh

Post by Bob Nels » Sat, 30 Nov 1996 04:00:00



The following code should be self-explanatory if compiled (when
USE_STANDOUT is defined) and run. In my case, the OS is Linux
using ncurses 1.9.9e, with TERM=linux and the terminfo capabilities
for such as provided in that ncurses package:

/*
Attempt to understand why ncurses 1.9.9e exhibits a problem with
downward scrolling when color is also involved.

- The problem is apparent when the cursor is placed on line 16 (shown
  initially with a bright red attribute) and then moved to line 17.
  At this point, the A_STANDOUT attribute that should be applied when
  on the cursor line is not set. The problem is not evident when the
  cursor is moved from line 18 to 17 and then to line 16.

- The problem is not evident if an explicit color pair attribute is
  set instead of using A_STANDOUT.
*/

#include <stdio.h>
#include <ncurses.h>

static void update_display(int curs_line)
{
    int i, n, attr;
    char *curs_line_str;

    for(i = 0; i < LINES; i++) {
        curs_line_str = "";

        if(i != curs_line && i == 15) {
            attr = COLOR_PAIR(1)|A_BOLD;
        }
        else if(i == curs_line) {
#ifdef USE_STANDOUT
            attr = A_STANDOUT;
#else
            attr = COLOR_PAIR(2);
#endif
            curs_line_str = " cursor";
        }
        else {
            attr = A_BOLD;
        }

        move(i, 0);
        attron(attr);
        printw(" Current%s line number: %d (Attr: %d)%n",
               curs_line_str, i + 1, attr, &n);
        printw("%*s", COLS - n, "");
        attroff(attr);
    }

    refresh();

Quote:}

static void handle_keys(void)
{
    int key = 0, curs_line = 0;

    do {
        switch(key) {
        case 0:
            break;

        case 'j':
        case KEY_DOWN:
            if(curs_line < LINES - 1)
                curs_line++;
            else
                goto fetch;
            break;

        case 'k':
        case KEY_UP:
            if(curs_line > 0)
                curs_line--;
            else
                goto fetch;
            break;

        default:
            goto fetch;
        }

        update_display(curs_line);

fetch:
    } while((key = getch()) != 'q' && key != 'Q');

Quote:}

int main(void)
{

    initscr();
    nonl();
    noecho();
    cbreak();
    curs_set(0);
    keypad(stdscr, TRUE);
    leaveok(stdscr, TRUE);

    if(has_colors()) {
        start_color();
        init_pair(1, COLOR_RED, COLOR_BLACK);
#ifndef USE_STANDOUT
        init_pair(2, COLOR_BLUE, COLOR_WHITE);
#endif
    }

    handle_keys();
    endwin();

    return 0;

Quote:}

--
=============================================================================

     linux for fun, M$ for $$$...and the NFL for what really counts!
=============================================================================
 
 
 

1. problems with ncurses.1.9.9e

I have successfully (i.e. without any errors or warnings) complied
ncurses.1.9.9e on my system and know it says my terminal does not support
color. the terminal being the Linux console. I got the termcapfix.txt from
sunsite. but that didn't fix it. The version before worked fine. Does

ps..i have updated to latest gcc compiler and libs and binutils.x.x.03 not
09

2. iBCS module on 1.2.13 Linux

3. ncurses 1.9.9e/shared lib

4. C calling Fortran 77 shared library on OSF/1 (or DUnix ?)

5. ncurses 1.9.9e-9

6. Netscape Communocation Server

7. NCURSES 1.9.9e: tegtent:warning: termcap entry to long

8. Repent now...

9. HELP!!ibmenu.so.1.9.9e has inconsistent

10. libncurses.so.1.9.9e: problems with colors

11. /usr/lib/libmenu.so.1.9.9e has inconsistent soname

12. ncurses 1.9.1a arrow keys?

13. ncurses 1.9.9g error msg: "error opening terminal: console"