天天看點

curses庫顯示函數基本用法樣例

/* curses test
 * file name: cursestest.c
 * cmd: gcc cursestest.c -lcurses
 * author: yilonglucky#gmail.com
 */
#include <stdio.h>
#include <curses.h>

int main()
{
    initscr();
    
    /* bold */
    move(10, 20);
    attron(A_BOLD);
    addstr("Hello, ");
    
    refresh();
    sleep(1);
    
    /* bold + underline */
    attron(A_UNDERLINE);
    addstr("world!");
    
    refresh();
    sleep(1);
    
    /* underline */
    move(11, 20);
    attroff(A_BOLD);
    addstr("Hello, ");
    
    refresh();
    sleep(1);
    
    /* normal */
    attroff(A_UNDERLINE);
    addstr("world!");
    
    refresh();
    sleep(1);
    
    /* highlight */
    move(12, 20);
    standout();
    addstr("Hello, world!");
    standend();
    
    refresh();
    sleep(1);
    
    sleep(10);
    endwin();
    return 0;
}