国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術(shù)文章
文章詳情頁

unix中的菜單程序

瀏覽:2日期:2024-06-10 09:07:09

#include <curses.h> #include <stdlib.h>

#define ENTER 10 #define ESCAPE 27 void init_curses() { initscr(); start_color(); init_pair(1,COLOR_WHITE,COLOR_BLUE); init_pair(2,COLOR_BLUE,COLOR_WHITE); init_pair(3,COLOR_RED,COLOR_WHITE); curs_set(0); noecho(); keypad(stdscr,TRUE); } void draw_menubar(WINDOW *menubar) { wbkgd(menubar,COLOR_PAIR(2)); waddstr(menubar,'Menu1'); wattron(menubar,COLOR_PAIR(3)); waddstr(menubar,'(F1)'); wattroff(menubar,COLOR_PAIR(3)); wmove(menubar,0,20); waddstr(menubar,'Menu2'); wattron(menubar,COLOR_PAIR(3)); waddstr(menubar,'(F2)'); wattroff(menubar,COLOR_PAIR(3)); } WINDOW **draw_menu(int start_col) { int i; WINDOW **items; items=(WINDOW **)malloc(9*sizeof(WINDOW *));

items[0]=newwin(10,19,1,start_col); wbkgd(items[0],COLOR_PAIR(2)); box(items[0],ACS_VLINE,ACS_HLINE); items[1]=subwin(items[0],1,17,2,start_col+1); items[2]=subwin(items[0],1,17,3,start_col+1); items[3]=subwin(items[0],1,17,4,start_col+1); items[4]=subwin(items[0],1,17,5,start_col+1); items[5]=subwin(items[0],1,17,6,start_col+1); items[6]=subwin(items[0],1,17,7,start_col+1); items[7]=subwin(items[0],1,17,8,start_col+1); items[8]=subwin(items[0],1,17,9,start_col+1); for (i=1;i<9;i++) wprintw(items[i],'Item%d',i); wbkgd(items[1],COLOR_PAIR(1)); wrefresh(items[0]); return items; } void delete_menu(WINDOW **items,int count) { int i; for (i=0;i<count;i++) delwin(items[i]); free(items); } int scroll_menu(WINDOW **items,int count,int menu_start_col) { int key; int selected=0; while (1) { key=getch(); if (key==KEY_DOWN || key==KEY_UP) { wbkgd(items[selected+1],COLOR_PAIR(2)); wnoutrefresh(items[selected+1]); if (key==KEY_DOWN) { selected=(selected+1) % count; } else { selected=(selected+count-1) % count; } wbkgd(items[selected+1],COLOR_PAIR(1)); wnoutrefresh(items[selected+1]); doupdate(); } else if (key==KEY_LEFT || key==KEY_RIGHT) { delete_menu(items,count+1); touchwin(stdscr); refresh(); items=draw_menu(20-menu_start_col); return scroll_menu(items,8,20-menu_start_col); } else if (key==ESCAPE) { return -1; } else if (key==ENTER) { return selected; } } } int main() { int key; WINDOW *menubar,*messagebar; init_curses(); bkgd(COLOR_PAIR(1)); menubar=subwin(stdscr,1,80,0,0); messagebar=subwin(stdscr,1,79,23,1); draw_menubar(menubar); move(2,1); printw('Press F1 or F2 to open the menus. '); printw('ESC quits.'); refresh();

do { int selected_item; WINDOW **menu_items; key=getch(); werase(messagebar); wrefresh(messagebar); if (key==KEY_F(1)) { menu_items=draw_menu(0); selected_item=scroll_menu(menu_items,8,0); delete_menu(menu_items,9); if (selected_item<0) wprintw(messagebar,'You haven't selected any item.'); else wprintw(messagebar, 'You have selected menu item %d.',selected_item+1); touchwin(stdscr); refresh(); } else if (key==KEY_F(2)) { menu_items=draw_menu(20); selected_item=scroll_menu(menu_items,8,20); delete_menu(menu_items,9); if (selected_item<0) wprintw(messagebar,'You haven't selected any item.'); else wprintw(messagebar, 'You have selected menu item %d.',selected_item+1); touchwin(stdscr); refresh(); } } while (key!=ESCAPE); delwin(menubar); delwin(messagebar); endwin(); return 0; }

標(biāo)簽: Unix系統(tǒng)
主站蜘蛛池模板: 成人a毛片手机免费播放 | 美女一丝不佳一级毛片香蕉 | 另类专区另类专区亚洲 | 欧美精品久久久久久久久大尺度 | 蜜桃欧美性大片 | 国产精品天天爽夜夜欢张柏芝 | 欧美aaaaaa| 国内精品七七久久影院 | 欧美激情毛片裸推荐 | 岛国伊人 | 亚洲精品成人网 | 久久成人福利视频 | 国产夫妇精品自在线 | 国产高清精品自在久久 | 久久精品全国免费观看国产 | 免费人成黄页网站在线观看 | 亚洲精品xxxx | 成人影院午夜久久影院 | 玖玖在线免费视频 | 免费大片黄手机在线观看 | 全部在线美女网站免费观看 | 香港a毛片免费全部播放 | 久久99国产精一区二区三区 | 亚洲在线视频免费观看 | 日本综合欧美一区二区三区 | 久久精品国产6699国产精 | 成人久久久 | 女人抠逼视频 | 国产粉嫩高中生无套第一次 | 经典香港a毛片免费观看 | 日韩精品在线观看免费 | www.一区二区三区.com | 免费视频精品一区二区三区 | 日本b站一卡二不卡 | 精品视频一区在线观看 | 高清在线一区二区三区亚洲综合 | 欧美精品日日鲁夜夜添 | 亚洲欧美另类视频 | 国产精品免费一区二区三区 | 亚洲欧美一区二区久久 | 国产精品色综合久久 |