开发者

How to not show characters being entered from a keyboard

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 dis开发者_高级运维play 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).


I don't know Ada, but you can run the following commands on unix systems: stty -echo and stty -noecho. They toggle the echo mode. I use this in many different languages and it always works.


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 :

with Ada.Text_Io;
with Ada.Characters.Latin_1;

procedure Bsmain is
   Achar : Character := ' ';
   Escape: Character renames Ada.Characters.Latin_1.ESC;
begin
   Ada.Text_Io.Put (Escape & "[8m"); -- invisible text mode
   while Achar /= 'q' loop -- q=quit
      Ada.Text_Io.Get (Achar);
      Ada.Text_Io.Put (Escape & "[1A"); -- move cursor back up a line
   end loop;
   Ada.Text_Io.Put (Escape & "[m"); -- restore back to normal text mode
end Bsmain;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜