From owner-freebsd-ports@FreeBSD.ORG Fri Dec 3 06:22:35 2004 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9C0AC16A4CE for ; Fri, 3 Dec 2004 06:22:35 +0000 (GMT) Received: from web20227.mail.yahoo.com (web20227.mail.yahoo.com [216.136.227.4]) by mx1.FreeBSD.org (Postfix) with SMTP id 61D3043D41 for ; Fri, 3 Dec 2004 06:22:35 +0000 (GMT) (envelope-from jianweirong@yahoo.com) Received: (qmail 42466 invoked by uid 60001); 3 Dec 2004 06:22:35 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=3LiwPF2l2Nm2JdCuf53vXtk9G5if81iUPsqNjbxBzGlEvFNBM/qEpk9l0XFlNlL3qDRG7k2Dipj27zfwQoocQoI3Pu055CBHkc0dAlT+qvbJju0vySRAAS5+tD+6CjIOjb6u1fE4KqfYXnwR0eHp+HYWQq+RGSsJmHWqOR2lIFE= ; Message-ID: <20041203062235.42464.qmail@web20227.mail.yahoo.com> Received: from [221.216.143.200] by web20227.mail.yahoo.com via HTTP; Fri, 03 Dec 2004 14:22:35 CST Date: Fri, 3 Dec 2004 14:22:35 +0800 (CST) From: Jianwei Rong To: trevor@FreeBSD.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="0-419996181-1102054955=:41863" Content-Transfer-Encoding: 8bit cc: ports@FreeBSD.org Subject: FreeBSD Port: ncurses-5.4 X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Dec 2004 06:22:35 -0000 --0-419996181-1102054955=:41863 Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline Good afternoon! The program of "menu_attrib.c" could not display chinese string. The enviroment is "FreeBSD 4.10, cce 0.51, ncurses 5.4". How to solve this problem? Thanks. rongjianwei 2004/12/03 ******************************** #include #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define CTRLD 4 char *choices[] = { "Choice 1", "English 2", "Choice 3", "选择 4", "Choice 5", "选择 6", "Choice 7", "Exit", }; int main() { ITEM **my_items; int c; MENU *my_menu; int n_choices, i; ITEM *cur_item; /* Initialize curses */ initscr(); start_color(); cbreak(); noecho(); keypad(stdscr, TRUE); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_MAGENTA, COLOR_BLACK); /* Initialize items */ n_choices = ARRAY_SIZE(choices); my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(choices[i], choices[i]); my_items[n_choices] = (ITEM *)NULL; item_opts_off(my_items[3], O_SELECTABLE); item_opts_off(my_items[6], O_SELECTABLE); /* Create menu */ my_menu = new_menu((ITEM **)my_items); /* Set fore ground and back ground of the menu */ set_menu_fore(my_menu, COLOR_PAIR(1) | A_REVERSE); set_menu_back(my_menu, COLOR_PAIR(2)); set_menu_grey(my_menu, COLOR_PAIR(3)); /* Post the menu */ mvprintw(LINES - 3, 0, "Press to see the option selected"); mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)"); post_menu(my_menu); refresh(); while((c = getch()) != KEY_F(1)) { switch(c) { case KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_UP: menu_driver(my_menu, REQ_UP_ITEM); break; case 10: /* Enter */ move(20, 0); clrtoeol(); mvprintw(20, 0, "Item selected is : %s", item_name(current_item(my_menu))); pos_menu_cursor(my_menu); break; } } unpost_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); free_menu(my_menu); endwin(); } _________________________________________________________ Do You Yahoo!? 注册世界一流品质的雅虎免费电邮 http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/ --0-419996181-1102054955=:41863 Content-Type: text/plain; name="menu_attrib.c" Content-Description: menu_attrib.c Content-Disposition: inline; filename="menu_attrib.c" #include #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define CTRLD 4 char *choices[] = { "Choice 1", "English 2", "Choice 3", "选择 4", "Choice 5", "选择 6", "Choice 7", "Exit", }; int main() { ITEM **my_items; int c; MENU *my_menu; int n_choices, i; ITEM *cur_item; /* Initialize curses */ initscr(); start_color(); cbreak(); noecho(); keypad(stdscr, TRUE); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_MAGENTA, COLOR_BLACK); /* Initialize items */ n_choices = ARRAY_SIZE(choices); my_items = (ITEM **)calloc(n_choices + 1, sizeof(ITEM *)); for(i = 0; i < n_choices; ++i) my_items[i] = new_item(choices[i], choices[i]); my_items[n_choices] = (ITEM *)NULL; item_opts_off(my_items[3], O_SELECTABLE); item_opts_off(my_items[6], O_SELECTABLE); /* Create menu */ my_menu = new_menu((ITEM **)my_items); /* Set fore ground and back ground of the menu */ set_menu_fore(my_menu, COLOR_PAIR(1) | A_REVERSE); set_menu_back(my_menu, COLOR_PAIR(2)); set_menu_grey(my_menu, COLOR_PAIR(3)); /* Post the menu */ mvprintw(LINES - 3, 0, "Press to see the option selected"); mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)"); post_menu(my_menu); refresh(); while((c = getch()) != KEY_F(1)) { switch(c) { case KEY_DOWN: menu_driver(my_menu, REQ_DOWN_ITEM); break; case KEY_UP: menu_driver(my_menu, REQ_UP_ITEM); break; case 10: /* Enter */ move(20, 0); clrtoeol(); mvprintw(20, 0, "Item selected is : %s", item_name(current_item(my_menu))); pos_menu_cursor(my_menu); break; } } unpost_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); free_menu(my_menu); endwin(); } --0-419996181-1102054955=:41863--