home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / SHOWC.C < prev    next >
C/C++ Source or Header  |  1996-05-16  |  103KB  |  1,798 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   showc.c                                                                 */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*   Source window processing.                                               */
  7. /*                                                                           */
  8. /*                                                                           */
  9. /* History:                                                                  */
  10. /*                                                                           */
  11. /*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  */
  12. /*                                                                           */
  13. /*...16->32 port.                                                            */
  14. /*...                                                                        */
  15. /*... 02/08/91  100   Philip    port to 32 bit.                              */
  16. /*... 02/08/91  101   Joe       port to 32 bit.                              */
  17. /*... 02/08/91  102   Pratima   port to 32 bit.                              */
  18. /*... 02/08/91  103   Dave      port to 32 bit.                              */
  19. /*... 02/08/91  104                                                          */
  20. /*... 02/08/91  105   Christina port to 32 bit.                              */
  21. /*... 02/08/91  106   Srinivas  port to 32 bit.                              */
  22. /*... 02/08/91  107   Dave      port to 32 bit.                              */
  23. /*... 02/08/91  108   Dave      port to 32 bit.                              */
  24. /*... 02/08/91  109                                                          */
  25. /*... 02/08/91  110   Srinivas  port to 32 bit.                              */
  26. /*... 02/08/91  111   Christina port to 32 bit.                              */
  27. /*... 02/08/91  112   Joe       port to 32 bit.                              */
  28. /*... 02/08/91  113                                                          */
  29. /*... 02/08/91  114                                                          */
  30. /*... 02/08/91  115   Srinivas  port to 32 bit.                              */
  31. /*... 02/08/91  116   Joe       port to 32 bit.                              */
  32. /*                                                                           */
  33. /*...Release 1.00 (Pre-release 1)                                            */
  34. /*...                                                                        */
  35. /*... 08/06/91  221   srinivas  Users app being started in back ground       */
  36. /*... 08/19/91  229   srinivas  ESC key should take back to action bar from  */
  37. /*...                           showthds and editregs.                       */
  38. /*... 08/22/91  234   Joe       PL/X gives "varname" is incorrect message    */
  39. /*...                           when entering a parameter name in the data   */
  40. /*...                           window.  This happens when the cursor is on  */
  41. /*...                           an internal procedure definition statement   */
  42. /*...                           and you use F2 to get into the data window   */
  43. /*...                           and then type the name.                      */
  44. /*... 08/30/91  235   Joe       Cleanup/rewrite ascroll() to fix several bugs*/
  45. /*                                                                           */
  46. /*...Release 1.00 (Pre-release 105 10/10/91)                                 */
  47. /*...                                                                        */
  48. /*... 10/31/91  308   Srinivas  Menu for exceptions.                         */
  49. /*...                                                                        */
  50. /*...Release 1.00 (Pre-release 107 11/13/91)                                 */
  51. /*...                                                                        */
  52. /*... 11/13/91  400   Srinivas  Vertical Register Display.                   */
  53. /*...                                                                        */
  54. /*... 11/18/91  401   Srinivas  Floating point Register Display.             */
  55. /*...                                                                        */
  56. /*...Release 1.00 (Pre-release 108 12/05/91)                                 */
  57. /*...                                                                        */
  58. /*... 01/28/92  508   Srinivas  Added Set Execution Line function.           */
  59. /*... 02/05/92  511   Srinivas  Allow turning off screen swapping while      */
  60. /*...                           executing.                                   */
  61. /*... 02/10/92  517   Srinivas  Cusrsor sensitive prompting for GetFunc.     */
  62. /*... 02/11/92  518   Srinivas  Remove limitation on max no of screen rows.  */
  63. /*... 02/12/92  521   Srinivas  Port to C-Set/2.                             */
  64. /*...                                                                        */
  65. /*...Release 1.00 (03/03/92)                                                 */
  66. /*...                                                                        */
  67. /*... 03/10/92  602   Srinivas  Hooking up watch points.                     */
  68. /*... 03/12/92  603   Srinivas  Problem with files longer than 80 cols.      */
  69. /*...                                                                        */
  70. /*...Release 1.01 (04/03/92)                                                 */
  71. /*...                                                                        */
  72. /*... 08/03/92  701   Joe       Cua Interface.                               */
  73. /*... 10/05/92  701   Michelle  Help window.                                 */
  74. /*... 01/12/93  808   Selwyn    Profile fixes/improvements.                  */
  75. /*... 03/22/93  816   Selwyn    PgUp/PgDn not working after F6 in a large    */
  76. /*...                           file.                                        */
  77. /**Includes*******************************************************************/
  78.                                         /*                                   */
  79. #include "all.h"                        /* SD86 include files                */
  80. static int   iview=0;   /*Shared with showa.c*/
  81.  
  82. uint str_fnd_flag;                      /* flag to indicate the wether to 110*/
  83.                                         /* mark the word in reverse video 110*/
  84.  
  85. /**Externs********************************************************************/
  86. extern uint slen;                       /* len of string found with FIND  110*/
  87. extern AFILE      *allfps;              /* all known files                   */
  88. extern AFILE      *fp_focus;            /* if return(-1)                     */
  89. extern uint        VideoCols;           /* # of cols per screen              */
  90. extern uint        VideoRows;           /* # of rows per screen           518*/
  91. extern uint        HideDataWin;         /* data window hidden flag.          */
  92. extern uint        LinesPer;            /* current # lines/screen for code   */
  93. extern KEY2FUNC    defk2f[];            /*                                   */
  94. extern uchar       Reg_Display = 0;     /* Register display flag          400*/
  95. extern uchar      *BoundPtr;            /* -> to screen bounds            518*/
  96. extern char        GetFuncBuffer[];     /* save buffer for GetFunc.       517*/
  97. extern uint        VioStartOffSet;      /* flag to tell were to start scr 701*/
  98. extern int        BlowBy;               /* blow by GetFuncsFromEvents flag701*/
  99. extern CmdParms   cmd;
  100. extern PROCESS_NODE *pnode;                                             /*827*/
  101. extern UINT       TopLine;              /* current top line for code         */
  102. extern UINT       MaxData;              /* max # of lines of Data            */
  103.  
  104. static AFILE      *showfp;              /* static var to hold current fp  701*/
  105. static uchar      *lp;                  /* pointer line in source buffer  701*/
  106. static uint       SrcCol;               /* cursor column position         701*/
  107. static uint       SrcLine;              /* cursor source line position    701*/
  108.  
  109. UINT  SyncAddr;                         /* used to sync ASM and SOURCE views */
  110. UINT  NoPaint;                          /* used by formatting routines also  */
  111. UINT  DataFileBot;                      /* last rec shown.            (0..N) */
  112. UINT  DataFileTop;                      /* 1st  rec shown.            (0..N) */
  113. UINT  SaveTopLine;                      /* saved top line for data window.   */
  114.  
  115.  
  116. /*                                                                           */
  117. /**Begin Code*****************************************************************/
  118. /*                                                                           */
  119. /*****************************************************************************/
  120. uint                                    /* chg return value to uint       521*/
  121. showC( AFILE *fp , uchar *msg )         /* show the source & handle k/b      */
  122.                                         /* AFILE block pointer               */
  123.                                         /* message pointer                   */
  124. {
  125.  AFILE  *Newfp;
  126.  uint   n;                              /* just an unsigned integer          */
  127.  uint   key;                            /* key returned from GetKey()     101*/
  128.  uint   span;                           /* # of bytes spanned by source line */
  129.  ULONG  xline;                          /* disasm display sync line          */
  130.  int    ScrollAmt;                      /* how much to scroll the screen     */
  131.  int    CsrAdjust;                      /* how much to adjust the cursor     */
  132.  int    func;                           /* function associated with a key    */
  133.  int    rc;                             /* return code from ShowAppScr    521*/
  134.  uchar     hlight[4];                   /* attributes for find string     110*/
  135.  int    MouseState;
  136.  char   InitString[81];
  137.  
  138.  LNOTAB *pLnoTabEntry;
  139.                                         /*                                   */
  140.  showfp = fp;
  141.  
  142.  if( fp->flags & AF_SYNC )              /* sync asm and source views         */
  143.  {
  144.   SetBitOff(fp->flags, AF_SYNC);        /* set "views synchronized"  in AFILE*/
  145.  
  146.   if(DBMapInstAddr(SyncAddr, &pLnoTabEntry, fp->pdf))
  147.   {
  148.    xline = 0;
  149.    if(pLnoTabEntry) xline = pLnoTabEntry->lno;
  150.  
  151.    xline -= fp->Nbias;                  /* make relative to source buf begin */
  152.  
  153.    if( xline  > fp->Nlines )            /* if past end of the source buffer  */
  154.     xline = fp->Nlines;                 /* then set it to last buffer line   */
  155.  
  156.    fp->topline += xline-1;              /* define the new topline            */
  157.  
  158.    fp->hotline = xline;                 /* define the hotline                */
  159.    fp->flags |= AF_ZOOM;                /* set flag to show current exec line*/
  160.   }
  161.  }                                      /* end of sync asm and source views  */
  162. /*
  163.   The hotline is the source line number where execution has stopped.
  164. */
  165.  
  166.  NoPaint = (fp->flags & AF_ZOOM);       /* set "show current exec line" flag */
  167.  if(!iview) fmtscr( fp );               /* show the screen for this afile    */
  168.  
  169.  if( NoPaint )
  170.  {
  171. /*****************************************************************************/
  172. /* If the hotline falls above the currently shown screen, then scroll        */
  173. /* up until the hotline is in view. The top margin is "ADJUST" lines down    */
  174. /* from the top.                                                             */
  175. /*                                                                           */
  176. /*****************************************************************************/
  177.   #define ADJUST  4                     /*                                   */
  178. if(!iview) {
  179.   if( (fp->hotline) < fp->topline )     /* if the hotline is above the    234*/
  180.   {                                     /* screen, then scroll the screen    */
  181.                                         /* to bring the hotline into view.   */
  182.    ScrollAmt=fp->hotline-1 -            /*                                   */
  183.              fp->topline;               /* adjust below top  of screen.      */
  184.    ScrollAmt-=ADJUST;                   /*                                   */
  185.    dovscr( fp, ScrollAmt );             /* now perform the scroll.           */
  186.    }
  187. }
  188. else {
  189. #ifdef MSH
  190.   if( (fp->hotline) < fp->topline )     /* if the hotline is above the    234*/
  191.   {                                     /* screen, then scroll the screen    */
  192.                                         /* to bring the hotline into view.   */
  193.    ScrollAmt=fp->hotline-1 -            /*                                   */
  194.              fp->topline;               /* adjust below top  of screen.      */
  195.    ScrollAmt-=ADJUST;                   /*                                   */
  196.    Window[SOURCE_WIN]->user_data=(void *) fp;
  197.    DoVscr(Window[SOURCE_WIN],ScrollAmt);
  198.    }
  199. #endif
  200. }
  201. /*****************************************************************************/
  202. /* If the hotline falls below the currently shown screen, then scroll down   */
  203. /* to bring the hotline into view. Also, provide margin adjustment.          */
  204. /*                                                                           */
  205. /*****************************************************************************/
  206. if(!iview) {
  207.   if( (fp->hotline) >=                  /* if the hot line is below the      */
  208.       (fp->topline+fp->Nshown)          /* screen, then scroll screen down   */
  209.     )                                   /*                                   */
  210.   {                                     /*                                   */
  211.    ScrollAmt=fp->hotline - fp->topline; /*                                234*/
  212.    ScrollAmt-=ADJUST;                   /* adjust below the top of screen.   */
  213.    dovscr( fp, ScrollAmt );             /* now perform the scroll.           */
  214.   }                                     /*                                   */
  215. }
  216. else {
  217. #ifdef MSH
  218.   if( (fp->hotline) >=                  /* if the hot line is below the      */
  219.       (fp->topline+fp->Nshown)          /* screen, then scroll screen down   */
  220.     )                                   /*                                   */
  221.   {                                     /*                                   */
  222.    ScrollAmt=fp->hotline - fp->topline; /*                                234*/
  223.    ScrollAmt-=ADJUST;                   /* adjust below the top of screen.   */
  224.    Window[SOURCE_WIN]->user_data=(void *) fp;
  225.    DoVscr(Window[SOURCE_WIN],ScrollAmt);
  226.   }                                     /*                                   */
  227. #endif
  228. }
  229.  
  230.                                         /*                                   */
  231. /*****************************************************************************/
  232. /*                                                                           */
  233. /*                                                                           */
  234. /*                                                                           */
  235. /*****************************************************************************/
  236.  
  237.   NoPaint = 0;                          /* ??????????????????????????????????*/
  238.   SetBitOff(fp->flags, AF_ZOOM);        /* do the same in the AFILE struct   */
  239.  
  240.   CsrAdjust = fp->hotline - fp->csrline; /* set cursor adjustment amount  234*/
  241.   if(!iview)
  242.   dovcsr( fp, CsrAdjust );              /* then adjust it.                   */
  243.   else {
  244. #ifdef MSH
  245.       Window[SOURCE_WIN]->user_data=(void *) fp;
  246.       DoVcsr( Window[SOURCE_WIN], CsrAdjust );          /* then adjust it.                   */
  247. #endif
  248.   }
  249.  
  250.   fp->csrline = fp->hotline;            /*                                234*/
  251.   if(!iview) fmtscr( fp );               /* show the screen for this afile    */
  252.  }
  253.  fmterr( msg );                         /* display the error message         */
  254.  
  255.  if( !IsOnCRT(fp) )                     /* is the cursor on the screen?      */
  256.      fp->csrline = fp->topline;         /* no. put it on the top line        */
  257.  
  258. /*
  259. Keyboard processing loop
  260. */
  261.  for( ;; )
  262.  {                                      /* begin k/b processing loop         */
  263.   fmtpos( fp );                         /* put "line xx of yy" message out   */
  264.   SrcCol = fp->skipcols + fp->csr.col;  /* set  column position              */
  265.   SrcLine = fp->csrline + fp->Nbias;    /* removed a +1.                  234*/
  266.   lp = fp->source +                     /* ->to top of source buffer +       */
  267.        fp->offtab[ fp->csrline ];       /* offset of cursorline              */
  268.   fp->csr.row = ( uchar )( fp->csrline- /* set cursor line in source buffer  */
  269.                   fp->topline +         /* - source line at top of display   */
  270.                   TopLine );            /* + topline for the code            */
  271.   PutCsr( ( CSR * )&fp->csr );          /* set the cursor position           */
  272.  
  273.   if (str_fnd_flag == 1)                /* if string found highlight the  110*/
  274.   {                                     /*  string on the screen at the   110*/
  275.       hlight[0] = 0xFF;                 /* attribute string for highlight 110*/
  276.       hlight[1] = (uchar)slen;          /* attribute string for highlight 110*/
  277.       hlight[2] = Attrib(vaXline);      /* attribute string for highlight 110*/
  278.       hlight[3] = 0;                    /* attribute string for highlight 110*/
  279.       putrc(fp->csr.row,fp->csr.col,    /*  fp->csr.col .                 110*/
  280.       &hlight[0]);                      /*                                110*/
  281.       str_fnd_flag = 0;                 /*                                110*/
  282.   }
  283.  
  284.  
  285.   /***************************************************************************/
  286.   /* Set the masked items for the source view.                            701*/
  287.   /***************************************************************************/
  288.   SetMenuMask( SOURCEVIEW );
  289.   if( (fp == GetExecfp()) || (GetExecfp() == NULL) )
  290.    DisableDropFile();
  291.   else
  292.    EnableDropFile();
  293.  
  294.   /***************************************************************************/
  295.   /* Get an event from the kbd/mouse.                                     701*/
  296.   /***************************************************************************/
  297.  
  298.  
  299.   if( (SerialParallel() == SERIAL) && (QueryConnectSema4() == SEMA4_RESET) )
  300.   {
  301.    fmterr("Disconnected...double click on window to reconnect.");
  302.    _beginthread(WaitForInterrupt, NULL, 0x8000, NULL );
  303. block:
  304.    SerialConnect( JUST_WAIT, DbgGetProcessID(), _DBG, SendMsgToDbgQue );
  305.    fmterr("Reconnected.");
  306.    DosSelectSession(0);
  307.   }
  308. #if 0
  309.   if(iview) {
  310.       func=BROWSEMSH;
  311.   }
  312.   else
  313. #endif
  314.   {
  315.      func = (BlowBy)?TOGGLESTORAGE:GetFuncsFromEvents(0 , (void *)fp );                           /*701*/
  316.   }
  317.  
  318.   if( (SerialParallel() == SERIAL) && (QueryConnectSema4() == SEMA4_RESET) )
  319.   {
  320.    ConnectThisPid( INFORM_ESP );
  321.    goto block;
  322.   }
  323.   /***************************************************************************/
  324.   /* GetFuncsFromEvents will not always be able to return an executable   701*/
  325.   /* function code, so we get back a raw LEFTMOUSECLICK or RIGHTMOUSECLICK701*/
  326.   /* So, what we do is:                                                   701*/
  327.   /*                                                                      701*/
  328.   /*  -LEFTMOUSECLICK                                                     701*/
  329.   /*    - if the click is in the source window, then set the cursor       701*/
  330.   /*      position.                                                       701*/
  331.   /*    - if the click is in the data window, then switch to the data     701*/
  332.   /*      window.                                                         701*/
  333.   /*                                                                      701*/
  334.   /*  -RIGHTMOUSECLICK                                                    701*/
  335.   /*    - bring up the object pulldown for the source window.             701*/
  336.   /*                                                                      701*/
  337.   /***************************************************************************/
  338.   if( func == LEFTMOUSECLICK )                                          /*701*/
  339.   {                                                                     /*701*/
  340.     if( GetEventView() == DATAVIEW )                                    /*701*/
  341.     {                                                                   /*701*/
  342.      SetDataViewCsr();                                                  /*701*/
  343.      func = TOGGLESTORAGE;                                              /*701*/
  344.     }                                                                   /*701*/
  345.     else                                                                /*701*/
  346.      func = SETCURSORPOS;                                               /*701*/
  347.   }                                                                     /*701*/
  348.   else                                                                  /*701*/
  349.   if( func == RIGHTMOUSECLICK )                                         /*701*/
  350.   {                                                                     /*701*/
  351.     MouseState = STATE_BUTTON_PRESSED;                                  /*701*/
  352.     func = GetObjectPullChoice( 11, &MouseState );                      /*701*/
  353.   }                                                                     /*701*/
  354.                                                                         /*701*/
  355. ReCirculate:                                                            /*701*/
  356.   /***************************************************************************/
  357.   /* Process the function.                                                701*/
  358.   /***************************************************************************/
  359.   switch( func )                                                        /*701*/
  360.                                                                         /*701*/
  361.   {                                                                     /*701*/
  362.                                                                         /*701*/
  363.    case GETFUNCTION:                                                    /*701*/
  364.    case GETFILE:                                                        /*701*/
  365.    case GETADDRESS:                                                     /*701*/
  366.     if( func == GETFUNCTION || func == GETADDRESS )                     /*701*/
  367.     {                                                                   /*701*/
  368.      /********************************************************************701*/
  369.      /* If the function is GetFunction, then implement cursor sensitive   701*/
  370.      /* prompting and initialize a token. If it's GETADDRESS, then        701*/
  371.      /* help the use out by throwing in a 0x for him.                     701*/
  372.      /********************************************************************701*/
  373.      InitString[0] = '\0';                                              /*701*/
  374.      if( func == GETADDRESS )                                           /*701*/
  375.       strcpy( InitString,"0x");                                         /*701*/
  376.      else                                                               /*701*/
  377.       token( lp, SrcCol,InitString);                                    /*701*/
  378.      fp_focus = GetFunction( InitString, func );                        /*701*/
  379.     }                                                                   /*701*/
  380.     else                                                                /*701*/
  381.      fp_focus = GetF( );                                                /*701*/
  382.                                                                         /*701*/
  383.     if( fp_focus )                                                      /*701*/
  384.     {                                                                   /*701*/
  385.      if( fp_focus->shower == showA && fp_focus->flags == 0 )            /*701*/
  386.      {                                                                  /*701*/
  387.       fp_focus->flags = ASM_VIEW_CHANGE;                                /*701*/
  388.       fp_focus->csr.row = fp_focus->csrline - 1;                        /*701*/
  389.       if(fp_focus->sview == NOSRC )                                     /*701*/
  390.        fp_focus->csr.row = 0;                                           /*701*/
  391.      }                                                                  /*701*/
  392.      return(-1);                                                        /*701*/
  393.     }                                                                   /*701*/
  394.     fmttxt( fp );                                                       /*701*/
  395.     fmterr( msg );                                                      /*701*/
  396.     break;                                                              /*701*/
  397.                                                                         /*701*/
  398.    case ESCAPE:                                                         /*701*/
  399.     fmttxt( fp );                                                       /*701*/
  400.     fmterr( msg );                                                      /*701*/
  401.     break;                                                              /*701*/
  402.                                                                         /*701*/
  403.     /*************************************************************************/
  404.     /* Edit the 30386 registers.                                             */
  405.     /* If the coprocessor register window is already on                      */
  406.     /*  - reset the screen bounds                                            */
  407.     /*  - reset the REGS387BIT bit.                                          */
  408.     /*  - refresh the data window.                                           */
  409.     /* If Register window is not present bring it up.                        */
  410.     /* Process the editing of registers.                                     */
  411.     /* If the register window was not up when we came here turn it off.      */
  412.     /* Format the screen                                                     */
  413.     /*************************************************************************/
  414.     case EDITREGISTERS:
  415.       if (TestBit(Reg_Display,REGS387BIT))
  416.       {
  417.         GetScrAccess();
  418.         ResetBit(Reg_Display,REGS387BIT);
  419.         ShowData(TopLine);
  420.       }
  421.       if (!TestBit(Reg_Display,REGS386BIT))
  422.       {
  423.         SetBit(Reg_Display,REPAINT);
  424.         ShowvRegs();
  425.       }
  426.       Newfp = KeyvRegs(&key);
  427.       if (!TestBit(Reg_Display,REGS386BIT))
  428.       {
  429.         memset(BoundPtr+VioStartOffSet,VideoCols,VideoRows-VioStartOffSet);
  430.         ShowData(TopLine);
  431.         fmttxt( fp );
  432.       }
  433. #if 0
  434.       RemoveCollisionArea();                                            /*701*/
  435. #endif
  436.       if (Newfp)
  437.       {
  438.         fp_focus = Newfp;
  439.         return(-1);
  440.       }
  441.       break;
  442.  
  443.    case FIND:                                                           /*701*/
  444.     FindStr(fp);                                                        /*701*/
  445.     fmtscr(fp);                                                         /*701*/
  446.     break;                                                              /*701*/
  447.                                                                         /*701*/
  448.    case REPEATFIND:                                                     /*701*/
  449.     rc = ScanStr(fp);                                                   /*701*/
  450.     fmtscr(fp);                                                         /*701*/
  451.     if( rc == 0 )                                                       /*701*/
  452.      fmterr( "Can't find that" );                                       /*701*/
  453.     break;                                                              /*701*/
  454.                                                                         /*701*/
  455.    case BROWSE:                                                         /*701*/
  456.     BrowseFile();                                                       /*701*/
  457.     fmtscr(fp);                                                         /*701*/
  458.     break;                                                              /*701*/
  459.  
  460. #ifdef MSH
  461.    case BROWSEMSH:
  462.     {
  463.     WINDOWEVENT *we;
  464.     iview=1;
  465.     we=BrowseMshFile(fp);
  466.     iview=0;
  467.     if(we->func) {
  468.         iview=we->iview;
  469.         func=we->func;
  470.         SrcCol = fp->skipcols + fp->csr.col;  /* set  column position              */
  471.         SrcLine = fp->csrline + fp->Nbias;    /* removed a +1.                  234*/
  472.         lp = fp->source +                     /* ->to top of source buffer +       */
  473.              fp->offtab[ fp->csrline ];       /* offset of cursorline              */
  474.         goto ReCirculate;
  475.     }
  476.     fmtscr(fp);                                                         /*701*/
  477.     }
  478.     break;                                                              /*701*/
  479. #endif
  480.                                                                         /*701*/
  481.    case SETCLEARCONDBKPT:                                               /*701*/
  482.     if( !(*(lp-1) & LINE_OK) )                                          /*701*/
  483.     {                                                                   /*701*/
  484.      beep();                                                            /*701*/
  485.      fmterr( "Can't stop at this line" );                               /*701*/
  486.      break;                                                             /*701*/
  487.     }                                                                   /*701*/
  488.     SetCondBrk( fp, SrcLine, lp );                                      /*701*/
  489.     fmtscr( fp );                                                       /*701*/
  490.     fmterr( "" );                                                       /*701*/
  491.     break;                                                              /*701*/
  492.                                                                         /*701*/
  493.    case SAVEBKPTS:
  494.     SaveBreakpoints();
  495.     fmtscr(fp);
  496.     break;
  497.  
  498.    case RESTOREBKPTS:
  499.    {
  500.     int mid;
  501.  
  502.     mid=fp->mid;
  503.     ResetBreakpointFileTime();
  504.     RestoreBreakpoints();
  505.     fp=mid2fp(mid); /*fp may be replaced by RestoreBreakpoints, if the */
  506.                     /*user designated source file disagrees with the */
  507.                     /*file already loaded.*/
  508.    }
  509.    MarkLineBRKs( fp );
  510.    fmtscr(fp);
  511.    break;
  512.  
  513.    case EDITBKPTS:
  514.        EditBreakpoints();
  515.        break;
  516.  
  517.    case DROPFILE:                                                       /*701*/
  518.     {                                                                   /*701*/
  519.      AFILE *fpnext;                                                     /*701*/
  520.                                                                         /*701*/
  521.      fpnext = fp->next;                                                 /*701*/
  522.      if ( fpnext == NULL )                                              /*701*/
  523.      fpnext = allfps;                                                   /*701*/
  524.      freefp( fp );                                                      /*701*/
  525.      fp = fpnext;                                                       /*701*/
  526.      if( fp->shower == showA && fp->flags == 0 )                        /*701*/
  527.      {                                                                  /*701*/
  528.       fp->flags = ASM_VIEW_CHANGE;                                      /*701*/
  529.       fp->csr.row = fp->csrline - 1;                                    /*701*/
  530.       if(fp->sview == NOSRC )                                           /*701*/
  531.        fp->csr.row = 0;                                                 /*701*/
  532.      }                                                                  /*701*/
  533.      fp_focus = fp;                                                     /*701*/
  534.      return(-1);                                                        /*701*/
  535.     }                                                                   /*701*/
  536.                                                                         /*701*/
  537.    case RESTART:                                                        /*701*/
  538.     iview=0;
  539.     Restart();                                                          /*701*/
  540.     break;                                                              /*701*/
  541.                                                                         /*701*/
  542.    case QUIT:                                                           /*701*/
  543.     NormalQuit(TRUE);                                                   /*701*/
  544.     break;                                                              /*701*/
  545.                                                                         /*701*/
  546.    case SETFUNCTIONBKPT:
  547.    case SETADDRESSBKPT:
  548.    case SETDEFERREDBKPT:
  549.    case SETADDRLOADBKPT:
  550.    case SETDLLLOADBKPT:
  551.     SetNameOrAddrBkpt(fp, func);
  552.     if(!iview) fmttxt(fp);
  553.     break;
  554.  
  555.    case UPCURSOR:                       /* move cursor up one line           */
  556.     dovcsr( fp, -1 );                   /*                                   */
  557.     break;                              /*                                   */
  558.                                         /*                                   */
  559.    case DOWNCURSOR:                     /* move the cursor down one line     */
  560.     dovcsr( fp, 1 );                    /*                                   */
  561.     break;                              /*                                   */
  562.                                         /*                                   */
  563.    case RIGHTCURSOR:                    /* move the cursor right one column  */
  564.     dofwdtab( fp, lp, SrcCol );         /*                                   */
  565.     break;                              /*                                   */
  566.                                         /*                                   */
  567.    case LEFTCURSOR:                     /* move the cursor left  one column  */
  568.     dobwdtab( fp, lp, SrcCol );         /*                                   */
  569.     break;                              /*                                   */
  570.                                         /*                                   */
  571.    case TABRIGHT:                       /* forward tab                       */
  572.     dofwdtab( fp, lp, SrcCol );         /* same as RIGHT for now             */
  573.     break;                              /*                                   */
  574.                                         /*                                   */
  575.    case TABLEFT:                        /* left tab                          */
  576.     dobwdtab( fp, lp, SrcCol );         /* same as LEFT for now              */
  577.     break;                              /*                                   */
  578.                                         /*                                   */
  579.    case PREVWINDOW:                     /* show previous screen              */
  580.     dovscr( fp, -(int)LinesPer );       /*                                521*/
  581.     break;                              /*                                   */
  582.                                         /*                                   */
  583.    case NEXTWINDOW:                     /* show next screen                  */
  584.     dovscr( fp, LinesPer );             /*                                   */
  585.     break;                              /*                                   */
  586.                                         /*                                   */
  587.    case FIRSTWINDOW:                    /*                                   */
  588.     dovscr( fp, -(int)fp->Tlines );     /* display first screen       234 521*/
  589.     fp->csrline = fp->topline;          /* update afile t put cursor on top  */
  590.     break;                              /*                                   */
  591.                                         /*                                   */
  592.    case LASTWINDOW:                     /*                                   */
  593.     dovscr( fp,fp->Tlines-LinesPer+1);  /* dispay last screen             234*/
  594.     fp->csrline = fp->topline + fp->Nshown - 1;                         /*234*/
  595.     break;
  596.  
  597.    case TOPOFWINDOW:                    /* move cursor to top line on screen */
  598.     fp->csrline = fp->topline;          /* update afile t put cursor on top  */
  599.     break;
  600.  
  601.    case BOTOFWINDOW:                    /* move cursor to last line on screen*/
  602.     fp->csrline = fp->topline + fp->Nshown - 1;
  603.     break;
  604.  
  605.    case SETCURSORPOS:                                                   /*701*/
  606.     SetSrcViewCsr( fp );                                                /*701*/
  607.     break;                                                              /*701*/
  608.  
  609.    /**************************************************************************/
  610.    /* Source line step - step over calls.                                 701*/
  611.    /**************************************************************************/
  612.    case SSTEP:
  613.    case SSTEPNOSWAP:
  614.  
  615.     if ( GetThreadState( GetExecTid() ) == TRC_C_ENDED )
  616.     {
  617.      beep();
  618.      fmterr( "No threads or thread not found. Can't step anything.");
  619.      break;
  620.     }
  621.  
  622.     if ( GetThreadState( GetExecTid() ) == TRC_C_BLOCKED )
  623.     {
  624.      beep();
  625.      fmterr( "Can't single step a blocked thread");
  626.      break;
  627.     }
  628.  
  629.     if ( GetThdDbgState( GetExecTid() ) == TS_FROZEN )
  630.     {
  631.      beep();
  632.      fmterr( "Can't single step a frozen thread");
  633.      break;
  634.     }
  635.  
  636.     if( fp == GetExecfp() )             /* is this the executing afile?      */
  637. /*   return( GOSTMTC );  */             /* go back to run()                  */
  638.      return( func );
  639.     fmt2err( "Can't continue:", msg );
  640.     beep();
  641.     break;
  642.  
  643.    /**************************************************************************/
  644.    /* Source line step - step into calls.                                 701*/
  645.    /**************************************************************************/
  646.    case SSTEPINTOFUNC:
  647.    case SSTEPINTOFUNCNOSWAP:
  648.  
  649.     if ( GetThreadState( GetExecTid() ) == TRC_C_ENDED )
  650.     {
  651.      beep();
  652.      fmterr( "No threads or thread not found. Can't step anything.");
  653.      break;
  654.     }
  655.  
  656.     if ( GetThreadState( GetExecTid() ) == TRC_C_BLOCKED )
  657.     {
  658.      beep();
  659.      fmterr( "Can't single step a blocked thread");
  660.      break;
  661.     }
  662.  
  663.     if ( GetThdDbgState( GetExecTid() ) == TS_FROZEN )
  664.     {
  665.      beep();
  666.      fmterr( "Can't single step a frozen thread");
  667.      break;
  668.     }
  669.  
  670.     if( fp == GetExecfp() )
  671. /*   return( GOSTMT );    */
  672.      return( func );
  673.     fmt2err( "Can't continue:", msg );
  674.     beep();
  675.     break;
  676.  
  677.    /**************************************************************************/
  678.    /* Run to the line the cursor is on.                                      */
  679.    /*                                                                        */
  680.    /*  - test for a break already on the line.                               */
  681.    /*  - test for an executable line.                                        */
  682.    /*  - set a one time breakpoint.                                          */
  683.    /*  - run.                                                                */
  684.    /**************************************************************************/
  685.    case RUNTOCURSOR:
  686.    case RUNTOCURSORNOSWAP:
  687.     if( (*(lp-1) & LINE_BP) )
  688.      if( GetExecfp() )
  689.        return( func );
  690.  
  691.     if( !(*(lp-1) & LINE_OK) )
  692.     {
  693.      beep();
  694.      fmterr( "Can't stop at this line" );
  695.      break;
  696.     }
  697.  
  698.     if( SetLineBRK(fp, SrcLine, lp, BRK_ONCE,NULL) ) /* single show bp   701*/
  699.     {
  700.      beep();
  701.      fmterr( "Can't set breakpoint " );
  702.      break;
  703.     }
  704.  
  705.     if( GetExecfp() )
  706.      return( func );
  707.     break;
  708.  
  709.    /**************************************************************************/
  710.    /* Let 'er rip.                                                        701*/
  711.    /**************************************************************************/
  712.    case RUNNOSWAP:
  713.    case RUN:
  714.     if( GetExecfp() )
  715.      return( func );
  716.     beep();
  717.     fmt2err( "Can't continue:", msg );
  718.     break;
  719.  
  720.    case GENHELP:                        /* General help                   701*/
  721.     {
  722.      uchar *HelpMsg;
  723.  
  724.      HelpMsg = GetHelpMsg( HELP_PULL_GENHELP, NULL,0 );
  725.      CuaShowHelpBox( HelpMsg );
  726.     }
  727.     break;
  728.  
  729.    case MSHHELP:                        /* General help                   701*/
  730.     {
  731. #if 0 /*xxxxjc*/
  732.      STARTDATA sd;
  733.      ULONG     sid;
  734.      ULONG     pid;
  735.      char      buffer[256];
  736.      char *format="%s\\help\\MSH.INF",PgmInputs[80];
  737.  
  738.      sprintf(PgmInputs,format,mshgetenv("MSHHOME"));
  739.  
  740.      memset( &sd, 0, sizeof(sd) );
  741.      sd.Length        = sizeof(sd);
  742.      sd.Related       = SSF_RELATED_INDEPENDENT;
  743.      sd.FgBg          = SSF_FGBG_BACK;
  744.      sd.TraceOpt      = SSF_TRACEOPT_NONE;
  745.      sd.InheritOpt    = SSF_INHERTOPT_PARENT;
  746.      sd.PgmName       = "VIEW.EXE";
  747.      sd.PgmInputs     = PgmInputs;
  748.      sd.SessionType   = SSF_TYPE_PM;
  749.      sd.PgmTitle      = "Msh Help";
  750.      sd.PgmControl    = SSF_CONTROL_VISIBLE;
  751.      sd.ObjectBuffer  = buffer;
  752.      sd.ObjectBuffLen = sizeof(buffer);
  753.  
  754.      DosStartSession( ( PSTARTDATA )&sd, &sid, &pid );
  755.  
  756.      fmterr("Math Shell Help");
  757. #endif/*xxxxjc*/
  758.     }
  759.     break;
  760.  
  761.    case FUNCKEYSHELP:                                                   /*808*/
  762.      HelpScreen( );
  763.      break;                             /* for now, no context sensitive help*/
  764.  
  765.    case SHOWDLLS:                       /* show names of DLLs                */
  766.      ShowDlls();                        /*                                   */
  767.      break;                             /*                                   */
  768.  
  769.    case FINDEXECLINE:                   /* help                              */
  770.     fp_focus = FindExecLine(fp, SrcLine); /* find current executing afile    */
  771.     if( GetExecfp() && fp_focus )       /* if both afiles exist then         */
  772.     {
  773.      fp_focus->flags |= AF_ZOOM;        /*                            816 235*/
  774.      return(-1);                        /* return to run()                   */
  775.     }
  776.     beep();
  777.     break;
  778.  
  779.    case SHOWTHREADS:                    /* show process threads              */
  780.     if( showthds((uint *)&key) )        /* if user selected new thread,   229*/
  781.      return( -1 );                      /* return to run()                   */
  782.     break;
  783.  
  784.    case SHOWPROCESSES:
  785.     Cua_showproc();
  786.     break;
  787.  
  788.    case TOGGLEHIDESTORAGE:              /*                                   */
  789.    case TOGGLESTORAGE:                  /* Toggle to and from storage window */
  790.    {
  791.     Newfp = NULL;
  792.     func = typoS((SIZEFUNC)ResizeWindow, fp, &Newfp);
  793.     if( Newfp )
  794.     {
  795.      fp_focus = Newfp;
  796.      return(-1);
  797.     }
  798.     if( func != 0 )                                                     /*701*/
  799.      goto ReCirculate;                                                  /*701*/
  800.     fmttxt( fp );                                                       /*701*/
  801.     break;
  802.  
  803.  
  804. #if 0
  805.     rc = typoS((SIZEFUNC)ResizeWindow,fp); /* go to storage window handlin521*/
  806.     if(rc != -1 )                       /* fall thru to toggleasm from       */
  807.     {                                   /* storage window if -1 return.      */
  808.      fmttxt( fp );                      /* come back from storage and update */
  809.      break;
  810.     }
  811. #endif
  812.    }
  813.    case TOGGLEASM:                      /* toggle between source and asm     */
  814.     SyncAddr = DBMapLno(fp->mid,        /* find synchronizing addr           */
  815.                         SrcLine,        /* in this debug file.               */
  816.                         fp->sfi,        /*                                   */
  817.                         &span ,         /*                                   */
  818.                         fp->pdf );      /*                                   */
  819.     if(SyncAddr == NULL)                /* if no addr for this line then  106*/
  820.      SyncAddr = DBMapNonExLine(fp->mid, /* try to map this line to an        */
  821.                                SrcLine, /* executable line.                  */
  822.                                fp->sfi,
  823.                                fp->pdf);/*                                   */
  824.     if( SyncAddr )                      /* is there any source available?    */
  825.      {                                  /* yes.                              */
  826.       fp->flags |= ASM_VIEW_TOGGLE;     /* tell afile that views are in sy235*/
  827.       (fp_focus = fp) -> shower = showA;/* define asm shower function        */
  828.       return(-1);                       /* return to run()                   */
  829.      }
  830.     beep();                             /* cannot display source             */
  831.     break;
  832.  
  833.    case SHOWCALLSTACK:                  /* show call stack                   */
  834.     switch( ActiveProcsMenu(&fp_focus) )/* show active procedures menu and   */
  835.     {                                   /* return further instructions       */
  836.      case A_ENTER:                      /* break on rtn to selected func     */
  837.      case C_ENTER:                      /*                                   */
  838.      if( GetExecfp() )                  /* is there an executing afile       */
  839.        return( RUN );                   /* return to run() and run to func701*/
  840.      fmt2err( "Can't continue:", msg ); /* no afile so can't execute         */
  841.      beep();                            /* complain a little                 */
  842.      break;                             /* break out sister                  */
  843.  
  844.      case ENTER:                        /* show the context of the call      */
  845.       return(-1);
  846.     }
  847.     break;                              /* we just wanted to see the stack   */
  848.  
  849.    case FINDFUNCTION:                   /* find the module defining the      */
  850.                                         /* procedure indicated by cursor.    */
  851.     fp_focus = locatefp(lp, SrcCol );                                   /*521*/
  852.     if( fp_focus )                                                      /*521*/
  853.     {                                                                   /*235*/
  854.      if( fp_focus->shower == showA )                                    /*235*/
  855.      {                                                                  /*235*/
  856.       fp_focus->flags = ASM_VIEW_CHANGE;                                /*235*/
  857.       fp_focus->csr.row = fp_focus->csrline - 1;                        /*235*/
  858.       if(fp_focus->sview == NOSRC )                                     /*235*/
  859.        fp_focus->csr.row = 0;                                           /*235*/
  860.      }                                                                  /*235*/
  861.      return(-1);                                                        /*235*/
  862.     }                                                                   /*235*/
  863.     beep();
  864.     break;
  865.  
  866.    case NEXTFILE:                       /* switch to th next file in ring    */
  867.     if( !(fp_focus = fp->next) )        /* is there a next one in the ring?  */
  868.      if( (fp_focus = allfps) == fp )    /* is there only one file?           */
  869.      {
  870.       beep();                           /* yes only one file                 */
  871.       break;
  872.      }
  873.     if(fp_focus->shower == showA )                                      /*235*/
  874.      fp_focus->flags = ASM_VIEW_NEXT;                                   /*235*/
  875.     return(-1);                         /* return to run with recalled afile */
  876.  
  877.     /*************************************************************************/
  878.     /* If Displaying the register window                                  400*/
  879.     /*  - Set the REPAINT bit.                                            400*/
  880.     /* Toggle the REGS386BIT bit.                                         400*/
  881.     /* If the coprocessor register window is already on                   400*/
  882.     /*  - reset the screen bounds                                         400*/
  883.     /*  - refresh the data window.                                        400*/
  884.     /*  - reset the REGS387BIT bit.                                       400*/
  885.     /* If the user is turning off the register display                    400*/
  886.     /*  - reset the screen bounds                                         400*/
  887.     /*  - refresh the data window.                                        400*/
  888.     /* Format the screen                                                  400*/
  889.     /*************************************************************************/
  890.     case REGISTERDISPLAY:                                               /*400*/
  891.      if (!TestBit(Reg_Display,REGS386BIT))                              /*400*/
  892.         SetBit(Reg_Display,REPAINT);                                    /*400*/
  893.      if (TestBit(Reg_Display,REGS387BIT) && !iview)                     /*401*/
  894.      {                                                                  /*401*/
  895.         memset(BoundPtr,VideoCols,VideoRows);                           /*518*/
  896.         ResetBit(Reg_Display,REGS387BIT);                               /*401*/
  897.         ShowData(TopLine);                                              /*400*/
  898.      }                                                                  /*401*/
  899.      Reg_Display ^= 0x2;                                                /*400*/
  900.      if (!TestBit(Reg_Display,REGS386BIT))                              /*400*/
  901.      {                                                                  /*400*/
  902.         memset(BoundPtr,VideoCols,VideoRows);                           /*518*/
  903.         ShowData(TopLine);                                              /*400*/
  904. #if 0
  905.         RemoveCollisionArea();                                          /*701*/
  906. #endif
  907.      }                                                                  /*400*/
  908.      if(!iview)fmttxt( fp );
  909.      break;                                                             /*400*/
  910.  
  911.  
  912.     /*************************************************************************/
  913.     /* If Displaying the co processor registers                           401*/
  914.     /*  - Set the REPAINT bit.                                            401*/
  915.     /* Toggle the REGS387BIT bit.                                         401*/
  916.     /* If the register window is already on                               401*/
  917.     /*  - reset the screen bounds                                         401*/
  918.     /*  - reset the REGS386BIT bit.                                       401*/
  919.     /* If the user is turning off the coproessor register display         401*/
  920.     /*  - reset the screen bounds                                         401*/
  921.     /*  - refresh the data window.                                        401*/
  922.     /* Format the screen                                                  401*/
  923.     /*************************************************************************/
  924.     case COREGISTERDISPLAY:                                             /*401*/
  925.      if (!TestBit(Reg_Display,REGS387BIT))                              /*401*/
  926.         SetBit(Reg_Display,REPAINT);                                    /*401*/
  927.      if (TestBit(Reg_Display,REGS386BIT) && !iview)                     /*401*/
  928.      {                                                                  /*401*/
  929.         ResetBit(Reg_Display,REGS386BIT);                               /*401*/
  930.         memset(BoundPtr,VideoCols,VideoRows);                           /*518*/
  931.      }                                                                  /*401*/
  932.      Reg_Display ^= 0x4;                                                /*401*/
  933.      if (!TestBit(Reg_Display,REGS387BIT))                              /*401*/
  934.      {                                                                  /*401*/
  935.         memset(BoundPtr,VideoCols,VideoRows);                           /*518*/
  936.         ShowData(TopLine);                                              /*401*/
  937. #if 0
  938.         RemoveCollisionArea();                                          /*701*/
  939. #endif
  940.      }                                                                  /*401*/
  941.      if(!iview) fmttxt( fp );
  942.      break;                                                             /*401*/
  943.  
  944.     /*************************************************************************/
  945.     /* Set Execution Line Function.                                       508*/
  946.     /*                                                                    508*/
  947.     /*  - Check if the Line is executable, if not put error message.      508*/
  948.     /*  - map the line number to address, if not able to map put error    508*/
  949.     /*    message.                                                        508*/
  950.     /*  - If able to map the line number to an address, call function to  508*/
  951.     /*    change the CS:IP and then reformat the text.                    508*/
  952.     /*                                                                    508*/
  953.     /*************************************************************************/
  954.     case SETEXECLINE:                                                   /*508*/
  955.     {                                                                   /*508*/
  956.        uint  addr;                                                      /*508*/
  957.        uint  Tempspan;                                                  /*521*/
  958.                                                                         /*508*/
  959.        if( *(lp-1) & LINE_OK )                                          /*508*/
  960.        {                                                                /*508*/
  961.           addr = DBMapLno(fp->mid, SrcLine, fp->sfi, &Tempspan, fp->pdf);
  962.           if( addr )                                                    /*508*/
  963.           {                                                             /*508*/
  964.             if( SetExecLine(addr) == TRUE )                             /*508*/
  965.             {                                                           /*508*/
  966.                fmttxt( fp );                                            /*508*/
  967.                break;                                                   /*508*/
  968.             }                                                           /*508*/
  969.           }                                                             /*508*/
  970.        }                                                                /*508*/
  971.        beep();                                                          /*508*/
  972.        fmterr( "Can't set ip at this line" );                           /*508*/
  973.     }                                                                   /*508*/
  974.     break;                                                              /*508*/
  975.  
  976.    case TIMEDSHOWAPPWINDOW:
  977.     if( IsEspRemote() )
  978.      xSelectSession();
  979.     else
  980.      DosSelectSession(DbgGetSessionID());
  981.     DosSleep(5000L);
  982.     DosSelectSession( 0 );
  983.     break;
  984.  
  985.    case SETCLEARBKPT:                   /* set/reset breakpoint              */
  986.     if( !(*(lp-1) & LINE_OK) )          /* breakable line?                   */
  987.     {                                   /*                                   */
  988.      beep();                            /*                                   */
  989.      fmterr( "Can't stop at this line" );/* no. tell 'em so                  */
  990.      break;
  991.     }
  992.     (void)SetLineBRK(fp,SrcLine,lp,BRK_SIMP,NULL);                      /*701*/
  993.     fmttxt( fp );                       /* update the display to show bp.    */
  994.     break;
  995.  
  996.    case SHRINKSTORAGE:                  /* shrink the storage display area   */
  997.    case EXPANDSTORAGE:                  /* Expand the storage display area   */
  998.     if( HideDataWin == TRUE  )          /* if data window is hidden,         */
  999.     {                                   /* turn it on.                       */
  1000.      ResizeWindow(fp,-(int)SaveTopLine);/* resize the src/asm window.     521*/
  1001.      HideDataWin = FALSE;               /* TopLine gets reestablished in     */
  1002.      break;                             /*                                   */
  1003.     }                                   /* the recalibrate....puke!          */
  1004.    switch( func )
  1005.    {
  1006.     case SHRINKSTORAGE:                 /* shrink the storage display area   */
  1007.      if( ShrinkStorage(fp,1) )
  1008.       beep();                           /* beep if not shrinkable            */
  1009.      break;
  1010.  
  1011.     case EXPANDSTORAGE:                 /* Expand the storage display area   */
  1012.      if( ExpandStorage(fp,1) )
  1013.       beep();                           /* beep if not expandable            */
  1014.      break;
  1015.    }
  1016.    break;
  1017.  
  1018.    case SHOWVAR:                        /* show the contents of a variable   */
  1019.    case SHOWVARPTSTO:                   /* show contents var points to       */
  1020.    case PUTVARINSTG:                    /* put a variable in the storage win */
  1021.    case PUTVARPTSTOINSTG:               /* put what variable points to in stg*/
  1022.    case EXPANDVAR:                      /* expand variable                   */
  1023.    case MSHGET:                         /* mshget variable                   */
  1024.    case MSHPUT:                         /* mshget variable                   */
  1025.     {                                   /*                                   */
  1026.      DFILE  *dfp;                       /* dfile node pointer.               */
  1027.      if( HideDataWin == TRUE  )         /* if data window is hidden,         */
  1028.      {                                  /* turn it on.                       */
  1029.       ResizeWindow(fp,-(int)SaveTopLine);/* resize the src/asm window.    521*/
  1030.       HideDataWin = FALSE;              /* TopLine gets reestablished in     */
  1031.      }                                  /* the recalibrate....puke!          */
  1032.      Newfp = NULL;
  1033.      dfp = dumpvar(fp,                  /* afile pointer                     */
  1034.                    lp,                  /* pointer to source line            */
  1035.                    SrcLine,             /* source line number                */
  1036.                    SrcCol,              /* source column number              */
  1037.                    func,                /* which show function               */
  1038.                    &Newfp
  1039.                   );
  1040.      if( Newfp )
  1041.      {
  1042.       fp_focus = Newfp;
  1043.       return(-1);
  1044.      }
  1045.      if ( dfp )                         /* if true returned from dumpvar()   */
  1046.      {
  1047.       if( func==PUTVARINSTG ||          /* data window.                      */
  1048.           func==PUTVARPTSTOINSTG        /*                                   */
  1049.         )                               /*                                   */
  1050.       {                                 /*                                   */
  1051.        int adjust;                      /* amount to adjust the source window*/
  1052.        uint recspan;                    /* span of records.(0...N)           */
  1053.        uint winsize;                    /* size of the window(1..N).         */
  1054. /*****************************************************************************/
  1055. /* At this point, if the node is too big to fit in a full data window, then  */
  1056. /* show the top MaxData lines of the node.                                   */
  1057. /*                                                                           */
  1058. /*****************************************************************************/
  1059.        if( dfp->lines > MaxData )       /* if this is a big node, then       */
  1060.        {                                /*                                   */
  1061.         DataFileTop = dfp->lrn;         /* display first MaxData lines of it.*/
  1062.         DataFileBot = DataFileTop +     /*                                   */
  1063.                       MaxData - 1;      /*                                   */
  1064.         ResizeWindow( fp, -(int)MaxData);/* resize the window.            521*/
  1065.         break;                          /* done.                             */
  1066.        }                                /*                                   */
  1067. /*****************************************************************************/
  1068. /* At this point, we know that the node will fit in the window. We want to   */
  1069. /* put it in the current window without expanding if possible.               */
  1070. /*                                                                           */
  1071. /*****************************************************************************/
  1072.        winsize = TopLine-VioStartOffSet;/* current size of the window.    701*/
  1073.        DataFileBot = dfp->lrn +         /* next bottom of  recs in window.   */
  1074.                      dfp->lines -1;     /*                                   */
  1075.        recspan=DataFileBot-DataFileTop; /* compute span of recs in window.   */
  1076.                                         /* Note: respan = 0...N              */
  1077.        if(recspan < winsize)            /* if the lines will fit w/o         */
  1078.        {                                /* expanding the window, then do it. */
  1079.         ShowData(winsize);              /* refresh the window.               */
  1080.         break;                          /* done.                             */
  1081.        }                                /*                                   */
  1082. /*****************************************************************************/
  1083. /* At this point, we know that the node will NOT fit in the current window.  */
  1084. /* We will try to expand the window so that the node will fit.               */
  1085. /*                                                                           */
  1086. /*****************************************************************************/
  1087.        if(recspan < MaxData )           /* if the window can be expanded to  */
  1088.        {                                /* hold the data, then do it.        */
  1089.         adjust = recspan - TopLine + 1;
  1090.         ResizeWindow( fp , -adjust);    /* resize the window.                */
  1091.         break;                          /* done.                             */
  1092.        }                                /*                                   */
  1093. /*****************************************************************************/
  1094. /* At this point, we know that the node will NOT fit in the current window   */
  1095. /* and the window cannot be expanded to fit. We have to scroll.              */
  1096. /*                                                                           */
  1097. /*****************************************************************************/
  1098.        DataFileTop=DataFileBot-MaxData+1;/* adjust top rec to be top rec in  */
  1099.        adjust=MaxData-TopLine;          /* win. compute win expansion        */
  1100.        ResizeWindow( fp , -adjust);     /* adjustment and then               */
  1101.                                         /* resize the window.                */
  1102.       }                                 /* end of PUTVARINSTG || PUTVARPTS...*/
  1103.      }                                  /* end if(dfp) block.                */
  1104.      break;                             /* done with these cases.            */
  1105.     }                                   /* end of {} for these cases.        */
  1106.                                         /*                                   */
  1107.    case CLEARALLBKPTS:                  /* Clear all program breaks.         */
  1108.     FreeAllBrks();                      /*                                   */
  1109.     dovscr(fp,0);                       /* refresh the screen.               */
  1110.     break;                              /*                                   */
  1111. /*****************************************************************************/
  1112. /* Hide the data window, but save the state for later return.                */
  1113. /*                                                                           */
  1114. /*****************************************************************************/
  1115.    case SHOWHIDESTORAGE:                /*                                   */
  1116.     if( HideDataWin == TRUE  )          /* if data window is hidden,         */
  1117.     {                                   /* turn it on.                       */
  1118.      ResizeWindow(fp,-(int)SaveTopLine);/* resize the src/asm window.     521*/
  1119.      HideDataWin = FALSE;               /* TopLine gets reestablished in     */
  1120.     }                                   /* the recalibrate....puke!          */
  1121.     else                                /* else if the window is not         */
  1122.     {                                   /* hidden, then turn it off.         */
  1123.      SaveTopLine = TopLine - VioStartOffSet;/* hold top line for restore. 701*/
  1124.      ResizeWindow(fp,TopLine-VioStartOffSet);/* resize and refresh the win701*/
  1125.                                         /* will set TopLine = 0              */
  1126.      HideDataWin = TRUE;                /* set hidden mode flag.             */
  1127.     }                                   /*                                   */
  1128.     break;                              /*                                   */
  1129.  
  1130.    /**************************************************************************/
  1131.    /* Set user colors.                                                       */
  1132.    /**************************************************************************/
  1133.    case SETCOLORS:                      /* set user colors.                  */
  1134.    {                                    /*                                   */
  1135.     SetColors();                        /*                                   */
  1136.     DisplayMenu();                      /* Redisplay the menu bar.           */
  1137.     if((TestBit(Reg_Display,REGS386BIT))/* If either 386 registers or 387 400*/
  1138.     ||(TestBit(Reg_Display,REGS387BIT)))/* registers window is on         401*/
  1139.         SetBit(Reg_Display,REPAINT);    /* set the reg win paint bit.     400*/
  1140.     fmtscr( fp );                       /* reset the colors for this AFILE   */
  1141.     break;                              /*                                   */
  1142.    }                                    /*                                   */
  1143.  
  1144.    /**************************************************************************/
  1145.    /* Set user exceptions notifications                                   308*/
  1146.    /**************************************************************************/
  1147.    case SETEXCEPTIONS:
  1148.      SetExceptions();
  1149.      break;
  1150.  
  1151.    /**************************************************************************/
  1152.    /* Set watch points                                                    602*/
  1153.    /**************************************************************************/
  1154.    case SETWATCHPOINTS:
  1155.      SetWps(fp);
  1156.      break;
  1157.  
  1158.    case  key_0:                      /* 0  0x0b30                         */
  1159.    case  key_1:                      /* 1  0x0231                         */
  1160.    case  key_2:                      /* 2  0x0332                         */
  1161.    case  key_3:                      /* 3  0x0433                         */
  1162.    case  key_4:                      /* 4  0x0534                         */
  1163.    case  key_5:                      /* 5  0x0635                         */
  1164.    case  key_6:                      /* 6  0x0736                         */
  1165.    case  key_7:                      /* 7  0x0837                         */
  1166.    case  key_8:                      /* 8  0x0938                         */
  1167.    case  key_9:                      /* 9  0x0a39                         */
  1168.    {
  1169.     typedef struct
  1170.     {
  1171.      char  key;
  1172.      UINT  code;
  1173.     }KEYTOCHAR;
  1174.     static KEYTOCHAR KeyToChar[]  = {'0',0x0b30,
  1175.                                      '1',0x0231,
  1176.                                      '2',0x0332,
  1177.                                      '3',0x0433,
  1178.                                      '4',0x0534,
  1179.                                      '5',0x0635,
  1180.                                      '6',0x0736,
  1181.                                      '7',0x0837,
  1182.                                      '8',0x0938,
  1183.                                      '9',0x0a39
  1184.                                     };
  1185.     for(n=0;n < 10 && (func != KeyToChar[n].code);n++){;}
  1186.     if( n < 10 )
  1187.     {
  1188.      fp->topline = GetLineNumber(KeyToChar[n].key);
  1189.      fp->csrline = fp->topline;
  1190.      dovscr(fp,0);
  1191.      break;
  1192.     }
  1193.    }
  1194.    beep();
  1195.    break;
  1196.  
  1197.    /**************************************************************************/
  1198.    /* Turn on/off the display of member functions.                           */
  1199.    /**************************************************************************/
  1200.    case TOGGLEMEMFNCS:
  1201.      SetViewMemFncs();
  1202.      break;
  1203.  
  1204. #ifdef MSH
  1205.    case MSHCOMMAND:                                                     /*701*/
  1206.     { static int MSHCommandCount=0;
  1207.       char msg[80];
  1208.       MSHOBJECT  *mshObject=*(((MSHOBJECT **)&mshinfo->mshfunction)+1);
  1209.       /*mshObject should be in the shared memory space.*/
  1210.       if(!strcmp(commandLine.parms[0],"MSHget")){
  1211.           MshParseExpr(
  1212.               commandLine.parms[1],
  1213.               commandLine.parms[2],
  1214.               0, 0, 0, mshObject);
  1215.       }
  1216.       else if(!strcmp(commandLine.parms[0],"MSHput")){
  1217.           extern int DataRecalc;                                         /*903*/
  1218.           extern uchar       Re_Parse_Data;
  1219.           MshParseExpr(
  1220.               commandLine.parms[1],
  1221.               commandLine.parms[2],
  1222.               0, 0, 0, mshObject);
  1223.  
  1224.           DataRecalc = TRUE;                                             /*903*/
  1225.           Re_Parse_Data = TRUE;
  1226.           ShowData(TopLine);
  1227.       }
  1228.       /*mshObject should be in the shared memory space.*/
  1229.       else {
  1230.           sprintf(msg,"O.K. MSH command (%s) semaphore processing %4.4d. ",
  1231.               commandLine.parms[0],
  1232.               ++MSHCommandCount);
  1233.       }
  1234.       fmterr( msg );
  1235.     }
  1236.     break;                                                              /*701*/
  1237. #endif
  1238.  
  1239.    default:
  1240.     beep();
  1241.     break;
  1242.   }                                     /* end of switch on functions        */
  1243.  }                                      /* end of keyboard processing loop   */
  1244. }                                       /* end of function showC             */
  1245.  
  1246. /***************************************************************************/
  1247. /*dovcsr                                                                   */
  1248. /* move the cursor down n lines                                            */
  1249. /*                                                                         */
  1250. /***************************************************************************/
  1251.  void
  1252. dovcsr(AFILE *fp,int n )                /* pointer to the afile block        */
  1253.                                         /* number of lines to move the cursor*/
  1254. {
  1255.  fp->csrline += n;                      /* update afile with current csr line*/
  1256.  if( !IsOnCRT(fp) )                     /* if the cursor goes off the screen */
  1257.  {
  1258.   fp->csrline -= n;                     /* reset afile value before update   */
  1259.   dovscr( fp, n );                      /* move the screen down n lines      */
  1260.  }
  1261. }
  1262.  
  1263. /***************************************************************************/
  1264. /*dohcsr                                                                   */
  1265. /* move the cursor over n columns                                          */
  1266. /*                                                                         */
  1267. /***************************************************************************/
  1268.  void
  1269. dohcsr(AFILE *fp, int n)
  1270. {
  1271.     if( (fp->csr.col += (uchar)n) >= ( uchar )VideoCols ){
  1272.         if( n > 0 ){
  1273.             n = (int)(fp->csr.col - (uchar)VideoCols + 1);
  1274.             fp->csr.col = ( uchar )(VideoCols - 1);
  1275.         }else{
  1276.         /* Convert csr.col from an 8-bit unsigned int to a 16-bit signed int */
  1277.             n = (int)(signed char)( fp->csr.col );                      /*603*/
  1278.             /*****************************************************************/
  1279.             /* changed cast from char to signed char                      603*/
  1280.             /*****************************************************************/
  1281.             fp->csr.col = 0;
  1282.         }
  1283.         dohscr( fp, n ); }
  1284. }
  1285.  
  1286. /***************************************************************************/
  1287. /*dohscr                                                                   */
  1288. /* move the screen horizontally n columns.                                 */
  1289. /*                                                                         */
  1290. /***************************************************************************/
  1291.  void
  1292. dohscr(AFILE *fp, int n)
  1293. {
  1294.     if( (int)(fp->skipcols += n) < 0 )
  1295.         fp->skipcols = 0;
  1296.     else if( fp->skipcols + VideoCols > 255 )
  1297.         fp->skipcols = 255 - VideoCols;
  1298.  
  1299.     fmttxt( fp );
  1300. }
  1301.  
  1302. /***************************************************************************/
  1303. /*dovscr                                                                   */
  1304. /* move the screen vertically n lines. n=large number moves a full screen. */
  1305. /*                                                                         */
  1306. /***************************************************************************/
  1307.  void
  1308. dovscr(AFILE *fp, int n)                /* pointer to afile                  */
  1309.                                         /* number of lines to move screen    */
  1310. {
  1311.  int newtop;                            /* new top of the screen             */
  1312.  int csrdelta;                          /* cursor offset from topline        */
  1313.  int target;                            /* potential top line in file        */
  1314.  int bias;                              /* file lines before start of src buf*/
  1315.  
  1316.  if(fp->Tlines==0) return;
  1317.  newtop = fp->topline + n;              /* define the new top line           */
  1318.  csrdelta = fp->csrline - fp->topline;  /* define lines between csr and top  */
  1319.  
  1320.  Recheck:
  1321.  
  1322.  bias = fp->Nbias;
  1323. /*
  1324.  
  1325.   At this point we first check to see if we're going beyond the lower
  1326.   line boundary of the source buffer.  If we are then there could still
  1327.   be source left in the file above the lines contained in the source
  1328.   buffer.  This is the case of a HUGE file meaning that the 64k source
  1329.   buffer could not hold all of the source lines and we need to back up
  1330.   in the file.
  1331.  
  1332.   If we have a HUGE file and all lines have not been read in, then we need
  1333.   to page the source buffer down in the file replenishing the source buffer.
  1334.   We then need to update the afile block and resynchronize the display.
  1335.  
  1336. */
  1337.  
  1338.  if( newtop < 1 )                       /* trying to go before first line?234*/
  1339.  {
  1340.   if( (fp->flags & AF_HUGE) &&          /* is this a HUGE file and the       */
  1341.        fp->Nbias                        /* buffer was previously paged down ?*/
  1342.     )
  1343.   {
  1344.    target = newtop + fp->Nbias;         /* yes on both. define new target    */
  1345.    if( target < 1 )                     /* if target is before file begin 234*/
  1346.     target = 1;                         /* then clip it at 1.             234*/
  1347.  
  1348.    pagefp( fp, target );                /* removed a +1.                  234*/
  1349.  
  1350.    Resync:
  1351.  
  1352.    newtop = target - fp->Nbias;         /* define the new top of the file    */
  1353.    fp->hotline += bias - fp->Nbias;     /* define the new hotline            */
  1354.    goto Recheck;                        /* do it again just for being a jerk */
  1355.   }
  1356.  
  1357.   newtop = 1;                           /* can't move before first line   234*/
  1358.  
  1359.  }
  1360.  else
  1361. /*
  1362.  
  1363.   At this point we first check to see if we have enough lines left in the
  1364.   buffer to fill up the display.  If we don't, we could still have source
  1365.   left in the file that has not been read into the source buffer.  This is
  1366.   the case of a HUGE file meaning that the 64k source buffer could not hold
  1367.   all of the source lines and we still need to read some in.
  1368.  
  1369.   If we have a HUGE file and all lines have not been read in, then we need
  1370.   to page the source buffer down in the file replenishing the source buffer.
  1371.   We then need to update the afile block and resynchronize the display.
  1372.  
  1373.  
  1374. */                                      /*need more lines than in buffer?*/
  1375.  {
  1376.   if( (uint)newtop + LinesPer - 1 > fp->Nlines )
  1377.   {
  1378.    if( (fp->flags & AF_HUGE) &&         /* yes. Is this a HUGE file and not  */
  1379.        (fp->Nlines + fp->Nbias < fp->Tlines) /* all lines have been read?    */
  1380.      )
  1381.    {
  1382.     target = newtop + fp->Nbias;        /* true again. define the target line*/
  1383.     if( target > (int)fp->Tlines )      /* is the target past end of file?   */
  1384.      target = fp->Tlines - LinesPer + 1;/* yes. display last LinesPer in file*/
  1385.     pagefp( fp, target + LinesPer - 1); /*                                234*/
  1386.     goto Resync;                        /* resync the display                */
  1387.    }
  1388.    newtop = fp->Nlines - LinesPer + 1;  /* display last LinesPer in file     */
  1389.    if( newtop < 1 )                     /* don't let the newtop go abv fil234*/
  1390.     newtop = 1;                         /* 1 is the minimum               234*/
  1391.   }
  1392.  }
  1393.  fp->topline = newtop;                  /* put new topline in afile          */
  1394.  fp->csrline = fp->topline + csrdelta;  /* put new csrline in afile          */
  1395.  
  1396.  fmttxt( fp );                          /* format the text for this afile    */
  1397. }
  1398.  
  1399. /***************************************************************************/
  1400. /*dofwdtab                                                                 */
  1401. /* move to the next c identifier in the line                               */
  1402. /*                                                                         */
  1403. /***************************************************************************/
  1404.  uint
  1405. dofwdtab(AFILE *fp,uchar *lp,uint col)  /* -> to afile                       */
  1406.                                         /* pointer to line cursor is on      */
  1407.                                         /* current cursor column             */
  1408. {
  1409.  uchar *cp;                             /* -> to char in source line         */
  1410.  uint   len;                            /* length of uncompressed source line*/
  1411.  int    delta=0;                        /* # of columns to next identifier   */
  1412.  uchar  line[MAXCOLS+1];                /* line buffer                       */
  1413.  
  1414.  len = Decode(lp, line);                /* define the uncompressed line len  */
  1415.  if( len > col )                        /* if the line is longer than column */
  1416.  {                                      /* then                              */
  1417.   cp = line + col;                      /* ->to character on the line        */
  1418.   line[len] = 0 ;                       /* init it to null                   */
  1419.   for( ;; )
  1420.   {
  1421.    while( IsOKchar(*cp++) ){;}          /* advance to end of current c ident */
  1422.    --cp;                                /* need to back up one position      */
  1423.    while( *cp && !IsOKchar(*cp) )       /* move to next identifier begin     */
  1424.     ++cp;
  1425.    if( *cp < '0' || *cp > '9' )         /* if we stopped on a constant then  */
  1426.     break;                              /* continue                          */
  1427.   }
  1428.   delta = (cp - line) - col ;           /* this is how much we gonna move    */
  1429.   dohcsr( fp, delta );                  /* now move it                       */
  1430.  }
  1431.  return( delta );                       /* inform caller how much we moved it*/
  1432. }
  1433. /***************************************************************************/
  1434. /*dobwdtab                                                                 */
  1435. /* move to the previous word in the line.                                  */
  1436. /*                                                                         */
  1437. /***************************************************************************/
  1438.  uint
  1439. dobwdtab(AFILE *fp,uchar *lp,uint col ) /* -> to afile                       */
  1440.                                         /* pointer to line cursor is on      */
  1441.                                         /* current cursor column             */
  1442. {
  1443.  uchar *cp;                             /* -> to char in source line         */
  1444.  uint  len;                             /* length of uncompressed source line*/
  1445.  int   delta=0;                         /* # of columns to next identifier   */
  1446.  uchar line[MAXCOLS+1];                 /* line buffer                       */
  1447.  
  1448.  len = Decode(lp, line);                /* define the uncompressed line len  */
  1449.  if( col && len )                       /* if the line is longer than column */
  1450.  {                                      /* then                              */
  1451.   cp = line + ( (col < len) ? col : len ); /* -> to column or end of line    */
  1452.   for( ;; )                             /* scan backward to previous identifr*/
  1453.   {
  1454.    for( ;; )                            /* scan left for OK char             */
  1455.    {
  1456.     if( cp == line )                    /* at the line begin?                */
  1457.      goto endfor;                       /* yes. we're done. get out          */
  1458.     if( IsOKchar(*--cp) )               /* is this a valid c identifier?     */
  1459.      break;                             /* yes. quit scan left for char      */
  1460.    }                                    /* end scan left for char            */
  1461.  
  1462.    while( IsOKchar(*cp) )               /* scan left for not-OK char         */
  1463.     if( --cp < line )                   /* at the line begin?                */
  1464.      break;                             /* yes. we're done. get out.         */
  1465.    if( *++cp < '0' || *cp > '9' )       /* valid identifier character ?      */
  1466.      break;                             /* yes. we're done, else a constant  */
  1467.   }                                     /* end scan backward for valid ident */
  1468.   endfor:
  1469.   delta = (cp - line) - col ;           /* how much to move the cursor       */
  1470.   dohcsr( fp, delta );                  /* move the cursor                   */
  1471.  }
  1472.  return( delta );                       /* return the amount moved           */
  1473. }                                       /* end dobwdtab()                    */
  1474.  
  1475. /***************************************************************************/
  1476. /*IsOnCRT                                                                  */
  1477. /* is the cursor on the screen.                                            */
  1478. /*                                                                         */
  1479. /***************************************************************************/
  1480.  uint
  1481. IsOnCRT(AFILE *fp )
  1482. {
  1483.  uint TorF;                             /* is it or isn't it                 */
  1484.  
  1485. /* we simply check to see if the current cursor line for the fp is within
  1486.    the line boundaries of the displayed source.
  1487. */
  1488.  
  1489.  TorF =( fp->csrline >= fp->topline &&
  1490.          fp->csrline < (fp->topline + fp->Nshown)
  1491.        );
  1492.  
  1493.  return( TorF );                        /* return the truth                  */
  1494. }
  1495.  
  1496. /***************************************************************************/
  1497. /*IsOKchar                                                                 */
  1498. /* check for valid c identifier.                                           */
  1499. /*                                                                         */
  1500. /***************************************************************************/
  1501.  uint
  1502. IsOKchar(uchar c)                       /* valid char for a C identifier     */
  1503. {
  1504.  uint ctr = c;                          /* was register.                  112*/
  1505.  
  1506.  return
  1507.  (
  1508.   (ctr >= '0' && ctr <= '9') ||         /* a digit ?                         */
  1509.   (ctr >= 'a' && ctr <= 'z') ||         /* a lowercase alpha ?               */
  1510.   (ctr >= 'A' && ctr <= 'Z') ||         /* an uppercase alpha ?              */
  1511.   (ctr == '_')||                        /* an underscore                     */
  1512.   (ctr == '@')||                        /* a @ for PL/86                     */
  1513.   (ctr == '$')||                        /* a $ for PL/86                     */
  1514.   (ctr == '#')||                        /* a # for PL/86                     */
  1515.   (ctr == 0x15)                         /* the italian character            */
  1516.  );
  1517. }
  1518.  
  1519. /*****************************************************************************/
  1520. /*  ResizeWindow()                                                           */
  1521. /*                                                                           */
  1522. /* Description:                                                              */
  1523. /*   Adjust the source and storage window sizes.                             */
  1524. /*                                                                           */
  1525. /* Parameters:                                                               */
  1526. /*   fp         input - afile for the source view.                           */
  1527. /*   adjust     input - amount to shrink the source window.                  */
  1528. /*                                                                           */
  1529. /* Return:                                                                   */
  1530. /*   1 or 0     0=ok. 1=can't do it.                                         */
  1531. /*                                                                           */
  1532. /* Assumptions                                                               */
  1533. /*              fp is valid.                                                 */
  1534. /*                                                                           */
  1535. /*****************************************************************************/
  1536. extern uint         MaxPer;             /* max # of lines for source code    */
  1537. extern uint        DataFileTop;         /* 1st rec shown of data file (0..N) */
  1538.  int                                    /* removed static                 701*/
  1539. ResizeWindow(AFILE *fp, int adjust )    /* afile for this view.              */
  1540.                                         /* source window adjustment amt.     */
  1541. {                                       /*                                   */
  1542.  int n = adjust;                        /* amount to adjust window size.     */
  1543.  
  1544. /*****************************************************************************/
  1545. /* The first thing to do is adjust the size of the window.                   */
  1546. /*                                                                           */
  1547. /*****************************************************************************/
  1548.  if( TopLine == VioStartOffSet &&       /* if the TopLine is maxed out and701*/
  1549.      adjust > 0                         /* caller wants it bigger, then      */
  1550.    )                                    /*                                   */
  1551.   return(0);                            /* don't do it.                      */
  1552.                                         /*                                   */
  1553.  TopLine -= adjust;                     /*                                   */
  1554.  if( TopLine > MaxData )                /* Limit to max data window size.    */
  1555.   TopLine = MaxData;                    /*                                   */
  1556.  
  1557. /*****************************************************************************/
  1558. /* Now we want to fit the data in the window and scroll the data if need be. */
  1559. /*                                                                           */
  1560. /*****************************************************************************/
  1561.  LinesPer = MaxPer - TopLine;           /* adjust top of source from bot.    */
  1562.  ShowData( TopLine );                   /* display the storage window.       */
  1563.  n = fp->csrline;                       /* hold the cursor line.             */
  1564.  dovscr( fp, -adjust );                 /* scroll the screen.                */
  1565.  fp->csrline = n;                       /* put the cursor line back.         */
  1566.  if( !IsOnCRT(fp) )                     /* if the cursor goes off screen,    */
  1567.   fp->csrline = fp->topline;            /* then put it on the top of source. */
  1568.  return(0);                             /*                                   */
  1569. }                                       /*                                   */
  1570. /*****************************************************************************/
  1571. /* ShrinkStorage()                                                           */
  1572. /*                                                                           */
  1573. /* Description:                                                              */
  1574. /*   Reduce the size of the storage window one line.                         */
  1575. /*                                                                           */
  1576. /* Parameters:                                                               */
  1577. /*   fp         input - afile structure for this source.                     */
  1578. /*   flag       input - source or asm flag.                                  */
  1579. /*                      1 = source.                                          */
  1580. /*                      0 = asm.                                             */
  1581. /*                                                                           */
  1582. /* Return:                                                                   */
  1583. /*              1 = can't do it.                                             */
  1584. /*              0 = dunnit.                                                  */
  1585. /*                                                                           */
  1586. /* Assumptions                                                               */
  1587. /*              will shrink it if I can.                                     */
  1588. /*                                                                           */
  1589. /*****************************************************************************/
  1590.  int                                    /*                                   */
  1591. ShrinkStorage(AFILE *fp , uint flag)    /* the afile structure for this src. */
  1592.                                         /* called from source or asm flag.   */
  1593.                                         /* 1 =>source. 0 =>asm.              */
  1594. {                                       /*                                   */
  1595.  uint span;                             /* span of data records in window.   */
  1596.                                         /*                                   */
  1597.  if( TopLine == VioStartOffSet)         /* if no data window we're done.  701*/
  1598.   return(1);                            /*                                   */
  1599.  span = DataFileBot - DataFileTop +1;   /* compute # recs in window.         */
  1600.  if(span == TopLine)                    /* if window is full, then           */
  1601.   if(DataFileBot)                       /* decrement the bottom display rec  */
  1602.     DataFileBot--;                      /*                                   */
  1603.  if(flag)                               /*                                   */
  1604.   ResizeWindow(fp,  1);                 /* resize the source window.         */
  1605.  else                                   /*                                   */
  1606.   Recalibrate(fp,  1);                  /* resize the asm window.            */
  1607.  return(0);                             /* return a success code.            */
  1608. }                                       /* end ShrinkStorage().              */
  1609. /*****************************************************************************/
  1610. /* ExpandStorage()                                                           */
  1611. /*                                                                           */
  1612. /* Description:                                                              */
  1613. /*   Increase the size of the storage window one line.                       */
  1614. /*                                                                           */
  1615. /* Parameters:                                                               */
  1616. /*   fp         input - afile structure for this source.                     */
  1617. /*   flag       input - source or asm flag.                                  */
  1618. /*                      1 = source.                                          */
  1619. /*                      0 = asm.                                             */
  1620. /*                                                                           */
  1621. /* Return:                                                                   */
  1622. /*              1 = can't do it.                                             */
  1623. /*              0 = dunnit.                                                  */
  1624. /*                                                                           */
  1625. /* Assumptions                                                               */
  1626. /*              will grow it if I can.                                       */
  1627. /*                                                                           */
  1628. /*****************************************************************************/
  1629.  int                                    /*                                   */
  1630. ExpandStorage(AFILE *fp , uint flag)    /* the afile structure for this src. */
  1631.                                         /* called from source or asm flag.   */
  1632.                                         /* 1 =>source. 0 =>asm.              */
  1633. {                                       /*                                   */
  1634.  if(TopLine == MaxData)                 /* if maxed out we can't do it       */
  1635.   return(1);                            /*                                   */
  1636.  DataFileBot++;                         /* expand window down.               */
  1637.  if(flag)                               /*                                   */
  1638.   ResizeWindow(fp, -1);                 /* resize the source window.         */
  1639.  else                                   /*                                   */
  1640.   Recalibrate(fp, -1);                  /* resize the asm window.            */
  1641.  return(0);                             /* return a success code.            */
  1642. }                                       /* end ExpandStorage().              */
  1643.  
  1644. void  SetCursorPos()                                                    /*701*/
  1645. {                                                                       /*701*/
  1646.   PEVENT  Event;                                                        /*701*/
  1647.                                                                         /*701*/
  1648.   Event = GetCurrentEvent();                                            /*701*/
  1649.   if( ((uint)Event->Row >= TopLine) &&                                  /*701*/
  1650.       ((uint)Event->Row <= (TopLine + showfp->Nshown - 1)) )            /*701*/
  1651.   {                                                                     /*701*/
  1652.     showfp->csrline = showfp->topline + (uint)Event->Row - TopLine;     /*701*/
  1653.     showfp->csr.col = (uchar)Event->Col;                                /*701*/
  1654.     showfp->csr.row = ( uchar )( showfp->csrline - showfp->topline + TopLine );
  1655.     lp = showfp->source + showfp->offtab[ showfp->csrline ];            /*701*/
  1656.     SrcCol  = showfp->skipcols + showfp->csr.col;                       /*701*/
  1657.     SrcLine = showfp->csrline  + showfp->Nbias;                         /*701*/
  1658.     PutCsr( ( CSR * )&showfp->csr );                                    /*701*/
  1659.   }                                                                     /*701*/
  1660.   else                                                                  /*701*/
  1661.     beep();                                                             /*701*/
  1662. }                                                                       /*701*/
  1663. /*****************************************************************************/
  1664. /* GetEventView()                                                         701*/
  1665. /*                                                                        701*/
  1666. /* Description:                                                           701*/
  1667. /*   Get the current view that a mouse click has occurred in.             701*/
  1668. /*                                                                        701*/
  1669. /* Parameters:                                                            701*/
  1670. /*  none                                                                  701*/
  1671. /*                                                                        701*/
  1672. /*                                                                        701*/
  1673. /* Return:                                                                701*/
  1674. /*  view        SOURCEVIEW ( or assembler ) it's the same.                701*/
  1675. /*              DATAVIEW                                                  701*/
  1676. /*              ACTIONBAR                                                 701*/
  1677. /*                                                                        701*/
  1678. /* Assumptions                                                            701*/
  1679. /*  none                                                                  701*/
  1680. /*                                                                        701*/
  1681. /*****************************************************************************/
  1682. extern uint           FnameRow;                                         /*701*/
  1683.                                                                         /*701*/
  1684. int GetEventView( )                                                     /*701*/
  1685. {                                                                       /*701*/
  1686.  PEVENT CurrentEvent;                                                   /*701*/
  1687.  int    view = 0;                                                       /*701*/
  1688.                                                                         /*701*/
  1689.  CurrentEvent = GetCurrentEvent();                                      /*701*/
  1690.  
  1691.  if(!iview) {                                                           /*701*/
  1692.  if( CurrentEvent->Row == 0 )                                           /*701*/
  1693.   view = ACTIONBAR;                                                     /*701*/
  1694.                                                                         /*701*/
  1695.  if( CurrentEvent->Row >= TopLine && CurrentEvent->Row <  FnameRow )    /*701*/
  1696.   view = SOURCEVIEW;                                                    /*701*/
  1697.                                                                         /*701*/
  1698.  else if( CurrentEvent->Row != 0 &&  CurrentEvent->Row < TopLine )      /*701*/
  1699.   view = DATAVIEW;                                                      /*701*/
  1700.  }                                                                      /*701*/
  1701.  else
  1702.  {
  1703. #ifdef MSH
  1704.   extern WINDOW *root, *Window[]; WINDOW *win;
  1705.   win=GetEventWindow(root);
  1706.   if( CurrentEvent->Row == 0 )                                           /*701*/
  1707.   view = ACTIONBAR;                                                      /*701*/
  1708.   else if(win==Window[DATA_WIN]) view=DATAVIEW;
  1709.   else view=SOURCEVIEW;
  1710. #endif
  1711.  }/* End if*/
  1712.  return(view);                                                          /*701*/
  1713. }                                                                       /*701*/
  1714. /*****************************************************************************/
  1715. /* SetSrcViewCsr()                                                        701*/
  1716. /*                                                                        701*/
  1717. /* Description:                                                           701*/
  1718. /*   Set the cursor position in the source window when a mouse event      701*/
  1719. /*   occurs.                                                              701*/
  1720. /*                                                                        701*/
  1721. /* Parameters:                                                            701*/
  1722. /*                                                                        701*/
  1723. /* Return:                                                                701*/
  1724. /*                                                                        701*/
  1725. /* Assumptions                                                            701*/
  1726. /*  The caller has already verified that the cursor is in the             701*/
  1727. /*  Source window.                                                        701*/
  1728. /*                                                                        701*/
  1729. /*****************************************************************************/
  1730. void  SetSrcViewCsr( AFILE *fp )                                        /*701*/
  1731. {                                                                       /*701*/
  1732.   PEVENT  Event;                                                        /*701*/
  1733.                                                                         /*701*/
  1734.   Event = GetCurrentEvent();                                            /*701*/
  1735.   if( ((uint)Event->Row >= TopLine) &&                                  /*701*/
  1736.       ((uint)Event->Row <= (TopLine + fp->Nshown - 1)) )                /*701*/
  1737.   {                                                                     /*701*/
  1738.    fp->csrline = fp->topline + Event->Row - TopLine;                    /*701*/
  1739.    fp->csr.col = Event->Col;                                            /*701*/
  1740.   }                                                                     /*701*/
  1741. }                                                                       /*701*/
  1742.  
  1743. void WaitForInterrupt( void *dummy )
  1744. {
  1745.  EVENT           *pEvent;
  1746.  
  1747.  
  1748.  for(;;)
  1749.  {
  1750.   pEvent = GetEvent( 500 );
  1751.   if( pEvent->FakeEvent == TRUE )
  1752.   {
  1753.    if( QueryConnectSema4() == SEMA4_POSTED )
  1754.     break;
  1755.  
  1756.    continue;
  1757.   }
  1758.  
  1759.   if( QueryConnectSema4() == SEMA4_RESET )
  1760.    ConnectThisPid( INFORM_ESP );
  1761.   break;
  1762.  }
  1763.  _endthread();
  1764. }
  1765.  
  1766. void ConnectThisPid( int InformEsp )
  1767. {
  1768.  ALLPIDS         *pYieldPid;
  1769.  DBG_QUE_ELEMENT  Qelement;
  1770.  USHORT           ThisPid;
  1771.  USHORT           YieldPid;
  1772.  
  1773.  ThisPid  = (USHORT)DbgGetProcessID();
  1774.  
  1775.  YieldPid  = 0;
  1776.  pYieldPid = GetPidConnected();
  1777.  if( pYieldPid )
  1778.   YieldPid  = pYieldPid->pid;
  1779.  
  1780.  if( ThisPid != YieldPid )
  1781.  {
  1782.   if( pYieldPid )
  1783.   {
  1784.    pYieldPid->PidFlags.ConnectYielded = TRUE;
  1785.    SetConnectSema4( &pYieldPid->ConnectSema4, TRUE );
  1786.   }
  1787.  
  1788.   Qelement.pid = ThisPid;
  1789.   Qelement.sid = (ULONG)YieldPid;
  1790.  
  1791.   Qelement.DbgMsgFlags.InformEsp = TRUE;
  1792.   if( InformEsp == NO_INFORM_ESP )
  1793.    Qelement.DbgMsgFlags.InformEsp = FALSE;
  1794.  
  1795.   SendMsgToDbgQue( DBG_QMSG_CONNECT_ESP, &Qelement, sizeof(Qelement) );
  1796.  }
  1797. }
  1798.