DEFINITION MODULE StatusLn;
FROM Terminal IMPORT WriteString, GotoXY, ReadChar, WriteChar;
FROM Strings IMPORT Append, Length, Copy, Insert, Delete;


PROCEDURE CursorRecall(Mem: BOOLEAN);
    (* If Mem is TRUE current cursor position is remembered
    If Mem is FALSE  the cursor is returned to previously membered position!*)

PROCEDURE PreserveStatusLine(Mem: BOOLEAN);
    (* I've got no idea what this function does. It's just mentioned
    briefly in the Kaypro manual. In case I ever want to use it...
    TRUE turns preservation on, FALSE turns it off. WOW! *)

PROCEDURE GotoStatusX(x: CARDINAL);
    (* Gets around m2's inability [ie BUG] to write to the status line
    and have the editor behave as well by writing a Kaypro excape sequence
    Notice that the statusline scrolls after every LF, so a WriteLn following
    this routine will note give lasting results. Also, the cursor MUST be
    dragged out of the statusline back to its proper position in the text
    before continuing normal text output *)

PROCEDURE Blank(x: CARDINAL);
    (* Blanks the screen and homes cursor if x=0
    If x>99 prints x DIV 100 LINEFEEDS
    then prints 1-99 [x MOD 100] blanks at current position
    *)

PROCEDURE ErrorMessage(s: ARRAY OF CHAR);
    (* Writes an errormessage to the programmer.
    Program Execution can be halted at this point by pressing ^C
    *)

PROCEDURE InputED(VAR StringToEdit: ARRAY OF CHAR; Prompt: ARRAY OF CHAR;
                  MaxLength   : CARDINAL) ;
    (* This little gem enables you to input with editing, starting from
    scratch [''] or from an assigned default StringToEdit.
    Prompt is usually = '>' or '?'.

        <CR> with the cursor in col zero returns the original StringToEdit,
        ignoring any changes that have been made during the procedure.

        <CR> anywhere else truncates the string at the character before the
        cursor and returns that value.

        <ESC> returns the entire string as displayed, regardless of cursor
        position.

        <DEL> Deletes the Char to the left of the cursor and closes the gap

        <TAB> (^I) Inserts a space at the current cursor position.

        <LEFTARROW> (^H or ^S) performs nondestructive backspace.

        <RIGHTARROW> (^L or ^D) performs nondestructive aheadspace upto
        MaxLength.

        ^C halts the program.

        All printable characters are accepted into the displayed string,
        overwriting the character under the cursor and advancing one position.

    If the Default StringToEdit is longer than MaxLength, it is truncated.
    MaxLength MUST be <80.
    Trailing blanks are stripped from result.

    *)

PROCEDURE HitAny;
    (*
    Calls a temporary halt in execution with the prompt
    "Press ANY key to continue" on the statusline.
    ^C will abort the program.
    Cursor is returned to screenposition it occupied prior to HitAny
    *)

PROCEDURE UserWantsTo(Question: ARRAY OF CHAR): BOOLEAN;
    (*
    Cleverly worded PROCEDURE name forms an English phrase with clear meaning
    if Question is worded to complete the option being queried:
    e.g.
        IF UserWantsTo('Continue') THEN . . . ELSE HALT;
    displays
        Continue? (Y/n)
    on the statusline. N,n,<ESC>= FALSE. ^C aborts. Y,y,<SP>,<CR> = TRUE.
    Nothing else is accepted.
    Cursor is remembered and replaced.
    NB: This function supplies its own questionmark!!
    *)

PROCEDURE Copyright
    (ProgramName,Version,Date: ARRAY OF CHAR; PrivateDomain: BOOLEAN);
    (*
    Generates an opening screen with a boxed copyright notice, address,
    and version number. If PrivateDomain is FALSE, program is ceded to
    the Public Domain.
    ProgramName may be upto 80CHARs long and is displayed centered in a
    prominant position. To ensure fit, Date should be 4-10 chars eg '1987'
    *)

PROCEDURE Notice(s: ARRAY OF CHAR);
    (*Blanks the Statusline then writes the message s to the statusline.
    Returns Cursor to precall position on exit.
    *)


END StatusLn.
