comp.lang.ada
 help / color / mirror / Atom feed
* how to put cursor at X,Y
@ 1996-10-25  0:00 GANAYE Pascal
  1996-10-25  0:00 ` Larry Kilgallen
  1996-10-29  0:00 ` Michael Feldman
  0 siblings, 2 replies; 6+ messages in thread
From: GANAYE Pascal @ 1996-10-25  0:00 UTC (permalink / raw)



I'm a beginner in ADA programming looking for a procedure to put the
cursor at the position X,Y in the screen without clear it.
By the way could you say me where i can find ada samples and
ada-programming related WEB Site




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

* Re: how to put cursor at X,Y
  1996-10-25  0:00 how to put cursor at X,Y GANAYE Pascal
@ 1996-10-25  0:00 ` Larry Kilgallen
  1996-10-29  0:00 ` Michael Feldman
  1 sibling, 0 replies; 6+ messages in thread
From: Larry Kilgallen @ 1996-10-25  0:00 UTC (permalink / raw)



SMTP mail produced this failure, so I post this respons instead
of mailing.

> The message could not be delivered to:
> 
> ganaye@univ-orleans.fr: Remote system's reason for rejecting: <ganaye@univ-orleans.fr>... User unknown

In article <3270BBC4.5480@univ-orleans.fr>, GANAYE Pascal <ganaye@univ-orleans.fr> writes:

>I'm a beginner in ADA programming looking for a procedure to put the
>cursor at the position X,Y in the screen without clear it.

That certainly depends on what software controls your screen:

	VT100 emulator
	X-windows system
	Motif
	Microsoft Windows
	OS/2

You should repost with that information.  Specifying your
compiler, machine, and operating system also would be good.

>By the way could you say me where i can find ada samples and
>ada-programming related WEB Site

www.adahome.com





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

* Re: how to put cursor at X,Y
  1996-10-25  0:00 how to put cursor at X,Y GANAYE Pascal
  1996-10-25  0:00 ` Larry Kilgallen
@ 1996-10-29  0:00 ` Michael Feldman
  1996-10-30  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Feldman @ 1996-10-29  0:00 UTC (permalink / raw)



In article <3270BBC4.5480@univ-orleans.fr>,
GANAYE Pascal  <ganaye@univ-orleans.fr> wrote:
>I'm a beginner in ADA programming looking for a procedure to put the
>cursor at the position X,Y in the screen without clear it.
>By the way could you say me where i can find ada samples and
>ada-programming related WEB Site

Here are the spec and body for a simple package to do what you need.
This works correctly for vt100/ANSI-compatible terminals, including
DOS machines with the ANSI.SYS driver installed in CONFIG.SYS.

You can use these, but please leave the block comment at the beginning
untouched.

Mike Feldman
-----
PACKAGE Screen IS
------------------------------------------------------------------
--| Procedures for drawing pictures on ANSI Terminal Screen
--| Author: Michael B. Feldman, The George Washington University 
--| Last Modified: October 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;   



WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
PACKAGE BODY Screen IS
------------------------------------------------------------------
--| Procedures for drawing pictures on ANSI Terminal Screen
--| These procedures will work correctly only if the actual
--| terminal is ANSI compatible. ANSI.SYS on a DOS machine
--| will suffice.
--| Author: Michael B. Feldman, The George Washington University 
--| Last Modified: September 1995                                     
------------------------------------------------------------------

  PROCEDURE Beep IS
  BEGIN
    Ada.Text_IO.Flush;
    Ada.Text_IO.Put (Item => ASCII.BEL);
  END Beep;

  PROCEDURE ClearScreen IS
  BEGIN
    Ada.Text_IO.Put (Item => ASCII.ESC);
    Ada.Text_IO.Put (Item => "[2J");
    Ada.Text_IO.Flush;
  END ClearScreen;

  PROCEDURE MoveCursor (To: IN Position) IS
  BEGIN                                                
    Ada.Text_IO.Flush;
    Ada.Text_IO.Put (Item => ASCII.ESC);
    Ada.Text_IO.Put ("[");
    Ada.Integer_Text_IO.Put (Item => To.Row, Width => 1);
    Ada.Text_IO.Put (Item => ';');
    Ada.Integer_Text_IO.Put (Item => To.Column, Width => 1);
    Ada.Text_IO.Put (Item => 'f');
  END MoveCursor;  

END Screen;




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

* Re: how to put cursor at X,Y
  1996-10-29  0:00 ` Michael Feldman
@ 1996-10-30  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1996-10-31  0:00     ` Ron Thompson
  1996-11-01  0:00     ` Michael Feldman
  0 siblings, 2 replies; 6+ messages in thread
From: whiting_ms@corning.com (Matt Whiting) @ 1996-10-30  0:00 UTC (permalink / raw)



In article <556euh$opl@felix.seas.gwu.edu>, mfeldman@seas.gwu.edu (Michael Feldman) writes:
>
>	. 
>	. 
>	. 
>
>   PROCEDURE MoveCursor (To: IN Position) IS
>   BEGIN                                                
>     Ada.Text_IO.Flush;
>     Ada.Text_IO.Put (Item => ASCII.ESC);
>     Ada.Text_IO.Put ("[");
>     Ada.Integer_Text_IO.Put (Item => To.Row, Width => 1);
>     Ada.Text_IO.Put (Item => ';');
>     Ada.Integer_Text_IO.Put (Item => To.Column, Width => 1);
>     Ada.Text_IO.Put (Item => 'f');
>   END MoveCursor;  
> 
> END Screen;
-- 

This is off the subject, but how do typical Ada compilers (or GNAT if
specificity is required) handle the above list of I/O statements?  I'm
thinking back to my FORTRAN days when I would typically use a single FORTRAN
WRITE/FORMAT statement combination to print out entire escape sequences with
"one" command.  Does the Ada compiler aggregate the above statements into one
buffer for issuance to the serial port or the ANSI driver?  Or does it
literally send seven separate I/O commands?  And what, if any, execution
efficiency is lost if the latter is true?

Matt




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

* Re: how to put cursor at X,Y
  1996-10-30  0:00   ` whiting_ms@corning.com (Matt Whiting)
@ 1996-10-31  0:00     ` Ron Thompson
  1996-11-01  0:00     ` Michael Feldman
  1 sibling, 0 replies; 6+ messages in thread
From: Ron Thompson @ 1996-10-31  0:00 UTC (permalink / raw)




The brave Ada programmer is always hammered about the
apparent lack of screen handling capabilities in the
typical Ada environment.  A lot of money and you can't even
do this... etc.  You know what I mean.
I used to do the ansi.sys way.  It was excellent exercise
for the programmer to understand what exactly it takes to
control the NON graphics mode of the typical Intel pc screen.
Later, I started using the mapped array, with the first 
address being the starting address of the bios screen.
A word per address, with the bits defined as the standard
bios interface, whammmo, refresh rate screen handling that
is unsurpassed in the dos world.  Can't do it in winders,
winders MUST do all of that stuff for you I suppose.
But for the brave dos programmers, let me know and I will
help you build a sporty screen interface that is as fast as
the machine allows.

rct

The opinions above are mine and mine alone.





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

* Re: how to put cursor at X,Y
  1996-10-30  0:00   ` whiting_ms@corning.com (Matt Whiting)
  1996-10-31  0:00     ` Ron Thompson
@ 1996-11-01  0:00     ` Michael Feldman
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Feldman @ 1996-11-01  0:00 UTC (permalink / raw)



In article <1996Oct30.074712.1@corning.com>,
whiting_ms@corning.com (Matt Whiting) <whiting_ms@corning.com> wrote:
>In article <556euh$opl@felix.seas.gwu.edu>, mfeldman@seas.gwu.edu (Michael Feldman) writes:

>>     Ada.Text_IO.Put (Item => ASCII.ESC);
>>     Ada.Text_IO.Put ("[");
>>     Ada.Integer_Text_IO.Put (Item => To.Row, Width => 1);
>>     Ada.Text_IO.Put (Item => ';');
>>     Ada.Integer_Text_IO.Put (Item => To.Column, Width => 1);
>>     Ada.Text_IO.Put (Item => 'f');

>This is off the subject, but how do typical Ada compilers (or GNAT if
>specificity is required) handle the above list of I/O statements?  I'm
>thinking back to my FORTRAN days when I would typically use a single FORTRAN
>WRITE/FORMAT statement combination to print out entire escape sequences with
>"one" command.  Does the Ada compiler aggregate the above statements into one
>buffer for issuance to the serial port or the ANSI driver?  Or does it
>literally send seven separate I/O commands?  And what, if any, execution
>efficiency is lost if the latter is true?

Good questions. I'll let the implementers answer specifically, but
propose another solution.

One could contemplate bundling it all up in one output statement by 
concatenating the strings together with the string images, as follows:

Ada.Text_IO.Put(Item =>
  ASCII.ESC & [ &
  Integer'Image(To.Row) & ';'
  Integer'Image(To.Column) & 'f');

This would be splendid except for one little problem. Unfortunately, 
Integer'Image returns the string with a leading blank (or a minus if 
the integer is negative), and the escape sequence can't have embedded 
blanks. So one would have to find another way of computing the string 
image of row and column without getting the leading blank. I'll leave 
that as an exercise.:-)

Yet another (maybe more interesting) possibility is to use the
Put-into-string form of all the Put statements. This is what
Fortran calls (or called) an "internal file". The string could then
be sent to the terminal with one final Put. 'Course then one would have
to know just how long the actual string was; the string length could
vary from 6 to 8 characters (why?).

Implementers: what are the performance tradeoffs here?
>
>Matt

Mike Feldman




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

end of thread, other threads:[~1996-11-01  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-25  0:00 how to put cursor at X,Y GANAYE Pascal
1996-10-25  0:00 ` Larry Kilgallen
1996-10-29  0:00 ` Michael Feldman
1996-10-30  0:00   ` whiting_ms@corning.com (Matt Whiting)
1996-10-31  0:00     ` Ron Thompson
1996-11-01  0:00     ` Michael Feldman

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