我怎么能在另一个内部实现滚动窗口?

时间:2015-06-26 07:25:38

标签: c ncurses

我将命令行应用程序嵌入到ncurses-TUI中。 我的应用程序(客户端/服务器)应该能够在需要时打印很多行,但它必须保留在我定义的窗口中:

    /* Removed code */
    ITEM **my_items;
    int c;
    MENU *my_menu;
    WINDOW *my_menu_win;
    int n_choices, i;

    // Initialize curses
    initscr();                              // initializes the screen
    start_color();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);
    init_pair(1, COLOR_RED, COLOR_BLACK);
    /* Removed code */
    /* Create items */
    n_choices = ARRAY_SIZE(choices);
    my_items = (ITEM **)calloc(n_choices, sizeof(ITEM *));
    for(i = 0; i < n_choices; ++i)
    {
        my_items[i] = new_item(choices[i], choices[i]);
    }

    /* Removed code */
    /* Create menu */
    my_menu = new_menu((ITEM **)my_items);

    /* Set menu option not to show the description */
    menu_opts_off(my_menu, O_SHOWDESC);

    /* Create the window to be associated with the menu */
    my_menu_win = newwin(WIN_HEIGHT, WIN_WIDTH, WIN_YPOS, WIN_XPOS);
    keypad(my_menu_win, TRUE);

    /* Set main window and sub window */
    set_menu_win(my_menu, my_menu_win);
    set_menu_sub(my_menu, derwin(my_menu_win,  WIN_HEIGHT/2, WIN_WIDTH/2, WIN_HEIGHT/2-3, WIN_WIDTH/2-10));

    /* Set menu mark to the string " * " */
    set_menu_mark(my_menu, ">");

    /* Print a border around the main window and print a title */
    box(my_menu_win, 0, 0);
    /* Removed code */
    /* Post the menu */
    post_menu(my_menu);
    wrefresh(my_menu_win);

    endwin();       //resets the screen
}

enter image description here

1 如何在此窗口中添加一个带有滚动内容的窗口,其中通常会输出到终端的所有输出都将打印

2 ......或者是否可以将这些窗口与终端输出相关联?

0 个答案:

没有答案