From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a83ac04244a76ea9 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Terminal IO, and menus Date: 1999/03/31 Message-ID: #1/1 X-Deja-AN: 461067413 References: <7drb1p$48k$1@nw001t.infi.net> NNTP-Posting-Date: Tue, 30 Mar 1999 22:55:32 PDT Newsgroups: comp.lang.ada Date: 1999-03-31T00:00:00+00:00 List-Id: "Heath Isler" writes: > My question is is there a way in the stadard packages to Clear the Screen > and postition the cursor in a specific location, i.e. Locate_Cursor (x => > 10, y =>15); ? I am plan on using this for menus and data input. No, there's nothing in the Ada predefined packages to do that. > I have also looked through a lot of packages on the net, and some of > them seem to fit my need. I not sure if I should use one of the > Terminal IO or menu packages. Can anyone recommend a package to use? In the GNAT source distribution, the dining philosophers example does terminal I/O using escape sequences. --:::::::::: --screen.ads --:::::::::: package Screen is -- simple ANSI terminal emulator -- Michael Feldman, The George Washington University -- July, 1995 ScreenHeight : constant Integer := 24; ScreenWidth : constant Integer := 80; subtype Height is Integer range 1..ScreenHeight; subtype Width is Integer range 1..ScreenWidth; type Position is record Row : Height := 1; Column: Width := 1; end record; procedure Beep; -- Pre: none -- Post: the terminal beeps once procedure ClearScreen; -- Pre: none -- Post: the terminal screen is cleared procedure MoveCursor (To: in Position); -- Pre: To is defined -- Post: the terminal cursor is moved to the given position end Screen; --:::::::::: --screen.adb --:::::::::: with Text_IO; package body Screen is -- simple ANSI terminal emulator -- Michael Feldman, The George Washington University -- July, 1995 -- These procedures will work correctly only if the actual -- terminal is ANSI compatible. ANSI.SYS on a DOS machine -- will suffice. package Int_IO is new Text_IO.Integer_IO (Num => Integer); procedure Beep is begin Text_IO.Put (Item => ASCII.BEL); end Beep; procedure ClearScreen is begin Text_IO.Put (Item => ASCII.ESC); Text_IO.Put (Item => "[2J"); end ClearScreen; procedure MoveCursor (To: in Position) is begin Text_IO.New_Line; Text_IO.Put (Item => ASCII.ESC); Text_IO.Put ("["); Int_IO.Put (Item => To.Row, Width => 1); Text_IO.Put (Item => ';'); Int_IO.Put (Item => To.Column, Width => 1); Text_IO.Put (Item => 'f'); end MoveCursor; end Screen;