Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 你怎么看箭头键?_C_Unix_Xterm_Termios - Fatal编程技术网

C 你怎么看箭头键?

C 你怎么看箭头键?,c,unix,xterm,termios,C,Unix,Xterm,Termios,对使用termios和xterm的原始模式的广泛搜索导致大量引用“计时技巧”,以区分转义序列和转义字符的单独外观 那你怎么做呢 我不想使用诅咒,因为我不想清除屏幕。这是一个计算器风格的程序,因此保留“ticker tape”界面很重要。最终在。我完整地引用了相关信息 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!ncoast!allbe

对使用termios和xterm的原始模式的广泛搜索导致大量引用“计时技巧”,以区分转义序列和转义字符的单独外观

那你怎么做呢


我不想使用诅咒,因为我不想清除屏幕。这是一个计算器风格的程序,因此保留“ticker tape”界面很重要。

最终在。我完整地引用了相关信息

Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!usenet.ins.cwru.edu!ncoast!allbery From: all...@NCoast.ORG (Brandon S. Allbery KB8JRR) Newsgroups: comp.unix.programmer Subject: Re: How do you read the arrow keys? Message-ID: Date: 1 Jan 91 03:56:56 GMT References: Reply-To: all...@ncoast.ORG (Brandon S. Allbery KB8JRR) Followup-To: comp.unix.programmer Organization: North Coast Computer Resources (ncoast) Lines: 68 As quoted from by brn...@kramden.acf.nyu.edu (Dan Bernstein): +--------------- | It's really the terminal's fault, not the programmer's fault. Codes | coming from the terminal should be uniquely decodable as untimed byte | streams. In the best situation, no code is a prefix of another. +--------------- 对于不同的波特率,要获得正确的VTIME是很困难的;但这也是一个问题 一次性任务。我在自己的程序中使用了这个技巧;它工作得很好。 我相信SVR3诅咒中的函数键支持可以强制执行 如果启用了halfdelay()并在您的端口中工作,则此选项无效

对于BSD,我最多只能说检查您的版本(例如Ultrix 3.x 或SunOS 4.x等)支持termio接口,或等待BSD4.4 应该会有POSIX termios。(因为BSD4.4已退出或将退出) 很快——我已经和它失去了联系——毫无疑问会有人插话的 请注意,早期的Ultrix版本声称有termio 支持,但不起作用


我已经删掉了这位作者的签名栏,因为他承认自己无论如何都不是原作者。

cough ncurses couguse使用@AshishAhuja所说的方法。只有当终端设计为发送ESC的不同代码时。。。叹息;我想他们这样做是为了手动输入缺失的序列。我不知道为什么有三位评论者建议使用ncurses,而这显然不符合OP的要求。ncurses控制整个屏幕。大多数现代Shell都能在不强制全屏用户界面的情况下读取箭头键。termios变量的键:对于
VTIME
我建议
1
纠正25年的摩尔定律。
struct termio tbuf; /* POSIX: struct termios */
int maxlen = 3, len;
char buf[3];

ioctl(0, TCGETA, &tbuf); /* POSIX: tcgetattr(0, &tbuf); */
tbuf.c_lflags &= ~(ICANON|ECHO);
tbuf.c_cc[VMIN] = maxlen;
tbuf.c_cc[VTIME] = 2; /* 2/10 sec, good at 9600 baud and up */
ioctl(0, TCSETAW, &tbuf); /* POSIX: tcsetattr(0, X???WAIT, &tbuf); */
              /* I forget the exact flag */

len = read(0, buf, maxlen);
if (len == 1)
{
    /* single character */
}
else
{
    /* function key sequence */
}