如何不显示从键盘输入的字符
作为一个学期的课程项目的一部分,我们正在编写一个模型火车系统。其中一部分是用于查看当前状态的监视器界面以及用于系统命令的键盘输入。当获取键盘输入时,我们不应该显示它们。
有没有办法禁用在屏幕上显示输入,或者如何从键盘流中获取这些输入?
目前使用 Ada.Text_IO 包并已使用 Get 和 Get_Immediate 进行了测试。
附加
我们不是针对 Linux 系统进行开发。我们正在为 MaRTE_OS 开发基本上可以称为独立终端的东西。该系统连接到数十个硬件板,其中大部分我没有见过,甚至可以告诉您它们的用途。
至于显示器,屏幕将完全充满频繁更新的输出(系统的一部分我有它刷新大约 0.05 秒的信息)。没有空间尝试尝试不显示信息,然后向上移动一行(也没有真正一次打印一行,显示类将其需要的内容直接打印到屏幕上的列、行) 。
输入不需要由输入它的用户进行审查,因为系统只是应该读取它并生成要处理的命令(它还有一个错误命令,用于错误的输入,并且除了允许系统执行任何操作之外,什么也不做)回到等待状态)。
As part of a semester long class project, we are programming a model train system. Part of this is a monitor interface for viewing the current status, and keyboard inputs for system commands. When getting the keyboard inputs, we are not supposed to display them.
Is there a way to disable displaying inputs to the screen or how would I get those from the keyboard stream?
Currently using Ada.Text_IO package and have tested with both Get and Get_Immediate.
Additional
We are not developing for a linux system. We are developing for MaRTE_OS on what can basically be called a stand-alone terminal. This system is connected to dozens of hardware boards most of which I haven't seen or could even tell you what they are there for.
As for the monitor, the screen will be completely filled with output updated frequently (part of the system I have it refreshing info about 0.05 sec). There is no room to attempt to try to not display the information and then shift back up a line (also nothing really gets printed a line at a time, the display class prints what it needs to straight to a col,row on the screen).
The input does not need to be reviewed by the user entering it as the system is just supposed to read it and generate a command to be processed (also it has an ERROR command that is there for bad inputs and just does nothing but allow the system to circle back to a waiting state).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道Ada,但你可以在unix系统上运行以下命令:
stty -echo
和stty -noecho
。他们切换回声模式。我在许多不同的语言中使用它并且它总是有效。I don't know Ada, but you can run the following commands on unix systems:
stty -echo
andstty -noecho
. They toggle the echo mode. I use this in many different languages and it always works.首先,我会验证需求。我可以看到没有重复该命令,但取消回显似乎有点对用户不利。或者,如果您的控制台支持 VT100 ANSI 转义序列,您可以使用
clear line
代码之一。First, I'd verify the requirement. I can see not repeating the command, but canceling echo seems a little user-hostile. Alternatively, if your console supports VT100 ANSI Escape Sequences, you could use one of the
clear line
codes.基于垃圾神的建议:
Building on trashgods suggestion :
如果您需要访问权限,您可以设置键盘中断,然后您可以“阻止他们通过”。
http://www.iuma.ulpgc.es/users/jmiranda /gnat-rts/node33.htm
If you have access required you can set up a keyboard interrupt then you could "head them off at the pass."
http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node33.htm