我正在尝试使用ncurses函数mvwprintw进行打印,但是无法在给定的窗口中打印?
while (tmp2->next != NULL) { // Adjust coord for local win for printf
mvwprintw (local_win, start_y, start_x, "%d ", tmp2->n);
tmp2 = tmp2->next;
}
this piece of code does not produce expected result.
/*
* === FUNCTION ====================================================
* Name: void traversebeg()
* Description: Traverse from beginning
* ===================================================================
*/
#ifdef _TEST_
void traversebeg()
{
int height, width, start_y, start_x;
height = 22;
width = 70;
start_y = (LINES - height)/2;
start_x = (COLS - width)/2;
char *msg = "Double linked List is EMPTY! Nothing to show!";
WINDOW *local_win = newwin (height, width, start_y, start_x);
box (local_win, 0, 0);
wrefresh(local_win);
tmp2 = h;
getmaxyx (local_win, start_y, start_x);
if (tmp2 == NULL) {
mvwprintw (local_win, start_y/2, (start_x - strlen(msg))/2, "%s",msg);
wgetch(local_win);
wclear (local_win);
destroy_win (local_win);
return;
}
getmaxyx (local_win, start_y, start_x); // Extract coord for local_win
mvwprintw (local_win, start_y, start_x, "List element from beginning: ");
refresh();
while (tmp2->next != NULL) { // Adjust coord for local win for printf
mvwprintw (local_win, start_y, start_x, "%d ", tmp2->n);
tmp2 = tmp2->next;
}
mvwprintw (local_win, start_y +1, start_x, "Press key exit");
wgetch (local_win);
wclear (local_win);
destroy_win (local_win);
} /* ----- end of function void traversebeg() ----- */
mvwprintw函数将在同一行上打印tmp2结构的所有枚举。 尽管ncurses函数printw可以完成此工作,但是它没有在给定的窗口中打印,而是在窗口外打印,并且活动完成后,文本仍保留在屏幕上。完成后必须清除屏幕。