home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / HELP.C < prev    next >
Text File  |  1995-12-13  |  40KB  |  909 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   help.c                                                                  */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   various routines for displaying help and messages.                      */
  8. /*                                                                           */
  9. /*                                                                           */
  10. /* History:                                                                  */
  11. /*                                                                           */
  12. /*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  */
  13. /*                                                                           */
  14. /*...16->32 port.                                                            */
  15. /*...                                                                        */
  16. /*... 02/08/91  100   Philip    port to 32 bit.                              */
  17. /*... 02/08/91  112   Joe       port to 32 bit.                              */
  18. /*...                                                                        */
  19. /*...Release 1.00 (Pre-release 105 10/10/91)                                 */
  20. /*...                                                                        */
  21. /*... 10/31/91  308   Srinivas  Menu for exceptions.                         */
  22. /*...                                                                        */
  23. /*...Release 1.00 (Pre-release 107 11/13/91)                                 */
  24. /*...                                                                        */
  25. /*... 11/13/91  400   Srinivas  Vertical Register Display.                   */
  26. /*... 11/18/91  401   Srinivas  Co processor Register Display.               */
  27. /*...                                                                        */
  28. /*...Release 1.00 (After pre-release 1.08)                                   */
  29. /*...                                                                        */
  30. /*... 02/12/92  521   Joe       Port to C-Set/2.                             */
  31. /*...                                                                        */
  32. /*...Release 1.00 (03/03/92)                                                 */
  33. /*...                                                                        */
  34. /*... 03/10/92  602   Srinivas  Hooking up watch points.                     */
  35. /*...                                                                        */
  36. /*...Release 1.01 (04/03/92)                                                 */
  37. /*...                                                                        */
  38. /*... 05/08/92  701   Srinivas  Cua Interface.                               */
  39. /**Includes*******************************************************************/
  40.  
  41. #include "all.h"                        /* SD86 include files                */
  42. #include "diahlpbx.h"
  43.  
  44. /**External declararions******************************************************/
  45.  
  46. extern uint     VideoRows;
  47. extern uint     VideoCols;
  48. extern uchar    VideoAtr;
  49. extern uchar    hilite[];               /* high light field attributes    701*/
  50. extern uchar    normal[];               /* normal field attributes        701*/
  51. extern uchar    ClearField[];           /* attrib str for clearing fields.   */
  52. extern CmdParms cmd;
  53. extern UINT     HelpRow;                /* screen row for menu help (0..N)   */
  54. extern UINT     ProRow;                 /* screen row for prompt (0..N)      */
  55. extern UINT     MsgRow;                 /* screen row for messages (0..N)    */
  56.  
  57. /**Static definitions ********************************************************/
  58.  
  59. static  uchar *HelpMessage;
  60.  
  61. /*****************************************************************************/
  62. /* Help()                                                                    */
  63. /*                                                                           */
  64. /* Description:                                                              */
  65. /*                                                                           */
  66. /*   Display help window, wait for key press, restore window.                */
  67. /*                                                                           */
  68. /* Parameters:                                                               */
  69. /*                                                                           */
  70. /*   id            input - help file message id.                             */
  71. /*   fillchars     input - optional fill in the blank chars.                 */
  72. /*                                                                           */
  73. /* Return:                                                                   */
  74. /*                                                                           */
  75. /*   key           user reponse from the help box.                           */
  76. /*                                                                           */
  77. /* Assumptions:                                                              */
  78. /*                                                                           */
  79. /*   none.                                                                   */
  80. /*                                                                           */
  81. /*****************************************************************************/
  82.  
  83.  void
  84. Help(ULONG id)
  85. {
  86.     uchar *mbuf;
  87.  
  88.     mbuf = GetHelpMsg(id, NULL,0);
  89.     VideoAtr = vaMenuBar;
  90.     CuaShowHelpBox( mbuf );
  91.     Tfree( mbuf);                                                        /*521*/
  92. }
  93.  
  94.     uint
  95. ShowHelpBox(uchar *helptext, UINTFUNC helpfunc,uint HeaderRows,void *args)
  96. {
  97.     uint  row, rows, cols;
  98.     uchar *cp, *msg;
  99.     uint  n, msglen, ans;
  100.     uchar *vbuf;
  101.     int   StartRow;
  102.     uint  TotalRows, TotalCols;
  103.     uint  ScreenRows;
  104.     uchar *SavePtr;
  105.     uint   col = 0;                     /* was not initialized.           512*/
  106.  
  107.     n = strlen(cp = helptext);
  108. /*****************************************************************************/
  109. /*  Calculate the number of rows and colums required to display the window308*/
  110. /*  by scanning the text buffer for control characters.                   308*/
  111. /*****************************************************************************/
  112.     for( rows = cols = 0 ; n ; ++rows, n -= col, cp += col )
  113.     {
  114.         if( rows == 0 )
  115.             msg = cp;
  116.         if( (col = strcspn(cp, "\r")) > cols )
  117.             cols = col;
  118.         if( (col == 0) && (rows == 0) )
  119.             rows -= 1;
  120.         if( col < n )
  121.             cp[col++] = 0;
  122.         if( (col < n) && (cp[col] == '\n') )
  123.             col += 1;
  124.     }
  125.  
  126. /*****************************************************************************/
  127. /* Calculate the following values:                                        308*/
  128. /*                                                                           */
  129. /*   StartRow   : Index into the text buffer from where to display the stuff.*/
  130. /*   TotalRows  : Total rows required including the border rows.             */
  131. /*   TotalCols  : Total cols required including the border Cols.             */
  132. /*   ScreenRows : Total number of rows available for display the entries     */
  133. /*                excluding the header lines and border lines.               */
  134. /*****************************************************************************/
  135.     StartRow   = 1;
  136.     TotalRows  = rows + 2;
  137.     TotalCols  = cols + 4;
  138.     ScreenRows = VideoRows - 2 - HeaderRows;
  139.  
  140. /*****************************************************************************/
  141. /*   If the total rows cannot fit on the screen then put the max possible.308*/
  142. /*****************************************************************************/
  143.     if ( (TotalRows ) > VideoRows )
  144.        TotalRows = VideoRows;
  145.  
  146. /*****************************************************************************/
  147. /*  Calculate the screen co-ordinates where to start the window.          308*/
  148. /*****************************************************************************/
  149.     row = (VideoRows - TotalRows) >> 1;
  150.     col = (VideoCols - TotalCols) >> 1;
  151.  
  152.     vbuf = Talloc(2*TotalRows*TotalCols);                               /*521*/
  153.     Vgetbox( vbuf, row, col,TotalRows, TotalCols );
  154.  
  155.     SavePtr = msg;
  156.  
  157.     Vfmtbox( "", row, col, TotalRows, TotalCols );
  158.  
  159. Reformat:
  160.  
  161.     msg = SavePtr;
  162.  
  163.  
  164. /*****************************************************************************/
  165. /* Display the header rows of the window.                                 308*/
  166. /*****************************************************************************/
  167.     for( n = 0 ; ++n <= HeaderRows ; )
  168.     {
  169.         msglen = strlen(msg);
  170.         if( *msg == '\t' )
  171.             putrc( row + n, col+2 + ((TotalCols-3 - msglen) >> 1), msg + 1 );
  172.         else
  173.             putrc( row + n, col+2, msg );
  174.         if( *(msg += msglen + 1) == '\n' )
  175.             msg += 1;
  176.     }
  177.  
  178.  
  179. /*****************************************************************************/
  180. /* Skip the rows in the text buffer which are not to be displayed.        308*/
  181. /*****************************************************************************/
  182.     for( n = 1 ; n < StartRow ; n++)
  183.     {
  184.         msglen = strlen(msg);
  185.         if( *(msg += msglen + 1) == '\n' )
  186.             msg += 1;
  187.     }
  188.  
  189.  
  190. /*****************************************************************************/
  191. /* Display the rows in the window from the desired postion in the text buff. */
  192. /*****************************************************************************/
  193.     for( n=HeaderRows ; ++n < TotalRows - 1 ; )
  194.     {
  195.         msglen = strlen(msg);
  196.         if( *msg == '\t' )
  197.             putrc( row + n, col+2 + ((TotalCols-3 - msglen) >> 1), msg + 1 );
  198.         else
  199.             putrc( row + n, col+2, msg );
  200.         if( *(msg += msglen + 1) == '\n' )
  201.             msg += 1;
  202.     }
  203.  
  204.     HideCursor();
  205.  
  206.  
  207. /*****************************************************************************/
  208. /* Call the menu box function.                                            308*/
  209. /*****************************************************************************/
  210.     ans =  ( * helpfunc ) (row+1, col+1, TotalRows-2, TotalCols-2, args);
  211.  
  212.  
  213. /*****************************************************************************/
  214. /* If HeaderRows is zero it indicates a help message so donot do any process */
  215. /* on the feed back keys.                                                 308*/
  216. /*****************************************************************************/
  217.     if (HeaderRows)
  218.     {
  219.          switch(ans)
  220.          {
  221.          /********************************************************************/
  222.          /* Depending on the keys set the startrow value. Ensure that the 308*/
  223.          /* screen is displayed with full rows ie on PgUp and PGDn anchor    */
  224.          /* the last line to the bottom of the screen. Then go to Reformat   */
  225.          /* to display the new rows in the window.                           */
  226.          /********************************************************************/
  227.            case UP:
  228.              StartRow--;
  229.              StartRow = (StartRow < 1) ? 1 : StartRow;
  230.              goto Reformat;
  231.            case DOWN:
  232.              StartRow++;
  233.              StartRow = min(StartRow,(int)(rows-HeaderRows-ScreenRows+1));
  234.              StartRow = (StartRow < 1) ? 1 : StartRow;
  235.              goto Reformat;
  236.            case PGUP:
  237.              StartRow = StartRow - ScreenRows;
  238.              StartRow = (StartRow < 1) ? 1 : StartRow;
  239.              goto Reformat;
  240.            case PGDN:
  241.              StartRow = StartRow + ScreenRows;
  242.              StartRow = min(StartRow,(int)(rows-HeaderRows-ScreenRows+1));
  243.              StartRow = (StartRow < 1) ? 1 : StartRow;
  244.              goto Reformat;
  245.            default:
  246.              break;
  247.          }
  248.     }
  249.  
  250.     Vputbox( vbuf, row, col, TotalRows, TotalCols );
  251.     Tfree( vbuf );                                                       /*521*/
  252.     return( ans );
  253. }
  254.  
  255.  void
  256. fmterr(uchar *msg)
  257. {
  258.   char SaveVideoAtr;                    /* holds the current video attr   701*/
  259.   SaveVideoAtr = VideoAtr;              /* save the current video attr    701*/
  260.   ClrScr( MsgRow, MsgRow, vaError );
  261.   if( msg ) putrc( MsgRow, 0, msg );
  262.   VideoAtr = SaveVideoAtr;              /* Restore saved video attribute  701*/
  263. }
  264.  
  265. void
  266. fmt2err(uchar *msg1,uchar *msg2)
  267. {
  268.     fmterr( msg1 );
  269.     if( msg1 && msg2 ) putrc( MsgRow, strlen(msg1) + 1, msg2 );
  270. }
  271.  
  272. void
  273. putmsg(uchar *msg)
  274. {
  275.     ClrScr( MsgRow, MsgRow, vaError );
  276.     if( msg ) putrc( MsgRow, 0, msg );
  277. }
  278.  
  279.  void
  280. SayMsgBox1(uchar *msg )
  281. {
  282.     uint row, rows, col, cols;
  283.  
  284.     rows = 1;
  285.     cols = strlen(msg);
  286.  
  287.     row = (VideoRows - (rows += 2)) >> 1;
  288.     col = (VideoCols - (cols += 4)) >> 1;
  289.  
  290.     VideoAtr = vaInfo;
  291.     Vfmtbox( "", row, col, rows, cols );
  292.     putrc( row+1, col+2, msg );
  293. }
  294.  
  295.  void
  296. SayMsgBox2( uchar *msg, ulong delay )
  297. {
  298.     uchar *vbuf, vacopy = VideoAtr;
  299.     uint cols=strlen(msg), rows=1, col, row;   /* was register.           112*/
  300.  
  301.     HideCursor();
  302.     row = (VideoRows - (rows += 2)) >> 1;
  303.     col = (VideoCols - (cols += 4)) >> 1;
  304.     vbuf = Talloc(2*rows*cols);                                         /*521*/
  305.     Vgetbox( vbuf, row, col, rows, cols );
  306.  
  307.     VideoAtr = vaInfo;
  308.     Vfmtbox( "", row, col, rows, cols );
  309.     putrc( row+1, col+2, msg );
  310.  
  311.     DosSleep(delay);
  312.  
  313.     Vputbox( vbuf, row, col, rows, cols );
  314.     VideoAtr = vacopy;
  315.     Tfree( vbuf );                                                       /*521*/
  316. }
  317.  
  318. /*****************************************************************************/
  319. /*  This function is same as saymsgbox1 except that it shifts the box to  401*/
  320. /*  the left by 2 columns to avoid the over lap with the register windows,401*/
  321. /*  its used only by the restart function                                 401*/
  322. /*****************************************************************************/
  323.  void
  324. SayMsgBox3(uchar *msg )
  325. {
  326.     uint row, rows, col, cols;
  327.  
  328.     rows = 1;
  329.     cols = strlen(msg);
  330.  
  331.     row = (VideoRows - (rows += 2)) >> 1;
  332.     col = (VideoCols - (cols += 4) - 4 ) >> 1;
  333.  
  334.     VideoAtr = vaInfo;
  335.     Vfmtbox( "", row, col, rows, cols );
  336. /*msh  putrcx( row+1, col+2, msg , 0); */
  337.     putrcx( row+1, col+2, msg);
  338. }
  339.  
  340. uchar *SayMsgBox4( uchar *msg )
  341. {
  342.     uchar *buf, vacopy = VideoAtr;
  343.     uint  cols = strlen( msg ), rows = 1, col, row;  /* was register.     112*/
  344.  
  345.     HideCursor();
  346.     row = (VideoRows - (rows += 2)) >> 1;
  347.     col = (VideoCols - (cols += 4)) >> 1;
  348.     buf = Talloc(2*rows*cols);                                         /*521*/
  349.     Vgetbox( buf, row, col, rows, cols );
  350.  
  351.     VideoAtr = vaInfo;
  352.     Vfmtbox( "", row, col, rows, cols );
  353.     putrc( row + 1, col + 2, msg );
  354.  
  355.     VideoAtr = vacopy;
  356.     return( buf );
  357. }
  358.  
  359. void RemoveMsgBox( uchar *msg, uchar *buf )
  360. {
  361.     uchar vacopy = VideoAtr;
  362.     uint  cols = strlen( msg ), rows = 1, col, row;  /* was register.     112*/
  363.  
  364.     HideCursor();
  365.     row = (VideoRows - (rows += 2)) >> 1;
  366.     col = (VideoCols - (cols += 4)) >> 1;
  367.  
  368.     VideoAtr = vaInfo;
  369.  
  370.     Vputbox( buf, row, col, rows, cols );
  371.     VideoAtr = vacopy;
  372. }
  373.  
  374.  
  375. #define BUTTONROW  (StartRow + TotalRows - 2)
  376. #define BUTTONCOL  (StartCol + (TotalCols / 2) - 3)
  377. #define BUTTONLEN  6
  378.  
  379. /*****************************************************************************/
  380. /* CuaShowHelpBox()                                                       701*/
  381. /*                                                                           */
  382. /* Description:                                                              */
  383. /*                                                                           */
  384. /*   Displays a given text in a dialog box.                                  */
  385. /*                                                                           */
  386. /* Parameters:                                                               */
  387. /*                                                                           */
  388. /*   HelpText  -> pointer to a buffer containing the text to be displayed.   */
  389. /*                                                                           */
  390. /* Return:                                                                   */
  391. /*          None                                                             */
  392. /*                                                                           */
  393. /*****************************************************************************/
  394. void  CuaShowHelpBox( uchar *HelpText )
  395. {
  396.   uint   RowCount, ColCount;
  397.   uint   TotalRows, TotalCols;
  398.   uint   n = 0, MsgLen,  ScrollBar = FALSE;
  399.   uchar  *Buffer;
  400.  
  401.   HelpMessage = HelpText;
  402.  
  403.   MsgLen = strlen( Buffer = HelpText );
  404.  
  405.   /***************************************************************************/
  406.   /* Count the number of max rows and columns needed to display the text.    */
  407.   /***************************************************************************/
  408.   for( RowCount = ColCount = 0; MsgLen; ++RowCount, MsgLen -= n, Buffer += n )
  409.   {
  410.       if( (n = strcspn( Buffer, "\r" )) > ColCount )
  411.           ColCount = n;
  412.       if( (n == 0) && (RowCount == 0) )
  413.           RowCount -= 1;
  414.       if( n < MsgLen )
  415.           Buffer[ n++ ] = 0;
  416.       if( (n < MsgLen) && (Buffer[ n ] == '\n') )
  417.           n += 1;
  418.   }
  419.  
  420.   TotalRows = RowCount + 6;
  421.   TotalCols = ColCount + 6;
  422.  
  423.   TotalCols = (TotalCols < VideoCols) ? TotalCols : VideoCols;
  424.  
  425.   /***************************************************************************/
  426.   /* Set the various attributes of the dialog box depending on the max rows  */
  427.   /* and columns.                                                            */
  428.   /***************************************************************************/
  429.   Dia_HelpBox_Choices.entries = RowCount;
  430.   if( TotalRows > VideoRows )
  431.   {
  432.     Dia_HelpBox_Choices.MaxRows = VideoRows - 10;
  433.     Dia_HelpBox.length = VideoRows - 4;
  434.     ScrollBar = TRUE;
  435.   }
  436.   else
  437.   {
  438.     Dia_HelpBox_Choices.MaxRows = RowCount;
  439.     Dia_HelpBox.length = TotalRows;
  440.   }
  441.  
  442.   Dia_HelpBox.width = TotalCols;
  443.  
  444.   Dia_HelpBox.col    = (VideoCols - TotalCols) >> 1;
  445.   Dia_HelpBox.row    = (VideoRows - Dia_HelpBox.length) >> 1;
  446.   Dia_HelpBox.Buttons[0].row = Dia_HelpBox.row +
  447.                                Dia_HelpBox_Choices.MaxRows + 4;    /*701*/
  448.   Dia_HelpBox.Buttons[0].col = ( Dia_HelpBox.width -
  449.                                  Dia_HelpBox.Buttons[0].length ) / 2 +
  450.                                Dia_HelpBox.col;
  451.  
  452.   ClearField[1] = (uchar)Dia_HelpBox.width;
  453.   DisplayDialog( &Dia_HelpBox, ScrollBar );
  454.   ProcessDialog( &Dia_HelpBox, &Dia_HelpBox_Choices, ScrollBar, NULL );
  455.   RemoveDialog( &Dia_HelpBox );
  456. }
  457.  
  458. /*****************************************************************************/
  459. /* DisplayHelpBoxText()                                                   701*/
  460. /*                                                                           */
  461. /* Description:                                                              */
  462. /*                                                                           */
  463. /*   Displays the help text.                                                 */
  464. /*                                                                           */
  465. /* Parameters:                                                               */
  466. /*                                                                           */
  467. /*   shell   ->  pointer to a dialog shell structure.                        */
  468. /*   ptr     ->  pointer to a dialog choice structure.                       */
  469. /*                                                                           */
  470. /* Return:                                                                   */
  471. /*          None                                                             */
  472. /*                                                                           */
  473. /*****************************************************************************/
  474. void  DisplayHelpBoxText( DIALOGSHELL *shell, DIALOGCHOICE *ptr )
  475. {
  476.   int    i, idx, MsgLen;
  477.   uchar  *message;
  478.  
  479.   message = HelpMessage;
  480.   for( i = 0; i <= ptr->SkipRows; i++ )
  481.   {
  482.     MsgLen = strlen( message );
  483.     if( *(message += MsgLen + 1) == '\n' )
  484.       message += 1;
  485.   }
  486.  
  487.   ClearField[1] = shell->width - 5;
  488.   for( i = 0, idx = ptr->SkipRows; i < ptr->MaxRows; idx++, i++ )
  489.   {
  490.     putrcx( shell->row + i + shell->SkipLines, shell->col + 2, ClearField);
  491.     MsgLen = strlen( message );
  492.  
  493.     if( *message == '\t' )
  494.         putrcx( shell->row + i + shell->SkipLines,
  495.                 shell->col + 2 + ((shell->width - 3 - MsgLen) >> 1),
  496.                 message + 1 );
  497.     else
  498.         putrcx( shell->row + i + shell->SkipLines, shell->col + 2, message);
  499.  
  500.     if( *(message += MsgLen + 1) == '\n' )
  501.       message += 1;
  502.   }
  503. }
  504.  
  505. /*****************************************************************************/
  506. /* HelpBoxDialogFunction()                                                701*/
  507. /*                                                                           */
  508. /* Description:                                                              */
  509. /*                                                                           */
  510. /* This is the function called by ProcessDialog (in pulldown.c) whenever an  */
  511. /* event occurs in the dialog. This fuction handles the events in a way      */
  512. /* specific to this dialog.                                                  */
  513. /*                                                                           */
  514. /* Parameters:                                                               */
  515. /*                                                                           */
  516. /*   shell         input  - Pointer to DIALOGSHELL structure.                */
  517. /*   ptr           input  - Pointer to DIALOGCHOICE structure.               */
  518. /*   nEvent        input  - Pointer to EVENT structure.                      */
  519. /*                                                                           */
  520. /* Return:                                                                   */
  521. /*        = 0     - The caller has to continue processing the dialog.        */
  522. /*       != 0     - The caller can terminate processing the dialog.          */
  523. /*****************************************************************************/
  524. uint  HelpBoxDialogFunction( DIALOGSHELL *shell, DIALOGCHOICE *ptr,
  525.                              EVENT *nEvent, void *ParamBlock )
  526. {
  527.   static uchar  Save;
  528.  
  529.   switch( nEvent->Value )
  530.   {
  531.     case INIT_DIALOG:
  532.     {
  533.       Save = hilite[1];
  534.       hilite[1] = normal[1] = 0;
  535.       return( 0 );
  536.     }
  537.  
  538.     case ENTER:
  539.     case ESC:
  540.     {
  541.       hilite[1] = normal[1] = Save;
  542.       return( ESC );
  543.     }
  544.  
  545.     default:
  546.       return( 0 );
  547.   }
  548. }
  549.  
  550. /*****************************************************************************/
  551. /* Error()                                                                   */
  552. /*                                                                           */
  553. /* Description:                                                              */
  554. /*                                                                           */
  555. /*   Display a fatal message and then exit the debugger.                     */
  556. /*                                                                           */
  557. /*   This function allows for a substitution string and a substitution       */
  558. /*   number to be tossed into the %1 and %2 fields of the message            */
  559. /*   defined by the message id.                                              */
  560. /*                                                                           */
  561. /* Parameters:                                                               */
  562. /*                                                                           */
  563. /*   MsgId          id of the message to display.                            */
  564. /*   Fatal          TRUE=>kill the debugger. FALSE=>informational.           */
  565. /*   SubStringCount String that will go into %1,%2,... substitutions.        */
  566. /*   ...            list of ptrs to strings                                  */
  567. /*                                                                           */
  568. /* Return:                                                                   */
  569. /*                                                                           */
  570. /* Assumptions:                                                              */
  571. /*                                                                           */
  572. /*   Vio has been initialized.                                               */
  573. /*                                                                           */
  574. /*****************************************************************************/
  575. #include <stdarg.h>
  576. void _System Error(ULONG MsgId, int Fatal,int SubStringCount,...)
  577. {
  578.  UCHAR   *SubStringTable[MAX_SUBSTRINGS];
  579.  int      i;
  580.  va_list  pSubString;
  581.  UCHAR   *pMsgBuf;
  582.  CSR      DosCsr;
  583.  
  584.  va_start(pSubString,SubStringCount);
  585.  for( i = 0; i < SubStringCount; i++ )
  586.   SubStringTable[i] = va_arg(pSubString,char *);
  587.  
  588.  pMsgBuf = GetHelpMsg(MsgId, SubStringTable,SubStringCount);
  589.  
  590.  DosBeep( 1000/*Hz*/, 3/*Millisecs*/ );
  591.  
  592.  CuaShowHelpBox(pMsgBuf);
  593.  Tfree( pMsgBuf );
  594.  if( Fatal == FALSE )
  595.   return;
  596.  UnRegisterExceptionHandler( );
  597.  ClrPhyScr( 0, VideoRows-1, vaClear );
  598.  DosCsr.col = 0;
  599.  DosCsr.row = ( uchar )(VideoRows-1);
  600.  PutCsr( &DosCsr );
  601.  exit(0);
  602. }
  603.  
  604. /*****************************************************************************/
  605. /* Message()                                                                 */
  606. /*                                                                           */
  607. /* Description:                                                              */
  608. /*                                                                           */
  609. /*   Display a fatal message and then exit the debugger.                     */
  610. /*                                                                           */
  611. /*   This function allows for a substitution string and a substitution       */
  612. /*   number to be tossed into the %1 and %2 fields of the message            */
  613. /*   defined by the message id.                                              */
  614. /*                                                                           */
  615. /* Parameters:                                                               */
  616. /*                                                                           */
  617. /*   MsgId          id of the message to display.                            */
  618. /*   Beep           TRUE=>scream about it. FALSE=>just a quiet bit of info.  */
  619. /*   SubStringCount String that will go into %1,%2,... substitutions.        */
  620. /*   ...            list of ptrs to strings                                  */
  621. /*                                                                           */
  622. /* Return:                                                                   */
  623. /*                                                                           */
  624. /* Assumptions:                                                              */
  625. /*                                                                           */
  626. /*****************************************************************************/
  627. void _System Message(ULONG MsgId, int Beep,int SubStringCount,...)
  628. {
  629.  UCHAR   *SubStringTable[MAX_SUBSTRINGS];
  630.  int      i;
  631.  va_list  pSubString;
  632.  UCHAR   *pMsgBuf;
  633.  
  634.  va_start(pSubString,SubStringCount);
  635.  for( i = 0; i < SubStringCount; i++ )
  636.   SubStringTable[i] = va_arg(pSubString,char *);
  637.  
  638.  pMsgBuf = GetHelpMsg(MsgId, SubStringTable,SubStringCount);
  639.  if(Beep)
  640.   beep();
  641.  SayStatusMsg(pMsgBuf);
  642.  Tfree( pMsgBuf );
  643.  return;
  644. }
  645.  
  646. /*****************************************************************************/
  647. /* SayStatusMsg()                                                            */
  648. /*                                                                           */
  649. /* Description:                                                              */
  650. /*                                                                           */
  651. /*   Display an informational message on the message line.                   */
  652. /*                                                                           */
  653. /* Parameters:                                                               */
  654. /*                                                                           */
  655. /*   pMsg           -> to Z-String message.                                  */
  656. /*                                                                           */
  657. /* Return:                                                                   */
  658. /*                                                                           */
  659. /* Assumptions:                                                              */
  660. /*                                                                           */
  661. /*  Message is less than 80 bytes.                                           */
  662. /*                                                                           */
  663. /*                                                                           */
  664. /*****************************************************************************/
  665. void SayStatusMsg(UCHAR *msg)
  666. {
  667.  char  SaveVideoAtr;
  668.  char *cp;
  669.  
  670.  /****************************************************************************/
  671.  /* - The message may contain cr/lf characters. We need to replace them      */
  672.  /*   with spaces.                                                           */
  673.  /****************************************************************************/
  674.  for( cp = msg; *cp ; cp++ )
  675.  {
  676.   if( (*cp == '\r') || (*cp == '\n') )
  677.    *cp = ' ';
  678.  }
  679.  
  680.  SaveVideoAtr = VideoAtr;
  681.  ClrScr( MsgRow, MsgRow, vaError );
  682.  if( msg ) putrc( MsgRow, 0, msg );
  683.  VideoAtr = SaveVideoAtr;
  684. }
  685.  
  686. /*****************************************************************************/
  687. /* MsgYorN()                                                                 */
  688. /*                                                                           */
  689. /* Description:                                                              */
  690. /*                                                                           */
  691. /*   Display a prompt for a yes or no keyboard response.                     */
  692. /*                                                                           */
  693. /* Parameters:                                                               */
  694. /*                                                                           */
  695. /*   MsgId          id of the message to display.                            */
  696. /*                                                                           */
  697. /* Return:                                                                   */
  698. /*                                                                           */
  699. /*   key                                                                     */
  700. /*                                                                           */
  701. /* Assumptions:                                                              */
  702. /*                                                                           */
  703. /*****************************************************************************/
  704. UINT MsgYorN(ULONG MsgId)
  705. {
  706.  UCHAR   *pMsgBuf;
  707.  uint     key;
  708.  
  709.  pMsgBuf = GetHelpMsg(MsgId, NULL,0 );
  710.  key = SayMsgBox(pMsgBuf);
  711.  Tfree( pMsgBuf );
  712.  return(key);
  713. }
  714.  
  715. /*****************************************************************************/
  716. /* SayMsgBox()                                                               */
  717. /*                                                                           */
  718. /* Description:                                                              */
  719. /*                                                                           */
  720. /*   Display a prompt.                                                       */
  721. /*                                                                           */
  722. /* Parameters:                                                               */
  723. /*                                                                           */
  724. /*   msg            ->to display message.                                    */
  725. /*                                                                           */
  726. /* Return:                                                                   */
  727. /*                                                                           */
  728. /* Assumptions:                                                              */
  729. /*                                                                           */
  730. /*****************************************************************************/
  731. UINT SayMsgBox(uchar *msg)
  732. {
  733.  UINT  row, rows, col, cols;
  734.  char *cp=NULL;
  735.  char *cpp;
  736.  int   len;
  737.  int   msglen = strlen(msg);
  738.  int   numrows;
  739.  int   n;
  740.  char *vbuf;
  741.  UINT  key;
  742.  
  743.  /****************************************************************************/
  744.  /* - Count the rows and cols needed to display by tokenizing on \n.         */
  745.  /****************************************************************************/
  746.  numrows = 0;
  747.  rows = 0;
  748.  cols = 0;
  749.  cp = strtok(msg,"\n");
  750.  do
  751.  {
  752.   numrows++;
  753.   len = 0;
  754.   cpp = cp;
  755.   while(*cpp++ != '\r') len++;
  756.   cols = (cols>len)?cols:len;
  757.   cp = strtok(NULL,"\n");
  758.  }
  759.  while( cp );
  760.  
  761.  /****************************************************************************/
  762.  /* - tokenization left \0s where the \ns were. Replace \0s with spaces.     */
  763.  /****************************************************************************/
  764.  for( cp=msg;msglen;msglen--,cp++ )
  765.   if( *cp == '\r')
  766.    *cp = ' ';
  767.  
  768.  /****************************************************************************/
  769.  /* - compute the top left origin of the display box and format.             */
  770.  /****************************************************************************/
  771.  rows = numrows;
  772.  row = (VideoRows - (rows += 2)) >> 1;
  773.  col = (VideoCols - (cols += 4)) >> 1;
  774.  
  775.  VideoAtr = vaInfo;
  776.  vbuf = Talloc(2*rows*cols);
  777.  Vgetbox( vbuf, row, col,rows, cols );
  778.  Vfmtbox( "", row, col, rows, cols );
  779.  /****************************************************************************/
  780.  /* - write the message to the display.                                      */
  781.  /****************************************************************************/
  782.  for( cp = msg, n=row ; numrows ; numrows--,n++ )
  783.  {
  784.   putrc( n+1, col+2, cp );
  785.   cp += strlen(cp) + 1;
  786.  }
  787.  
  788.  {
  789.   PEVENT pEvent;
  790.  
  791.   pEvent = GetEvent( SEM_INDEFINITE_WAIT );
  792.   key = pEvent->Value;
  793.   pEvent->Value = 0;
  794.  }
  795.  
  796.  Vputbox( vbuf, row, col, rows, cols );
  797.  Tfree( vbuf );
  798.  return( key );
  799. }
  800.  
  801. /*****************************************************************************/
  802. /* SayMsgBox5()                                                              */
  803. /*                                                                           */
  804. /* Description:                                                              */
  805. /*                                                                           */
  806. /*   Display a prompt.                                                       */
  807. /*                                                                           */
  808. /* Parameters:                                                               */
  809. /*                                                                           */
  810. /*   msg            ->to display message.                                    */
  811. /*                                                                           */
  812. /* Return:                                                                   */
  813. /*                                                                           */
  814. /* Assumptions:                                                              */
  815. /*                                                                           */
  816. /*****************************************************************************/
  817. void _System SayMsgBox5(ULONG MsgId, int SubStringCount,...)
  818. {
  819.  UCHAR   *SubStringTable[MAX_SUBSTRINGS];
  820.  int      i;
  821.  va_list  pSubString;
  822.  UCHAR   *pMsgBuf;
  823.  
  824.  UINT  row, rows, col, cols;
  825.  char *cp=NULL;
  826.  char *cpp;
  827.  int   len;
  828.  int   msglen;
  829.  int   numrows;
  830.  int   n;
  831.  char *vbuf;
  832.  
  833.  va_start(pSubString,SubStringCount);
  834.  for( i = 0; i < SubStringCount; i++ )
  835.   SubStringTable[i] = va_arg(pSubString,char *);
  836.  
  837.  pMsgBuf = GetHelpMsg(MsgId, SubStringTable,SubStringCount);
  838.  
  839.  msglen = strlen(pMsgBuf);
  840.  
  841.  /****************************************************************************/
  842.  /* - Count the rows and cols needed to display by tokenizing on \n.         */
  843.  /****************************************************************************/
  844.  numrows = 0;
  845.  rows = 0;
  846.  cols = 0;
  847.  cp = strtok(pMsgBuf,"\n");
  848.  do
  849.  {
  850.   numrows++;
  851.   len = 0;
  852.   cpp = cp;
  853.   while(*cpp++ != '\r') len++;
  854.   cols = (cols>len)?cols:len;
  855.   cp = strtok(NULL,"\n");
  856.  }
  857.  while( cp );
  858.  
  859.  /****************************************************************************/
  860.  /* - tokenization left \0s where the \ns were. Replace \0s with spaces.     */
  861.  /****************************************************************************/
  862.  for( cp=pMsgBuf;msglen;msglen--,cp++ )
  863.   if( *cp == '\r')
  864.    *cp = ' ';
  865.  
  866.  /****************************************************************************/
  867.  /* - compute the top left origin of the display box and format.             */
  868.  /****************************************************************************/
  869.  rows = numrows;
  870.  row = (VideoRows - (rows += 2)) >> 1;
  871.  col = (VideoCols - (cols += 4)) >> 1;
  872.  
  873.  VideoAtr = vaInfo;
  874.  vbuf = Talloc(2*rows*cols);
  875.  Vgetbox( vbuf, row, col,rows, cols );
  876.  Vfmtbox( "", row, col, rows, cols );
  877.  /****************************************************************************/
  878.  /* - write the message to the display.                                      */
  879.  /****************************************************************************/
  880.  for( cp = pMsgBuf, n=row ; numrows ; numrows--,n++ )
  881.  {
  882.   putrc( n+1, col+2, cp );
  883.   cp += strlen(cp) + 1;
  884.  }
  885.  DosSleep(1000);
  886.  Vputbox( vbuf, row, col, rows, cols );
  887.  Tfree( vbuf );
  888.  return;
  889. }
  890.  
  891. /*---------------------------------------------------------------------------*/
  892. /* - Below here added for MSH support.                                       */
  893. /*---------------------------------------------------------------------------*/
  894. #ifdef MSH
  895. void FmtErr(uchar *msg) {
  896.   if(iview) {
  897.       VioContext *vioContext=SaveVioContext(NULL);
  898.       RestoreVioContext(&MainVioContext);
  899.       fmterr(msg);
  900.       RestoreVioContext(vioContext);
  901.       Tfree(vioContext);
  902.   }
  903.   else
  904.   {
  905.       fmterr(msg);
  906.   }/* End if*/
  907. }
  908. #endif
  909.