getch() 的文件描述符 [英] File descriptor of getch()

查看:70
本文介绍了getch() 的文件描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 libev 来监听终端中的键盘(击键)事件.我的想法是使用 (n)curses getch() 并设置 notimeout() (非阻塞)来告诉 getch() 不要等待下一次按键.

I want to use libev to listen for keyboard (keystrokes) events in the terminal. My idea is to use (n)curses getch() and set notimeout() (to be nonblocking) to tell getch() not to wait for next keypress.

是否有我可以观看的 getch 使用的文件描述符?

Is there a file descriptor that getch uses I can watch?

推荐答案

如果你使用 initscr(),你要求的文件描述符是 fileno(stdin),因为 initscr 子程序等效于:

If you use initscr(), the file descriptor you ask for is fileno(stdin), since the initscr subroutine is equivalent to:

newterm(getenv("TERM"), stdout, stdin); return stdscr;

如果使用newterm(type, outfile, infile),文件描述符为fileno(infile).

If you use newterm(type, outfile, infile), the file descriptor is fileno(infile).

这篇关于getch() 的文件描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆