(****************************************************************************)
(*                                                                          *)
(*                           GSX Char Module                                *)
(*                           ===============                                *)
(* This Module contains all text-related GSX functions, which provice a     *)
(* device-independent access to normal text screens. In future, this module *)
(* will be enhanced by a text window manager.                               *)
(*                                                                          *)
(* 16.5.1988          Wolfgang Muees, Hagenring 22, 3300 Braunschweig       *)
(*                                                                          *)
(****************************************************************************)


VAR
  Rows, Columns : INTEGER;                (* screen dimensions X,Y *)

PROCEDURE GetDimensions;                  (* A call to GetDimensions returns the number of
                                             addressable rows & columns on the screen. If
                                             access to specific rows/columns is not possible,
                                             this values are set to -1 *)
BEGIN
  simplESC ( 1 );
  Rows    := INTOUT[1];
  Columns := INTOUT[2];
END;


PROCEDURE CursorUp;                       (* Advances text cursor 1 row up. If the cursor was
                                             already on top of screen, nothing happens. *)
BEGIN
  simplESC ( 4 );
END;


PROCEDURE CursorDown;                     (* Advances text cursor 1 row down. If the cursor was
                                             already on bottom of screens, nothing happens. *)
BEGIN
  simplESC ( 5 );
END;


PROCEDURE CursorRight;                    (* Advances text cursor 1 column right. If the cursor
                                             was already on rightmost column of screen,
                                             nothing happens. *)
BEGIN
  simplESC ( 6 );
END;


PROCEDURE CursorLeft;                     (* Advances text cursor 1 column left. If the cursor
                                             was already on leftmost column of screen,
                                             nothing happens. *)
BEGIN
  simplESC ( 7 );
END;


PROCEDURE CursorHome;                     (* Force text cursor to home position : top left of
                                             screen. *)
BEGIN
  simplESC ( 8 );
END;


PROCEDURE EraseLineEnd;                   (* Erase current line from text cursor position
                                             to end of line. The new cursor position is
                                             undetermined and must be set by CursorAt. *)
BEGIN
  simplESC ( 10 );
END;


PROCEDURE EraseScreenEnd;                 (* Erase screen from text cursor position to end
                                             of screen. The new cursor position is undetermined
                                             and must be set by CursorAt. *)
BEGIN
  simplESC ( 9 );
END;


PROCEDURE CursorAt ( Row, Column : INTEGER ); (* Sets text cursor to specified position.
                                              Valid range for Row/Column is [1..Rows/Columns].
                                              If Row/Column are out of range, cursor positon
                                              is trunced to allowed range. *)
BEGIN
  INTIN[1]  := Row;
  INTIN[2]  := Column;
  CB.IINLEN := 2;
  simplESC ( 11 );
END;


PROCEDURE WriteText ( Text : Lstring );   (* Writes a text string at cursor position.
                                             The cursor position advances with each displayed
                                             character until rightmost column is reached.
                                             If there are more characters in Text, they are
                                             ignored. Note that the length of Text is trunced
                                             to I_inLen ( see GSXMAIN ), if nessessary. *)
BEGIN
  SetText ( Text );
  simplESC ( 12 );
END;


PROCEDURE Reverse;                        (* Switch to inverse text. *)
BEGIN
  simplESC ( 13 );
END;


PROCEDURE Normal;                         (* Switch back to normal text ( default ) *)
BEGIN
  simplESC ( 14 );
END;


PROCEDURE GetPosition ( VAR Row, Column : INTEGER ); (* Returns current cursor position. *)
BEGIN
  simplESC ( 15 );
  Row    := INTOUT[1];
  Column := INTOUT[2];
END;

