LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 985|回复: 7

请教:curses程序为什么不能输入中文?

[复制链接]
发表于 2004-7-8 18:50:53 | 显示全部楼层 |阅读模式
#include <form.h>
#include <locale.h>

int main()
{ FIELD *field[3];
FORM *my_form;
int ch;

setlocale( LC_CTYPE, "" );

/* Initialize curses */
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
meta( stdscr,TRUE );

/* Initialize the fields */
field[0] = new_field(1, 10, 4, 18, 0, 0);
field[1] = new_field(1, 10, 6, 18, 0, 0);
field[2] = NULL;

/* Set field options */
set_field_back(field[0], A_UNDERLINE); /* Print a line for the option */
field_opts_off(field[0], O_AUTOSKIP); /* Don't go to next field when this */
/* Field is filled up */
set_field_back(field[1], A_UNDERLINE);
field_opts_off(field[1], O_AUTOSKIP);

/* Create the form and post it */
my_form = new_form(field);
post_form(my_form);
refresh();

mvprintw(4, 10, "Value 1:");
mvprintw(6, 10, "Value 2:");
refresh();

/* Loop through to get user requests */
while((ch = getch()) != KEY_F(1))
{ switch(ch)
{ case KEY_DOWN:
/* Go to next field */
form_driver(my_form, REQ_NEXT_FIELD);
/* Go to the end of the present buffer */
/* Leaves nicely at the last character */
form_driver(my_form, REQ_END_LINE);
break;
case KEY_UP:
/* Go to previous field */
form_driver(my_form, REQ_PREV_FIELD);
form_driver(my_form, REQ_END_LINE);
break;
default:
/* If this is a normal character, it gets */
/* Printed */
form_driver(my_form, ch);
break;
}
}

/* Un post form and free the memory */
unpost_form(my_form);
free_form(my_form);
free_field(field[0]);
free_field(field[1]);

endwin();
return 0;
}
发表于 2004-7-8 21:45:05 | 显示全部楼层
听说curses对中文支持不好,需要自己修改它的源代码。
发表于 2004-7-9 08:47:01 | 显示全部楼层
sco下没问题
 楼主| 发表于 2004-7-9 11:16:07 | 显示全部楼层
为什么SCO上可以
LINNUX上不行?
发表于 2004-7-9 12:46:01 | 显示全部楼层
不知你的“输入”指的是什么意思
如果是说,显示中文 我这倒有编译好的,可以显示中文(比如显示中文菜单)的版本,如果你 说的是要在输入框输入中文,我没试过。
 楼主| 发表于 2004-7-9 15:46:03 | 显示全部楼层
以上程序可以显示中文, 但输入中文form_driver不能接收,不是说
ncurses已经支持unicode了吗?
为什么SCO上可以,LINNUX上不行?
发表于 2004-7-11 15:47:12 | 显示全部楼层
莫非是终端的问题。你保证输入的汉字是unicode编码?
 楼主| 发表于 2004-7-12 17:54:31 | 显示全部楼层
其实在 form field 中也无法显示中文~
应该是 forms 的问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表