DEFINITION MODULE m2ud;
(*$ NameChk:=FALSE LargeVars:=FALSE *)

(*---------------------------------------------------------------------------*)
(* User dependent part of debugger                                           *)
(*---------------------------------------------------------------------------*)

FROM SYSTEM IMPORT BYTE,FFP,LONGSET;

TYPE
  Window=(dt1Wdw,dt2Wdw,srcWdw,modWdw,prdWdw);
  CommandType=(scroll,select,menu);
  SelectionKind=(data,source);
  SelectionSet=SET OF SelectionKind;
  DisplayProc=PROCEDURE(CARDINAL,CARDINAL);(* top,display *)
  SelectProc=PROCEDURE(SelectionSet,CARDINAL,CARDINAL); (* line,column *)
    (*
     * Command returns the event generated by the user in a format appropriate
     * for the Client of this module. Three different Commands are possible:
     *
     * scroll: This indicates that the content of the window has to be
     *         redisplayed to reflect the new condition, which may be
     *         a resized window, or a scroll of the contents of the window.
     *         Display contains the display procedure corresponding to the
     *         window in which the change occurred. newTopLine contains
     *         the number of the new first line of the window and displayLines
     *         the number of lines to be displayed.
     * select: This indicates that the user selected something in either
     *         a source or data window.  sel defines if it is the source or
     *         the data which is affected and line,column contain the position
     *         where the selection occured.
     * menu: This indicates that the user choosed an item from the menu.
     *       menu contains the procedure which handles the menus and itemNr
     *       the number of the selected menuItem.
     *)
  Command=RECORD
   CASE type:CommandType OF
   | scroll: (* redisplay window with newTopLine as number of the first line
                in the window and displayLines as number of lines in window.
              *)
    Display:DisplayProc;
    newTopLine,displayLines:CARDINAL
   | select:
    Select:SelectProc;
    sel:SelectionSet;
    line,column:CARDINAL (* absolute form *)
   | menu:
    itemNr:INTEGER
   END
  END;

VAR
  (*
   * Vom Menü änderbar:
   * Src sofort anzeigen oder erst auf rechte Maustaste
   *)
  (*$ LongAlign:=FALSE *)
  srcImm:BOOLEAN;

PROCEDURE InitM2UD; (* nur von m2d aufrufen! *)
PROCEDURE ExitM2UD; (* nur von m2d aufrufen! *)

PROCEDURE GetCommand(VAR command:Command);

PROCEDURE DispLn    (u:Window);
  (*
   * Go on a new line in the specified window.
   *)
PROCEDURE DispString(u:Window; s:ARRAY OF CHAR; n:INTEGER);
  (*
   * Write the string into the specified window. The string
   * is written right-adjusted in a field of size n if it is
   * shorter than n, otherwise it is simply written as is.
   *)
PROCEDURE DispCard  (u:Window; x:LONGCARD; n:INTEGER);
   (*
    * Displays a unsigned number in the specified window.
    * The number is written right-adjusted in a field of
    * size n in decimal representation.
    *)
PROCEDURE DispInt   (u:Window; x:LONGINT; n:INTEGER);
   (*
    * Displays a signed number in the specified window.
    * The number is written right-adjusted in a field of
    * size n in decimal representation.
    *)
PROCEDURE DispHex   (u:Window; x:ARRAY OF BYTE; n:INTEGER);
   (*
    * Displays a unsigned number in the specified window.
    * The number is written right-adjusted in a field of
    * size n in hexadecimal representation. The size of the
    * passed variable determines how much digits are used
    * for the number. E.g. let the value of the number be
    * 1EH and the fieldlength n be 10. Here is how it
    * will be represented, depending on whether it is passed
    * in a variable of type CHAR, INTEGER or LONGINT:
    *
    *     CHAR:    '        1E'
    *     INTEGER: '      001E'
    *     LONGINT: '  0000001E'
    *
    * Of course the quotes are not printed. They are shown to
    * clearly mark the extent of the string.
    *)
PROCEDURE DispChar  (u:Window; ch:CHAR; n:INTEGER);
   (*
    * n=0: Write characters with quotes.
    * n=1: Use exactly one place (=> CTRL-Chars ='.'
           and normal chars without quotes.
    * n>=2: Use quotes and display ctrl-chars as oooC.
    *)
PROCEDURE DispFFP  (u:Window; x:FFP; n:INTEGER);
    (*
     * Realnumbers are displayed as hex numbers. This should change.
     *)
PROCEDURE DispReal  (u:Window; x:REAL; n:INTEGER);
    (*
     * Realnumbers are displayed as hex numbers. This should change.
     *)
PROCEDURE DispLReal  (u:Window; x:LONGREAL; n:INTEGER);
    (*
     * Longrealnumbers are displayed as hex numbers. This should change.
     *)

PROCEDURE RestoreLayout;
   (*
    * Moves all windows to their initial position.
    *)
PROCEDURE RestoreWindow(u:Window);
  (*
   * Gets the height of the window and calls the displayProc with
   * the current topLine and the new height.
   *)
PROCEDURE WindowHeight(u:Window):CARDINAL;
  (*
   * Return the number of lines that can be displayed in this window.
   *)
PROCEDURE WindowWidth(u:Window):CARDINAL;
  (*
   * Return the number of characters per line that can be displayed
   * in this window.
   *)
PROCEDURE WindowTopLine(u:Window):CARDINAL;
  (*
   * Return the number of the line which is displayed on the first
   * line of the window.
   *)
PROCEDURE Tab(u:Window; position:INTEGER);
  (*
   * This procedure should better be called SetHorizontalPos. It
   * reposition the cursor on the same line at thecharacter position
   * given in `position`.
   *)
PROCEDURE Mark(u:Window; inverse:BOOLEAN);
  (*
   * This procedure sets the character rendering. if inverse is TRUE,
   * following characters are displayed in inverse mode.
   *)
PROCEDURE InitWindowStatus(u:Window; topLine,dataHeight:CARDINAL);
   (*
    * This procedure sets the number of the first line to be displayed
    * in the window and the number of total lines of the date belonging
    * to this window (e.g. the number of lines of the source, the number
    * of variables etc.). This procedure will also recalculate the
    * size and position of the autoKnob (given in fractions of maxBody).
    * The window is also cleared and the cursor is set to the position
    * 0,0.
    *)
PROCEDURE InitActions(u:Window; d:DisplayProc; s:SelectProc);
    (*
     * First assigns the displayProc and selectProc to this window and
     * calls InitWindowStatus. If a non-empty menu string was passed
     * to this procedure then it is added to the menu and for every
     * window the menu is reset and newly set to the modified menu.
     *)
PROCEDURE InputString(VAR prompt, s: ARRAY OF CHAR);

PROCEDURE ReadLayout;
PROCEDURE SaveLayout;
PROCEDURE Beep;

END m2ud.def
