⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subscl.c

📁 BeginningLinuxProgramming example6
💻 C
字号:
/*  First, the initial code section. The base window display is initialized with some text.  */#include <unistd.h>#include <stdlib.h>#include <curses.h>int main() {    WINDOW *sub_window_ptr;    int x_loop;    int y_loop;    int counter;    char a_letter = '1';    initscr();    for (x_loop = 0; x_loop < COLS - 1; x_loop++) {        for (y_loop = 0; y_loop < LINES - 1; y_loop++) {            mvwaddch(stdscr, y_loop, x_loop, a_letter);            a_letter++;            if (a_letter > '9') a_letter = '1';        }    }/*  We now create the new scrolling subwindow    and, as advised, we must 'touch' the parent window before refreshing the screen.  */    sub_window_ptr = subwin(stdscr, 10, 20, 10, 10);    scrollok(sub_window_ptr, 1);    touchwin(stdscr);    refresh();    sleep(1);/*  Then we erase the contents of the subwindow, print text to it and refresh it.    The scrolling text is achieved by a loop.  */    werase(sub_window_ptr);    mvwprintw(sub_window_ptr, 2, 0, "%s", "This window will now scroll");    wrefresh(sub_window_ptr);    sleep(1);    for (counter = 1; counter < 10; counter++) {        wprintw(sub_window_ptr, "%s", "This text is both wrapping and \                    scrolling.");        wrefresh(sub_window_ptr);        sleep(1);    }/*  Having finished this loop, we delete the subwindow. Then we refresh the base screen.  */    delwin(sub_window_ptr);    touchwin(stdscr);    refresh();    sleep(1);    endwin();    exit(EXIT_SUCCESS);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -