comp.lang.ada
 help / color / mirror / Atom feed
* Console management package for Linux
@ 1998-05-08  0:00 Jaume Obrador
  1998-05-08  0:00 ` Jerry van Dijk
  1998-05-08  0:00 ` Juergen Pfeifer
  0 siblings, 2 replies; 4+ messages in thread
From: Jaume Obrador @ 1998-05-08  0:00 UTC (permalink / raw)



I'm looking for a Console management package for Linux, wich supports
colors and cursor positioning (like J. van dyk Console package for
win95)

Jaume Obrador.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Console management package for Linux
  1998-05-08  0:00 Console management package for Linux Jaume Obrador
  1998-05-08  0:00 ` Jerry van Dijk
@ 1998-05-08  0:00 ` Juergen Pfeifer
  1 sibling, 0 replies; 4+ messages in thread
From: Juergen Pfeifer @ 1998-05-08  0:00 UTC (permalink / raw)



You should try ncurses from
ftp://prep.ai.mit.edu/pub/gnu/ncurses-4.2.tar.gz.
ncurses contains a fairly complete Ada95 binding (developed and tested for
GNAT of course).

Juergen

Jaume Obrador schrieb in Nachricht <3552F6CD.2FCF@ipc4.uib.es>...
>I'm looking for a Console management package for Linux, wich supports
>colors and cursor positioning (like J. van dyk Console package for
>win95)
>
>Jaume Obrador.






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Console management package for Linux
  1998-05-08  0:00 Console management package for Linux Jaume Obrador
@ 1998-05-08  0:00 ` Jerry van Dijk
  1998-05-14  0:00   ` Anton Planting
  1998-05-08  0:00 ` Juergen Pfeifer
  1 sibling, 1 reply; 4+ messages in thread
From: Jerry van Dijk @ 1998-05-08  0:00 UTC (permalink / raw)



Jaume Obrador (jobrador@ipc4.uib.es) wrote:

: I'm looking for a Console management package for Linux, wich supports
: colors and cursor positioning (like J. van dyk Console package for
: win95)

Well, that depends on what you need.

For basic terminal control you can use the terminfo system (termcap
is now considered obsolete).

For higher-level control you can use the (n)curses library.

There is also the question if X terminals have to be supported.

However, if you are sure your program will only run on a linux
virtual terminal, it supports the ANSI escape sequences. So,
a Quick & Dirty solution is:

-- demo.adb
with Console;     use Console;
with Ada.Text_IO; use Ada.Text_IO;

procedure Demo is
   C : Character;
begin
   Foreground_Color (White);
   Background_Color (Blue);
   Clear_Screen;
   Goto_XY (36, 12);
   Put ("CONSOLE!");
   Goto_XY (0, 0);
   Get_Immediate (C);
   Foreground_Color (White);
   Background_Color (Black);
   Clear_Screen;
end Demo;

-- Console.ads
package Console is

   -----------
   -- Types --
   -----------

   subtype X_Loc is Natural range 0 .. 79;

   subtype Y_Loc is Natural range 0 .. 24;

   type Color_Type is (Black, Red, Green, Yellow, Blue, Magenta, Cyan, White);

   ---------------------
   -- Console control --
   ---------------------

   procedure Clear_Screen;

   procedure Goto_XY (X : in X_Loc; Y : in Y_Loc);

   procedure Foreground_Color (Color : in Color_Type);
   procedure Background_Color (Color : in Color_Type);

end Console;

-- console.adb
with Ada.Text_IO;

package body Console is

   Ansi : String := ASCII.ESC & "[";

   function Num (N : Integer) return String is
      Result : String := Integer'Image (N);
   begin
      return Result (2 .. Result'Last);
   end Num;
   pragma Inline (Num);

   procedure Clear_Screen is
   begin
      Ada.Text_IO.Put (Ansi & "2J");
   end Clear_Screen;

   procedure Goto_XY (X : in X_Loc; Y : in Y_Loc) is
   begin
      Ada.Text_IO.Put (Ansi & Num (Y) & ";" & Num (X) & "H");
   end Goto_XY;

   procedure Foreground_Color (Color : in Color_Type) is
   begin
      Ada.Text_IO.Put (Ansi & Num (Color_Type'Pos (Color) + 30) & "m");
   end Foreground_Color;

   procedure Background_Color (Color : in Color_Type) is
   begin
      Ada.Text_IO.Put (Ansi & Num (Color_Type'Pos (Color) + 40) & "m");
   end Background_Color;

end Console;


-- 
-- Jerry van Dijk  | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Console management package for Linux
  1998-05-08  0:00 ` Jerry van Dijk
@ 1998-05-14  0:00   ` Anton Planting
  0 siblings, 0 replies; 4+ messages in thread
From: Anton Planting @ 1998-05-14  0:00 UTC (permalink / raw)



great




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1998-05-14  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-08  0:00 Console management package for Linux Jaume Obrador
1998-05-08  0:00 ` Jerry van Dijk
1998-05-14  0:00   ` Anton Planting
1998-05-08  0:00 ` Juergen Pfeifer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox