Resize terminal and scrolling problem with ncurses

后端 未结 3 2065
[愿得一人]
[愿得一人] 2020-12-10 07:00

I\'m programming in C using ncurses libraries (it\'s the first time) and I\'ve two problems. I\'m on ubuntu with the default terminal (gnome terminal).

1) I need to

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 07:04

    You can't resize the terminal window from ncurses but you can resize the terminal which the resize system call.

    #include 
    #include 
    
    int main(int argc, char *argv[]){
        WINDOW *ventana1;
        system("resize -s 30 80");
        initscr();
        start_color();
        ventana1 = newwin(15, 50, 0, 0);
        init_pair(1,COLOR_YELLOW,COLOR_BLUE);
        init_pair(2,COLOR_BLUE, COLOR_YELLOW);
        wbkgd(ventana1,COLOR_PAIR(1));
        wprintw(ventana1, "POLLO");
        wrefresh(ventana1);
        wgetch(ventana1);
        wgetch(ventana1);
        system("resize -s 20 60");
        wbkgd(ventana1,COLOR_PAIR(2));
        wprintw(ventana1, "POLLO");
        wrefresh(ventana1);
        wgetch(ventana1);
        wgetch(ventana1);
        system("resize -s 35 85");
        system("clear");
        wbkgd(ventana1,COLOR_PAIR(1));
        wprintw(ventana1, "POLLO");
        wrefresh(ventana1);
        wgetch(ventana1);
        wgetch(ventana1);
        delwin(ventana1);
        endwin();
        system("resize -s 25 75");
    }
    

提交回复
热议问题