【发布时间】:2012-12-20 11:34:24
【问题描述】:
如何在使用 C 的 STDIN 一段时间后按下 Tab 键时自动填充文本?
输入看起来像,
C:\>autofil.exe Hello
C:\>autofil.exe Hello. ( When I enter a period, it should autofil Hello after the period)
C:\>autofil.exe Hello.World *World is autofilled when period was entered.
第二个要求是我是否在
C:\>autofil.exe Hello.World (And when i press Tab key, `World` should print with other suggestions, as `Friend`, and if I press Tab again, print `Matt`, and scroll so on when tab is pressed... )
嗯,这是我的要求。选项卡完成以自动填充文本。另外,想知道如何从 STDIN 读取 Tab 键。
谢谢!
【问题讨论】:
-
您必须实现自定义外壳。当您发出启动命令时,您的程序尚未运行。
-
如果是
bash,实现一个简单的 bash-completion 函数是很容易的。但是,我在这里看到C:\>;) -
您不能“从标准输入读取密钥”,因为标准输入不是 tty。通常,stdin 与 tty 相关联,并且 tty 驱动程序正在检测关键事件并将字符发送到程序正在读取的流中,但 stdin 不是 tty。考虑按键事件根本没有任何意义。
标签: c