浏览代码

- works with test ansi tty, but will need a rethink when we start

getting key_ codes instead
tags/v0.9.3
Dan Lynch 18 年前
父节点
当前提交
11e280670d
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6
    2
      src/hci/mucurses/kb.c

+ 6
- 2
src/hci/mucurses/kb.c 查看文件

@@ -94,7 +94,8 @@ int wgetnstr ( WINDOW *win, char *str, int n ) {
94 94
 
95 95
 	_str = str;
96 96
 
97
-	while ( ( ( c = wgetch( win ) ) != '\n' ) && !( n == 0 ) ) {
97
+	while (!( n == 0 ) ) {
98
+		c = wgetch( win );
98 99
 		if ( c >= 0401 && c <= 0633 ) {
99 100
 			switch(c) {
100 101
 			case KEY_LEFT :
@@ -107,7 +108,10 @@ int wgetnstr ( WINDOW *win, char *str, int n ) {
107 108
 				*_str = '\0';
108 109
 				break;
109 110
 			}
110
-		} else { // *should* only be ASCII chars now
111
+		} else if ( c == '\n' ) {
112
+			*_str = '\0';
113
+			break;
114
+		}else { // *should* only be ASCII chars now
111 115
 			*(_str++) = (char)c;
112 116
 			n--;
113 117
 		}

正在加载...
取消
保存