[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoiding clearing the screen

From: Christer Enfors
Subject: Avoiding clearing the screen
Date: Thu, 20 Dec 2007 09:03:01 +0100
User-agent: Thunderbird (Windows/20071031)


I'm using ncurses 5.5 on an AIX 5.3 machine. I've had the TERM variable set to vt100 and dtterm, but both values produce the same result. I've created a menu program that uses the menu and panel libraries. My program uses three non-overlapping windows, each using their own panel. Meaning, if I understand panels correctly, I don't really need panels, but I included it from the start anyway because I thought that my program might eventually need overlapping windows (IE, panels).

Now, my problem is that the entire screen is cleared when I press a key to go up or down in the menu, which causes some terminals to flicker terribly. I was expecting ncurses to only redraw a subsection of the menu - the menu item that was previously selected, and the new one. That the entire screen is cleared is strange to me, because I don't clear the entire screen - I only clear one of my windows (which takes up the bottom fifth of the screen).

The function that causes the screen to be cleared is doupdate().

Here is the relevant parts of the code. Comments have been added for the purpose of this post. Irrelevant parts of the code have been replaced with /* [snip] */.

/* We start in this function. */
TreeNode *EnterMenu(TreeNode *node, ScreenInfo *screen_info)
 /* [snip] */

 while (done == 0)
     switch (getch()) /* User presses j or KEY_DOWN here. */
        case 'j':
        case KEY_DOWN:
          menu_driver(menu, REQ_DOWN_ITEM); /* Go one step down in menu. */
          do_redraw = 1;
/* [snip] */

     if (do_redraw)
          item = current_item(menu);
          active_node = item_userptr(item);
          /* Call PrintHelp, which clears bottom_win, which takes up the
           * bottom fifth of the screen. This function is included below
           * for reference.
          PrintHelp(active_node, screen_info->bottom_win);

          /* Call RedrawScreen, included below. */

     do_redraw = 0;

 /* [snip] */

/* [snip] */

void PrintHelp(TreeNode *node, WINDOW *win)
 MenuItemData *data;
 int lines, cols;

 assert(win != NULL);

 if (node == NULL)

 data = node->data;

 assert(data != NULL);

 wclear(win); /* Clear the bottom fifth of the screen. This is the
                * only part of the relevant code where any type of
                * clear function is called.
if (data->help)
     getmaxyx(win, lines, cols); /* Get size of window */
     WrapText(data->help, cols - 1);
     wattron(win, HELP_ATTR);
     waddstr(win, data->help);

/* [snip] */

void RedrawScreen()
 doupdate(); /* Somewhere in this function, the screen is cleard. Why? */

/* [snip] */

Any help would be appreciated.

Christer Enfors

reply via email to

[Prev in Thread] Current Thread [Next in Thread]