/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
/*                                                                     */
/*        P�l Hedne 1990                                               */
/*                                                                     */
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;*/
#include "dialog.h"
extern MathModus;

/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          */
/*                                                                                                                                                                               ;       */
/*                                                                                                                                                                               ;       */
/*                                                                                                                                                                               ;       */
/*                                                                                                                                                                               ;       */
/*                                                                                                                                                                               ;       */
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          */
/* (macro _init                                                                                                                                                          */
/*      ((int help_id)                                                                                                                                           */
/*       (string text)                                                                                                                                           */
/*       (global help_id)                                                                                                                                        */
/*       (= help_id (create_buffer "Help menu" "latex.mnu" 1))                                   */
/*       (sprintf text "Help ID = %d" help_id)                                                                           */
/*       (message text)                                                                                                                                          */
/*      )                                                                                                                                                                                        */
/* )                                                                                                                                                                                             */
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */
/*                                                                                                                                                                                                      ; */
/*   -1 DIALOG_INIT       The dialog manager has just been invoked                              ; */
/*   -2 DIALOG_ENTER_FIELD  The cursor has just entered a non-list field                ; */
/*   -3 DIALOG_ENTER_LIST   The cursor has just entered a l                                             ; */
/*   -4 DIALOG_ALTER_LIST   The current item in a list has just been changed ; */
/*   -5 DIALOG_ALTER_MENU   The current item in a menu has just been changed ; */
/*   -5 DIALOG_MOVE_MENU (Same as DIALOG_ALTER_ME                                                                       ; */
/*   -6 DIALOG_PICK_MENU The user has just selected a menu button with Enter ; */
/*   -7 DIALOG_EXIT_FIELD   The cursor has just left a non-list field                   ; */
/*   -8 DIALOG_EXIT_LIST The cursor has just left a l                                                           ;       */
/*   -9 DIALOG_TERM       The dialog manager is exit                                                                    ;       */
/*   -10 DIALOG_ESCAPE    The user has just pressed Esc to exit all levels      ; */
/*   -11 DIALOG_F10       The user has just pressed F10 to save a dialog box            ; */
/*   -12 DIALOG_GREY_MINUS   The user has just pressed the keypad minus key     ; */
/*   -13 DIALOG_CREATE_MENU  A menu buffer has just been made current                   ; */
/*   -14 DIALOG_CREATE_DBOX  A dialog box data buffe                                                                    ; */
/*                                                                                                                                                                                                      ; */
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; */

pro_help (...)
{
       int event, line, retval, exe_sw;

       string text, macro_name;

       global macro_name, exe_sw;

       get_parm (0, event);
       get_parm (1, line);
       get_parm (2, text);

       switch (event)
               {
               case DIALOG_INIT:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG INIT")                                                                        */
                       }
               case DIALOG_ENTER_FIELD:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_ENTER_FIELD")                                                 */
                       }
               case DIALOG_ENTER_LIST:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_ENTER_LIST")                                                  */
                       }
               case DIALOG_ALTER_LIST:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_ALTER_LIST")                                                  */
                       }
               case DIALOG_ALTER_MENU:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_ALTER_MENU")                                                  */
                       }
               case DIALOG_MOVE_MENU:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_MOVE_MENU")                                                   */
                       }
               case DIALOG_PICK_MENU:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_PICK_MENU")                                                   */
                       macro_name = substr (text, index (text, ";") + 1);
                       _dialog_esc ();
                       exe_sw = 1;
                       }
               case DIALOG_EXIT_FIELD:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_EXIT_FIELD")                                                  */
                       }
               case DIALOG_EXIT_LIST:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_EXIT_LIST")                                                   */
                       }
               case DIALOG_TERM:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_TERM")                                                                        */
                       }
               case DIALOG_ESCAPE:
                       {
                       exe_sw = 0;
                       retval = TRUE;
                       /*                                (message "DIALOG_ESCAPE")                                                              */
                       }
               case DIALOG_F10:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_F10")                                                                         */
                       }
               case DIALOG_GREY_MINUS:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_GREY_MINUS")                                                  */
                       }
               case DIALOG_CREATE_MENU:
                       {
                       retval = TRUE;
                       /*                                (message "DIALOG_CREATE_MENU")                                                 */
                       }
                       /* default                                                                                                                                                       */
               default:
                       {
                       beep ();
                       /*                                      (message "Illegal key")                                                                  */
                       }
               }
       returns retval;
}

/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          */
latex_help (...)
{
       string file, title, msg, action;

       title = "LaTex help";
       msg = "Press ESC to continue, ENTER to pick";
       file = "latex.mnu";
       if (MathModus == 1)
               file = "latexmat.mnu";
       action = "pro_help";
       /*        (_process_menu lx by rx ty title msg filename buf_id action fast) */
       _process_menu (10, 5, 10, 5, title, msg, file, NULL, action, 1);
       /*              (_process_menu 10 15 70 5 title msg NULL help_id action 1)               */
       if (exe_sw == 1)
               execute_macro (macro_name);
}
/* ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;          */
string gen_help (...)
{
  string parameter,file, title, msg, action;
  int buf_key,line;

       title = "";
       msg = "Press ESC to continue, ENTER to pick";
       file = "";
       action = "pro_help";
  get_parm (0, file);
  title=file;
       exe_sw=0;
  if (get_parm (1, buf_key))
       _process_menu(10,5,10,5,title,msg,NULL,buf_key,action,1,line,parameter);
  else
       _process_menu (10,5,10,5,title,msg,file,NULL,action,1,line,parameter);
  if (exe_sw == 1)
               execute_macro (macro_name);
  return(parameter);
}