From: "Dr. Adrian Wrigley" <amtw@linuxchip.demon.co.uk.uk.uk>
Subject: Cursor control question - ncurses and alternatives
Date: Fri, 13 Oct 2006 16:32:30 GMT
Date: 2006-10-13T16:32:30+00:00 [thread overview]
Message-ID: <pan.2006.10.13.16.30.06.922066@linuxchip.demon.co.uk.uk.uk> (raw)
Hi!
This should be a fairly simple Ada problem to solve...
I'm trying to build a small, text-based, real-time application,
to run in an xterm under Linux.
I want the user to be prompted to type in a command with a
prompt which shows the time, along with some other dynamic
information.
As the user types in a command, the prompt should continue
updating, until return is pressed. Then the updating stops,
an action is performed, and the prompt appears on another line.
What Ada library is likely to be easiest to use for cursor
control? I hear there is an ncurses binding, but this seems
to have hundreds of calls.
At the most basic level, I want to move the cursor to the start
of the line, update the prompt, and move the cursor back to
where it was. How can I do this?
I have some test code, shown below, to illustrate the problem.
Currently, the cursor moves to the end of the prompt
spontaneously, when it should be at the end of the user's command.
I don't want to take over the xterm with a "full-screen" application,
I just want to enter a series of commands in a scrolling terminal.
Is this a job for ncurses? What function is needed?
Or is there a better way?
Thanks for your suggestions!
--
Adrian
with Text_IO;
with Ada.Characters.Latin_1;
procedure TimDat is
Count : Integer := 1000;
function A return Integer is
begin
Count := Count + 1;
return Count;
end A;
Message : String := "Hello";
CR : constant Character := Ada.Characters.Latin_1.CR;
task ShowClock;
task body ShowClock is
begin
loop
declare
S : String := Integer'Image (A);
begin
Text_IO.Put (CR & S & " - " & Message & " > ");
end;
delay 1.0;
end loop;
end ShowClock;
begin
loop
declare
Command : String := Text_IO.Get_Line (Text_IO.Standard_Input);
begin
Text_IO.Put_Line ("Command was """ & Command & """");
end;
end loop;
end TimDat;
----------------------------------------------------------------
next reply other threads:[~2006-10-13 16:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-13 16:32 Dr. Adrian Wrigley [this message]
2006-10-13 18:16 ` Cursor control question - ncurses and alternatives Dmitry A. Kazakov
2006-10-13 21:13 ` Jeffrey R. Carter
2006-10-13 22:41 ` Björn Persson
2006-10-14 2:38 ` Dr. Adrian Wrigley
2006-10-14 12:53 ` Dr. Adrian Wrigley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox