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

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   showdk.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*  data formatting routines.                                                */
  8. /*                                                                           */
  9. /*                                                                           */
  10. /* History:                                                                  */
  11. /*                                                                           */
  12. /*****************************************************************************/
  13.  
  14. #include "all.h"
  15. static int iview=0;
  16. #define FmtErr fmterr
  17. /**Defines *******************************************************************/
  18.  
  19. #define N1KEYS 17
  20.  
  21. /**External declararions******************************************************/
  22.  
  23.  
  24. extern uint        DstatRow;            /* data window status row.           */
  25. extern uint        ExprMid;             /* Set by ParseExpr                  */
  26. extern uint        ExprLno;             /* Set by ParseExpr                  */
  27. extern uint        ExprTid;             /* Set by ParseExpr                  */
  28. extern SCOPE       ExprScope;           /* Set by ParseExpr                  */
  29. extern uchar*      ParseError;          /* Set by ParseExpr                  */
  30. extern uchar       BadExprMsg[];        /*                                   */
  31. extern KEY2FUNC    defk2f[];            /*                                   */
  32. extern uint        ParseMshExpr;
  33. extern uint        DataFileTop;         /* top record displayed in data file.*/
  34. extern uint        DataFileBot;         /* bottom rec displayed in data file.*/
  35. extern uint        TopLine;             /* current top line for Code (0..N)  */
  36. extern uint        LinesPer;            /* current # lines/screen for code  */
  37. extern uint        SaveTopLine;         /* saved top line.                   */
  38. extern int         HideDataWin;         /* data window hidden flag.          */
  39. extern uint        ExprAddr;            /* Set by ParseExpr.              112*/
  40. extern uchar       Re_Parse_Data;       /* flag to indicate wether all    244*/
  41.                                         /* variables in datawindow are to 244*/
  42.                                         /* be reparsed.                   244*/
  43. extern uint        VioStartOffSet;      /* flag to tell were to start screen */
  44.                                         /* display.                       701*/
  45. extern uint        VideoCols;
  46. extern uint        VideoRows;
  47. extern uchar      *BoundPtr;            /* -> to screen bounds            701*/
  48. extern CmdParms   cmd;
  49. extern UINT       MaxData;              /* max # of lines of Data            */
  50.  
  51. int    BlowBy = NO;                     /* blow by GetFuncsFromEvents flag701*/
  52. int    HideDataWin;                     /* data window hidden flag.          */
  53. DFILE *DataFileQ;                       /* data file pointer.                */
  54. DFILE *dfpfirst={(DFILE*)(void*)&DataFileQ};
  55. DFILE *dfplast ={(DFILE*)(void*)&DataFileQ};
  56.  
  57. /**Static definitions ********************************************************/
  58.  
  59. static  CSR stgcsr[3];                 /* data window cursor definition.    */
  60.  
  61.  
  62. /*****************************************************************************/
  63. /*  InitDataWinCsr()                                                      701*/
  64. /*                                                                           */
  65. /* Description:                                                              */
  66. /*                                                                           */
  67. /*   Inits the data window cursor value to one.                              */
  68. /*                                                                           */
  69. /* Return:                                                                   */
  70. /*   None                                                                    */
  71. /*****************************************************************************/
  72. void InitDataWinCsr()                                                   /*701*/
  73. {                                                                       /*701*/
  74.   stgcsr[0].row = 1;                                                    /*701*/
  75.   stgcsr[1].row = 0;                                                    /*701*/
  76.   stgcsr[2].row = 0;                                                    /*701*/
  77. }                                                                       /*701*/
  78.  
  79. int typoS(SIZEFUNC resizefunc, AFILE *fp, AFILE **fpp)
  80. {
  81.  int    row;                            /* display row in the data window.   */
  82.  int    mem;                            /* the member of a dfile node.       */
  83.  uint   key;                            /* the user's input key.             */
  84.  uint   span;                           /* span of records in data window.   */
  85.  int    nexttop;                        /* next top line of data display.    */
  86.  uint   absrow;                         /* the absolute data file record #.  */
  87.  int    func;                           /* function associated with a key.   */
  88.  DFILE *dfp;                            /* -> to a dfile node.               */
  89.  uint   filelen;                        /* length of the data file.          */
  90.  char   msgbuf[80];                     /* buffer for message.               */
  91.  uint   rc;                             /* retrun code.                      */
  92.  uint   view_flag;                      /* flag to indicate source or asm 220*/
  93.                                         /* view.                             */
  94.  uchar  Data_Refresh_flag;              /* flag to indicate refesh of     244*/
  95.                                         /* data window.                   244*/
  96.  AFILE  *newfp;
  97. /*****************************************************************************/
  98. /* The first thing we want to do is open the data window if one is not open. */
  99. /* We will open a full size, blank window and resize the src/asm window      */
  100. /* as necessary.                                                             */
  101. /*                                                                           */
  102. /*****************************************************************************/
  103.  if(HideDataWin)                        /* we may need to unhide the         */
  104.  {                                      /* data window.                      */
  105.   (* resizefunc)(fp,-(int)SaveTopLine); /* resize the src/asm window.     521*/
  106.   HideDataWin = FALSE;                  /* TopLine gets reestablished in     */
  107.  }                                      /* the resizefunc()...puke!          */
  108.  DstatRow = TopLine;                    /* establish status line (0..N).     */
  109.  if( !(TopLine-VioStartOffSet))         /* if there is not a window open, 701*/
  110.  {                                      /*                                   */
  111.   DstatRow = MaxData;                   /* establish status line (0..N).     */
  112.   (* resizefunc)(fp,-(int)MaxData);     /* resize the src/asm window.     521*/
  113.  }                                      /*                                   */
  114.                                         /*                                   */
  115. /*****************************************************************************/
  116. /* Establish the cursor row in the data window. Do not wrap.                 */
  117. /*                                                                           */
  118. /*****************************************************************************/
  119.  row = stgcsr[iview].row;                      /* retrieve saved cursor position.   */
  120.  if( row >= (int)TopLine )              /* if below the window, then         */
  121.    row = TopLine - 1 + VioStartOffSet;  /* peg it at the bottom.          701*/
  122.                                         /*                                   */
  123. /*****************************************************************************/
  124. /* Now refresh the data in the window and add the status line.               */
  125. /*                                                                           */
  126. /*****************************************************************************/
  127. Refresh:
  128.  ShowData( iview?LinesPer:TopLine );
  129.  FmtErr(NULL);
  130.  
  131.  /************************************************************************701*/
  132.  /* - The BlowBy flag is used to skip the GetFuncsFromEvents call in      701*/
  133.  /*   showc() and showa so that we can execute functions from the         701*/
  134.  /*   data window and come back into the data window without stopping     701*/
  135.  /*   in showc() or showa().                                              701*/
  136.  /* - To avoid an annoying blink when running functions from the data     701*/
  137.  /*   window we set the BoundPtr[TopLine] = 0 so that this line could     701*/
  138.  /*   not be written to. What we have to do here is reset the BoundPtr    701*/
  139.  /*   back to what it should be.                                          701*/
  140.  /*                                                                       701*/
  141.  /************************************************************************701*/
  142.  if(iview==VIEW_NORMAL)
  143.  {                                                                      /*701*/
  144.   extern uchar  Reg_Display;                                            /*701*/
  145.   BoundPtr[TopLine] = VideoCols;                                        /*701*/
  146.   if(TestBit(Reg_Display,REGS386BIT))                                   /*701*/
  147.    BoundPtr[TopLine] = VideoCols-REGSWINWIDTH;                          /*701*/
  148.   if(TestBit(Reg_Display,REGS387BIT))                                   /*701*/
  149.    BoundPtr[TopLine] = VideoCols-COREGSWINWIDTH;                        /*701*/
  150.  }                                                                      /*701*/
  151.   BlowBy = NO;                                                          /*701*/
  152.  
  153. /*****************************************************************************/
  154. /* We will now handle the following functions.                               */
  155. /*                                                                           */
  156. /* case UPCURSOR:                       -- move cursor up in data window/drag*/
  157. /* case DOWNCURSOR:                     -- move cursor dn in data window/drag*/
  158. /* case FIRSTWINDOW:                    -- move to top of data file.         */
  159. /* case PREVWINDOW:                     -- move back one window.             */
  160. /* case TOPOFWINDOW:                    -- move cursor to top of window.     */
  161. /* case BOTOFWINDOW:                    -- move cursor to bottom of window.  */
  162. /* case LASTWINDOW:                     -- move to last window in file.      */
  163. /* case NEXTWINDOW:                     -- move to the next window in file.  */
  164. /* case SHRINKSTORAGE:                  -- reduce the window size.           */
  165. /* case EXPANDSTORAGE:                  -- increase the window size.         */
  166. /* case EXPANDVAR:                      -- expand  the dfile node member.    */
  167. /* case TABRIGHT:                       -- edit the dfile record.            */
  168. /* case RIGHTCURSOR:                    -- edit the dfile record.            */
  169. /* case HELP:                           -- help.                             */
  170. /* case SHOWSEGS:                       -- show the EXE header segments.     */
  171. /* case TOGGLESTORAGE:                  -- go back to the source window.     */
  172. /* case ACTIONBAR:                      -- display the options menu.         */
  173. /* case FORMATVAR:                      -- display data record in user format*/
  174. /* case INSERTLINE:                     -- add a blank line in the data win. */
  175. /* case DELETELINE:                     -- delete an object from the data win*/
  176. /* case EDITFORMULA:                    -- edit a data window expression.    */
  177. /* case BROWSE:                         -- browse any file.                  */
  178. /* case TOGGLEHIDESTORAGE:              -- go back to the src window&hide    */
  179. /* case SHOWHIDESTORAGE:                -- go back to the src window&hide    */
  180. /* case SETCOLORS:                      -- set colors from colors menu       */
  181. /*                                                                           */
  182. /*****************************************************************************/
  183.  Data_Refresh_flag = FALSE;             /* reset the data refresh flag.      */
  184.  for( ;; )                              /* begin loop to process user input. */
  185.  {                                      /*                                   */
  186.   if (Data_Refresh_flag)                /* if data refreh flag is set     244*/
  187.   {                                     /* then call show data.           244*/
  188.     ShowData( iview?LinesPer:TopLine );
  189.     Data_Refresh_flag = FALSE;          /* reset the data refresh flag.   244*/
  190.   }
  191.   absrow = DataFileTop +                /* establish absolute data file rec. */
  192.       (stgcsr[iview].row = ( uchar )row);      /*                                   */
  193.   {
  194.     CSR csr;
  195.     csr.row=RowStart+stgcsr[iview].row;
  196.     csr.col=ColStart+stgcsr[iview].col;
  197.     PutCsr( &csr );                     /* refresh the cursor.               */
  198.   }
  199.   if( TopLine )                         /* if there is a data window, then   */
  200.    if(!iview) fmtdwinstat(DstatRow, row );         /* put in a status line.             */
  201.  
  202.   /***************************************************************************/
  203.   /* Set the masked items for the source view.                            701*/
  204.   /***************************************************************************/
  205.   if( fp->shower == showA )                                             /*701*/
  206.     SetMenuMask( DATAVIEWASM );                                         /*701*/
  207.   else                                                                  /*701*/
  208.     SetMenuMask( DATAVIEWSRC );                                         /*701*/
  209.                                                                         /*701*/
  210.   if( (fp == GetExecfp()) || (GetExecfp() == NULL) )                    /*701*/
  211.    DisableDropFile();
  212.   else
  213.    EnableDropFile();
  214.  
  215.   /***************************************************************************/
  216.   /* Get an event from the kbd/mouse.                                     701*/
  217.   /***************************************************************************/
  218. GETAFUNCTION:
  219. #define  RETURNESC  1                                                   /*818*/
  220.  
  221.   if( (SerialParallel() == SERIAL) && (QueryConnectSema4() == SEMA4_RESET) )
  222.   {
  223.    FmtErr("Disconnected...double click on window to reconnect.");
  224.    _beginthread(WaitForInterrupt, NULL, 0x8000, NULL );
  225. block:
  226.    SerialConnect( JUST_WAIT, DbgGetProcessID(), _DBG, SendMsgToDbgQue );
  227.    FmtErr("Reconnected.");
  228.    DosSelectSession(0);
  229.   }
  230.  
  231.   func = GetFuncsFromEvents( RETURNESC, (void *)fp );              /*818  701*/
  232.  
  233.   if( (SerialParallel() == SERIAL) && (QueryConnectSema4() == SEMA4_RESET) )
  234.   {
  235.    ConnectThisPid( INFORM_ESP );
  236.    goto block;
  237.   }
  238. HANDLEEVENTS:
  239.   /***************************************************************************/
  240.   /* GetFuncsFromEvents will not always be able to return an executable   701*/
  241.   /* function code, so we get back a raw LEFTMOUSECLICK or RIGHTMOUSECLICK701*/
  242.   /* So, what we do is:                                                   701*/
  243.   /*                                                                      701*/
  244.   /*  -LEFTMOUSECLICK                                                     701*/
  245.   /*    - if the click is in the data window, then set the cursor         701*/
  246.   /*      position or edit storage.                                       701*/
  247.   /*    - if the click is in the source window, then switch to the source 701*/
  248.   /*      window.                                                         701*/
  249.   /*                                                                      701*/
  250.   /*  -RIGHTMOUSECLICK                                                    701*/
  251.   /*    - bring up the object pulldown for the data window.               701*/
  252.   /*                                                                      701*/
  253.   /***************************************************************************/
  254.   if( func == LEFTMOUSECLICK )                                          /*701*/
  255.   {                                                                     /*701*/
  256.    switch( GetEventView() )                                             /*701*/
  257.    {                                                                    /*701*/
  258.     case SOURCEVIEW:                                                    /*701*/
  259.      SetSrcViewCsr( fp );                                               /*701*/
  260.      func = TOGGLESTORAGE;                                              /*701*/
  261.      break;                                                             /*701*/
  262.                                                                         /*701*/
  263.     case DATAVIEW:                                                      /*701*/
  264.     {                                                                   /*701*/
  265.      PEVENT  Event;                                                     /*701*/
  266.                                                                         /*701*/
  267.      Event = GetCurrentEvent();                                         /*701*/
  268.                                                                         /*701*/
  269.      if(Event->Col >= STGCOL - 1)                                       /*701*/
  270.      {                                                                  /*701*/
  271.       SetDataViewCsr();                                                 /*701*/
  272.       row = stgcsr[iview].row;                                                 /*701*/
  273.       absrow = DataFileTop + ( uchar )row ;                             /*701*/
  274.       func = TABRIGHT;                                                  /*701*/
  275.      }                                                                  /*701*/
  276.      else                                                               /*701*/
  277.       func = SETCURSORPOS;                                              /*701*/
  278.      break;                                                             /*701*/
  279.     }                                                                   /*701*/
  280.                                                                         /*701*/
  281.     case ACTBARVIEW:                                                    /*701*/
  282.      goto GETAFUNCTION;                                                 /*701*/
  283.                                                                         /*701*/
  284.                                                                         /*701*/
  285.     default:                                                            /*701*/
  286.      func = DONOTHING;                                                  /*701*/
  287.      break;                                                             /*701*/
  288.    }                                                                    /*701*/
  289.   }                                                                     /*701*/
  290.   else if( func == RIGHTMOUSECLICK )                                    /*701*/
  291.   {                                                                     /*701*/
  292.     int    MouseState;                                                  /*701*/
  293.     MouseState = STATE_BUTTON_PRESSED;                                  /*701*/
  294.     func = GetObjectPullChoice( 13, &MouseState );                      /*701*/
  295.   }                                                                     /*701*/
  296.  
  297. #if 0
  298.   if(key == ESC)                        /*                                   */
  299.    func = TOGGLESTORAGE;                /*                                   */
  300. #endif
  301.  
  302.   switch( func )                        /* branch on the user input.         */
  303.   {                                     /*                                   */
  304.    case UPCURSOR:                       /* begin UPCURSOR.                   */
  305.                                         /*                                   */
  306.     if( --row == (VioStartOffSet-1) )   /* if we're trying to drag the    701*/
  307.     {                                   /* window up in the file, then       */
  308.      row = VioStartOffSet;              /* put the cursor on the 1st line 701*/
  309.      if(DataFileTop > 0)                /* If the window is not topped out   */
  310.       DataFileTop--;                    /* then drag the window up one line. */
  311.      span = DataFileBot - DataFileTop;  /* if the data file is too big to fit*/
  312.      if( span == TopLine )              /* in the window, then adjust the    */
  313.       DataFileBot--;                    /* size of the window so it will fit.*/
  314.      Data_Refresh_flag = TRUE;          /* set the data refresh flag.     244*/
  315.     }                                   /*                                   */
  316.     break;                              /* end UPCURSOR.                     */
  317.                                         /*                                   */
  318.    case DOWNCURSOR:                     /* begin DOWNCURSOR.                 */
  319.                                         /*                                   */
  320.     if( ++row == (int)TopLine )         /* if we're trying to drag the       */
  321.     {                                   /* window down, then leave the cursor*/
  322.      row--;                             /* on the bottom line.               */
  323.      DataFileTop++;                     /* move the window top down one rec- */
  324.      DataFileBot++;                     /* move the bottom of the window     */
  325.      Data_Refresh_flag = TRUE;          /* set the data refresh flag.     244*/
  326.     }                                   /*                                   */
  327.     break;                              /* end DOWNCURSOR.                   */
  328.                                         /*                                   */
  329.    case FIRSTWINDOW:                    /* begin FIRSTWINDOW, alias C-Home.  */
  330.     if( DataFileTop > 0 )               /* if window is not already pegged   */
  331.     {                                   /* against the top, then             */
  332.      DataFileTop = 0;                   /* peg window to top of data file.   */
  333.      DataFileBot=DataFileTop+TopLine-1; /* establish window bottom.          */
  334.      Data_Refresh_flag = TRUE;          /* set the data refresh flag.     244*/
  335.     }                                   /*                                   */
  336.     row = VioStartOffSet;               /* put cursor on the top line.    701*/
  337.     break;                              /* end FIRSTWINDOW.                  */
  338.                                         /*                                   */
  339.    case PREVWINDOW:                     /* begin PREVWINDOW, alias PgUp.     */
  340.     if( DataFileTop > 0 )               /* if the window is not pegged to the*/
  341.     {                                   /* top of the file, then             */
  342.      nexttop = DataFileTop-TopLine + 1; /* compute the next top of file and  */
  343.      DataFileTop = nexttop;             /* clip it at the top of the file.   */
  344.      if( nexttop < 0 )                  /*                                   */
  345.       DataFileTop = 0;                  /*                                   */
  346.      DataFileBot=DataFileTop+TopLine-1; /* compute the data file bottom.     */
  347.      Data_Refresh_flag = TRUE;          /* set the data refresh flag.     244*/
  348.     }                                   /*                                   */
  349.     row = VioStartOffSet;               /* put the cursor on the top row. 701*/
  350.     break;                              /* end PREVWINDOW.                   */
  351.                                         /*                                   */
  352.    case TOPOFWINDOW:                    /* TOPOFWINDOW, alias C-PgUp.        */
  353.     row = VioStartOffSet;               /* put the cursor on the top row. 701*/
  354.     break;                              /*                                   */
  355.                                         /*                                   */
  356.    case LASTWINDOW:                     /* begin LASTWINDOW, alias c-end.    */
  357.     dfp = (DFILE *)&DataFileQ;          /* ->to dfile ring pointer.          */
  358.  
  359.     /*************************************************************************/
  360.     /* scan to the last node in the dfile ring.                              */
  361.     /*************************************************************************/
  362.     for( ; dfp && dfp->next; dfp = dfp->next){;}
  363.  
  364.     if( dfp != NULL )                   /* a node.                           */
  365.     {                                   /*                                   */
  366.      filelen = dfp->lrn+dfp->lines;     /* compute length of the data file.  */
  367.      nexttop = filelen - TopLine;       /* compute last window top rec.      */
  368.      if( nexttop > (int)DataFileTop )   /* if it's past the current top rec  */
  369.      {                                  /* then compute the new top and      */
  370.       DataFileTop = nexttop;            /* bottom.                           */
  371.       DataFileBot = filelen - 1;        /*                                   */
  372.       Data_Refresh_flag = TRUE;         /* set the data refresh flag.     244*/
  373.      }                                  /*                                   */
  374.      row = TopLine - 1;                 /* move cursor to top of window.     */
  375.     }                                   /*                                   */
  376.     break;                              /* end LASTWINDOW.                   */
  377.  
  378.    case NEXTWINDOW:                     /* begin NEXTWINDOW, alias PgDn.     */
  379.     DataFileTop += TopLine-1;           /*                                   */
  380.     DataFileBot += TopLine-1;           /*                                   */
  381.     Data_Refresh_flag = TRUE;           /* set the data refresh flag.     244*/
  382.     row = TopLine-1;                    /* put cursor on the bottom of window*/
  383.     break;                              /* end NEXTWINDOW.                   */
  384.                                         /*                                   */
  385.    case BOTOFWINDOW:                    /* ctrl-PgDn.                        */
  386.      row = TopLine-1;                   /* put cursor on bottom of window.   */
  387.      break;                             /*                                   */
  388.  
  389.    case SETCURSORPOS:                                                   /*701*/
  390.     SetDataViewCsr();                                                   /*701*/
  391.     row = stgcsr[iview].row;                                                   /*701*/
  392.     break;                                                              /*701*/
  393.                                         /*                                   */
  394.    case SHRINKSTORAGE:                  /* SHRINKSTORAGE.                    */
  395.     if( fp->shower == showC)            /* set a view flag for the call   220*/
  396.      view_flag = 1;                     /* to shrinkstorage.              220*/
  397.     else                                /*                                220*/
  398.      view_flag = 0;                     /*                                220*/
  399.     if( ShrinkStorage(fp,view_flag) )   /* shrink it.                     220*/
  400.      beep();                            /*                                   */
  401.     DstatRow = TopLine;                 /* reset the status line.            */
  402.     if(row >= (int)TopLine)             /* don't let cursor fall into the    */
  403.      row = TopLine -1;                  /* source window.                    */
  404.     if(TopLine != VioStartOffSet)       /* if we have closed up the data  701*/
  405.      break;                             /* window, then go back to the       */
  406.     FmtErr( NULL );                     /* source/asm window.                */
  407.     return(0);                          /*                                   */
  408.  
  409. /*****************************************************************************/
  410. /* These three functions handling leaving the data window.                   */
  411. /*                                                                           */
  412. /*****************************************************************************/
  413.    case TOGGLEHIDESTORAGE:              /* hide the data window when         */
  414.    case SHOWHIDESTORAGE:                /* leaving.                          */
  415.     SaveTopLine = TopLine - VioStartOffSet;/* hold top line for restore.  701*/
  416.     (* resizefunc)(fp,TopLine-VioStartOffSet);/* resize and refresh win   701*/
  417.                                         /* will set TopLine = 0              */
  418.     HideDataWin = TRUE;                 /* set hidden mode flag.             */
  419.     return(-2);                         /*                                   */
  420.                                         /*                                   */
  421.    case ESCAPE:                                                         /*818*/
  422.    case TOGGLESTORAGE:                  /* return to src/asm window.         */
  423.      FmtErr( NULL );                    /*                                   */
  424.      return(0);                         /*                                   */
  425.  
  426.    case EXPANDSTORAGE:                  /* EXPANDSTORAGE                     */
  427.     if( fp->shower == showC)            /* check in what type of view are 701*/
  428.        view_flag = 1;                   /* we in the source window. Depen 220*/
  429.     else                                /* ding on that pass a flag to    220*/
  430.        view_flag = 0;                   /* expand storage.                220*/
  431.     if( ExpandStorage(fp,view_flag) )   /*                                220*/
  432.      beep();                            /* beep if not expandable            */
  433.     DstatRow = TopLine;                 /*                                   */
  434.     break;                              /* reset the status line.            */
  435.                                         /*                                   */
  436.    case EXPANDVAR:                      /*                                   */
  437.     {                                   /*                                   */
  438.      uint recno;                        /* the data file record number.      */
  439.      recno = DataFileTop + row;         /* establish the record number.      */
  440.      dfp=FindNearDrec( recno );         /* find the containing dfile node.   */
  441.      if(!dfp ||                         /* if no node or the member number   */
  442.         recno-dfp->lrn + 1 > dfp->lines /* is beyond the end of the node     */
  443.        )                                /* then                              */
  444.      {                                  /*                                   */
  445.       beep();                           /* alert the user.                   */
  446.       FmtErr("No data to expand");      /* format an error message.          */
  447.       break;                            /* go try again.                     */
  448.      }                                  /*                                   */
  449.                                         /* now, verify active function if    */
  450.      /************************************************************************/
  451.      /* If this node is for a stack variable, the stack frame may not        */
  452.      /* be active. We need to check for this and send a message.             */
  453.      /* The scope is in the node info.                                       */
  454.      /************************************************************************/
  455.      if( dfp->scope && !dfp->sfx )      /* if stack var and no active        */
  456.      {                                  /* frame, then...                    */
  457.       char   procname[64];              /* buffer for procedure name.        */
  458.                                         /*                                   */
  459.       CopyProcName(dfp->scope,          /* get function defining this        */
  460.                    procname,            /* stack variable.                   */
  461.                    sizeof(procname)     /*                                   */
  462.                   );                    /*                                   */
  463.       sprintf( msgbuf,                  /* build a  "function not active" 521*/
  464.               "\"%s\" not active",      /* message.                          */
  465.               procname);                /*                                   */
  466.                                         /*                                   */
  467.       beep();                           /* beep.                             */
  468.       putmsg(msgbuf);                   /* display the message.              */
  469.       break;                            /*                                   */
  470.      }                                  /*                                   */
  471.      mem = recno - dfp->lrn + 1;        /* compute the node member.          */
  472.      newfp = NULL;
  473.      rc = zoomrec( fp, dfp, mem, &newfp );
  474.      if( newfp )
  475.      {
  476.       *fpp = newfp;
  477.       return(0);
  478.      }
  479.      if(rc && rc != ESC )               /* back all the way out on ESC.      */
  480.      {                                  /*                                   */
  481.       beep();                           /*                                   */
  482.       putmsg("can't expand this data"); /*                                   */
  483.      }                                  /*                                   */
  484.  
  485.      if( fp->shower == showC )          /*                                701*/
  486.        dovscr( fp, 0 );                 /* refresh source part of the     220*/
  487.      else                               /* screen or else refresh the asm 220*/
  488.      {                                  /* part of the screen             220*/
  489.        fp->flags |= ASM_VIEW_REFRESH;   /* set the flag for refreshing    302*/
  490.        ascroll( fp, 0 );                /* asm view                       302*/
  491.      }
  492.      break;
  493.     }
  494.  
  495. caseTABRIGHT:
  496.    case TABRIGHT:
  497.    case RIGHTCURSOR:
  498.    { uchar *cp;
  499.  
  500.      if( (dfp = FindNearDrec(absrow)) && dfp->zapper )
  501.      {
  502.       if( !(cp=ParseExpr(dfp->expr,0x10,dfp->mid,dfp->lno, dfp->sfi)) || *cp )
  503.       {
  504.        FmtErr("Sorry, I can't do that right now.");
  505.       }
  506.       else
  507.       {
  508.        rc = (*dfp->zapper)(dfp, row, absrow - dfp->lrn);                /*701*/
  509.        if(  rc )                                                        /*701*/
  510.        {                                                                /*701*/
  511.         if( rc == LEFTMOUSECLICK )                                      /*701*/
  512.         {                                                               /*701*/
  513.          func = LEFTMOUSECLICK;                                         /*701*/
  514.          goto HANDLEEVENTS;                                             /*701*/
  515.         }                                                               /*701*/
  516.         if( (rc == RECIRCULATE) || (rc == UP) || (rc == DOWN) )         /*701*/
  517.         {                                                               /*701*/
  518.          row = stgcsr[iview].row;                                              /*701*/
  519.          absrow = DataFileTop + ( uchar )row ;                          /*701*/
  520.          goto caseTABRIGHT;                                             /*701*/
  521.         }                                                               /*701*/
  522.  
  523.         Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  524.  
  525.         /*********************************************************************/
  526.         /* - set the DataRecalc flag.                                     903*/
  527.         /*********************************************************************/
  528.         {                                                               /*903*/
  529.          extern int DataRecalc;                                         /*903*/
  530.                                                                         /*903*/
  531.          DataRecalc = TRUE;                                             /*903*/
  532.         }                                                               /*903*/
  533.  
  534.         goto Refresh;
  535.        }
  536.       }
  537.      }
  538.      beep();break;
  539.    }
  540.  
  541.    case GENHELP:                        /* General help                   701*/
  542.     {
  543.       uchar *HelpMsg;
  544.  
  545.       HelpMsg = GetHelpMsg( HELP_WIN_DATA, NULL,0 );
  546.       CuaShowHelpBox( HelpMsg );
  547.     }                                  /* else fall through...              */
  548.     break;
  549.  
  550.    case HELP:
  551.      HelpScreen( );              /* enter our help function ( ESC key */
  552.                                  /*   to return here )                */
  553.       break;                     /* for now, no context sensitive help*/
  554.  
  555.    case TOGGLEASM:                                                      /*701*/
  556.     return(func);                                                       /*701*/
  557.  
  558.    case FORMATVAR:
  559.      dfp = FindDrec(absrow);
  560.      if( dfp != NULL )
  561.      {
  562.       SetType(dfp);
  563.       goto Refresh;
  564.      }
  565.      break;
  566.  
  567.    case INSERTLINE:
  568.      InsDataFile( absrow, NULL );
  569.      goto Refresh;
  570.  
  571.    case DELETELINE:
  572.      DelDataFile( absrow );
  573.      goto Refresh;
  574.  
  575.    case FIND:                                                           /*701*/
  576.    case REPEATFIND:                                                     /*701*/
  577.    {                                                                    /*701*/
  578.     PEVENT Event;                                                       /*701*/
  579.                                                                         /*701*/
  580.     Event = GetCurrentEvent();                                          /*701*/
  581.     if( Event->Type != TYPE_KBD_EVENT )                                 /*701*/
  582.     {                                                                   /*701*/
  583.       if( func == FIND )                                                /*701*/
  584.        BlowBy = YES;                                                    /*701*/
  585.       else                                                              /*701*/
  586.        BoundPtr[TopLine] = 0;                                           /*701*/
  587.       goto caseBlowBy;                                                  /*701*/
  588.     }                                   /* else fall through...           701*/
  589.    }
  590. /*****************************************************************************/
  591. /* The following block of code handles the entry and editing of data objects.*/
  592. /* Typing and valid character or the EditFormula function will take us into  */
  593. /* this mode.                                                                */
  594. /*                                                                           */
  595. /*****************************************************************************/
  596. {                                       /*                                   */
  597.  uint   csroff=0;                       /* offset of cursor in entry field.  */
  598.  uint   retkey;                         /* key code returned from keystr().  */
  599.  uchar *cp;                             /* -> to error msg from ZapExpr().   */
  600.  uchar probuf[EXPRSIZE];                /* the data object expression buffer.*/
  601.                                         /*                                   */
  602.    default:                             /* case DEFAULT:                     */
  603.    case EDITFORMULA:                    /* case EDITFORMULA:                 */
  604.  
  605.     if( func != EDITFORMULA )
  606.     {
  607.      /************************************************************************/
  608.      /* We need a copy of the raw key for this function.                  701*/
  609.      /************************************************************************/
  610.      {                                                                  /*701*/
  611.       PEVENT CurrentEvent;                                              /*701*/
  612.                                                                         /*701*/
  613.       CurrentEvent = GetCurrentEvent();                                 /*701*/
  614.       key = CurrentEvent->Value;
  615.      }                                                                  /*701*/
  616.                                            /*                                   */
  617.        if( key == ESC )
  618.          break;
  619.  
  620.        key = key & 0xFF;                   /*                                   */
  621.        if( key != 0x15 )                   /* let's please the italians.        */
  622.         if( key < 0x20 ||                  /* check for wacky character and     */
  623.             key > 0x7F                     /* inform the user.                  */
  624.           )                                /*                                   */
  625.         {                                  /*                                   */
  626.          beep();
  627.          break;
  628.         }                                  /*                                   */
  629.     }                                     /*                                   */
  630.  
  631.    /* case EDITFORMULA:    */
  632.                                         /*                                   */
  633.     dfp = FindDrec(row+DataFileTop);    /* find scoping dfile node for row.  */
  634.     if(dfp)                             /* if a node is defined here then    */
  635.      memcpy(probuf,                     /* copy the expression into the   101*/
  636.             dfp->expr,                  /* expression buffer.                */
  637.             sizeof(probuf)              /*                                   */
  638.            );                           /*                                   */
  639.     else                                /* else, initialize the expression   */
  640.      *(uint *)probuf = 0;               /* buffer to double NULL.            */
  641.                                         /*                                   */
  642.     if( func != EDITFORMULA)            /* if a valid character was typed    */
  643.     {                                   /*                                   */
  644.      probuf[0] = ( uchar )key;          /* then put it the 1st char position.*/
  645.      csroff = 1;                        /*                                   */
  646. /*   csroff = 2;   */                   /*                                   */
  647.     }                                   /*                                   */
  648.                                         /*                                   */
  649.     ClrScr( row, row, vaStgPro );       /* clear the screen.                 */
  650.     putrc( row, 0, probuf );            /* display the initial expr buffer.  */
  651.     retkey = '\0';                      /* initialize retkey from keystr().  */
  652.  
  653.     while( (retkey != ENTER) && (retkey != ESC) )
  654.     {
  655.      retkey = GetString(row,0,sizeof(probuf)-1, sizeof(probuf)-1,
  656.                                                    &csroff, probuf, 0,NULL);
  657.  
  658.  
  659.      switch( retkey )                   /* now process the expression buffer.*/
  660.      {                                  /*                                   */
  661.       case ENTER:                       /* if the user said go for it, then  */
  662.        cp = ZapExpr(row+DataFileTop,    /* build a new node or process an    */
  663.                     probuf,             /* old node.                         */
  664.                     &csroff,            /*                                   */
  665.                     fp                  /*                                   */
  666.                    );                   /* tell the variable context.        */
  667.        if(cp)                           /* if there was a problem with the   */
  668.        {                                /* expression in the buffer then     */
  669.         FmtErr( cp );                   /* post a bad expression message     */
  670.         retkey = '\0';                  /* reset the retkey.                 */
  671.         beep();                         /* alert the user.                   */
  672.        }                                /*                                   */
  673.        break;                           /* and resume in the while loop.     */
  674.                                         /*                                   */
  675.       case ESC:                         /* escape out of this mess.          */
  676.         break;                          /*                                   */
  677.                                         /*                                   */
  678.       case F1:                          /* context sensitive help.           */
  679.         Help( HELP_FORMULA );
  680.         break;                          /*                                   */
  681.                                         /*                                   */
  682.       default:                          /*                                   */
  683.         beep();                         /*                                   */
  684.      }                                  /* end expression buffer processing. */
  685.      csroff = 0;                        /* set cursor offset to 1st char.    */
  686.     }                                   /* end loop til ENTER.               */
  687.                                         /*                                   */
  688.     if( retkey == ENTER )               /* if user left above loop with enter*/
  689.      if( ++row == (int)TopLine )        /* then move the cursor down a row   */
  690.       row -= 1;                         /* if possible.                      */
  691.     goto Refresh;                       /* go refresh the display.           */
  692. }                                       /* end case default & EDITFORMULA.   */
  693.  
  694.    case SETWATCHPOINTS:                                                 /*701*/
  695.     SetWps(fp);                                                         /*701*/
  696.     break;                                                              /*701*/
  697.                                                                         /*701*/
  698.    case FINDFUNCTION:                                                   /*701*/
  699.    case FINDEXECLINE:                                                   /*701*/
  700.    case NEXTFILE:                                                       /*701*/
  701.    case DROPFILE:                                                       /*701*/
  702.    case RESTART:                                                        /*701*/
  703.    case QUIT:                                                           /*701*/
  704.    case RUN:                                                            /*701*/
  705.    case SSTEP:                                                          /*701*/
  706.    case SSTEPINTOFUNC:                                                  /*701*/
  707.    case RUNTOCURSOR:                                                    /*701*/
  708.    case RUNNOSWAP:                                                      /*701*/
  709.    case SSTEPNOSWAP:                                                    /*701*/
  710.    case SSTEPINTOFUNCNOSWAP:                                            /*701*/
  711.    case RUNTOCURSORNOSWAP:                                              /*701*/
  712.    case SETCLEARBKPT:                                                   /*701*/
  713.    case SETCLEARCONDBKPT:                                               /*701*/
  714.    case CLEARALLBKPTS:                                                  /*701*/
  715.    case TOGGLEASMVIEW:                                                  /*701*/
  716.    case TOGGLEDIS:                                                      /*701*/
  717.     BoundPtr[TopLine] = 0;                                              /*701*/
  718.     goto caseBlowBy;
  719.  
  720.    /**************************************************************************/
  721.    /* Functions requiring popups cannot block the purple line from        701*/
  722.    /* blinking.                                                           701*/
  723.    /**************************************************************************/
  724.    case GETFUNCTION:                                                    /*701*/
  725.    case GETADDRESS:                                                     /*701*/
  726.    case GETFILE:                                                        /*701*/
  727.    case BROWSE:                                                         /*701*/
  728.    case SETFUNCTIONBKPT:                                                /*701*/
  729.    case SETADDRESSBKPT:                                                 /*701*/
  730.    case SETEXCEPTIONS:                                                  /*701*/
  731.    case SHOWCALLSTACK:                                                  /*701*/
  732.    case SHOWTHREADS:                                                    /*701*/
  733.    case SHOWPROCESSES:                                                  /*701*/
  734.    case SHOWDLLS:                                                       /*701*/
  735.    case REGISTERDISPLAY:                                                /*701*/
  736.    case EDITREGISTERS:                                                  /*701*/
  737.    case COREGISTERDISPLAY:                                              /*701*/
  738.    case SETCOLORS:                                                      /*701*/
  739.  
  740.     /*************************************************************************/
  741.     /* Set up a fence to prevent the display routines from writing and    701*/
  742.     /* rewriting the purple line that divides the source/assembler window 701*/
  743.     /* and the data window.                                               701*/
  744.     /*                                                                    701*/
  745.     /* Set a flag to blow by GetFuncsFromEvents so that we can come       701*/
  746.     /* directly back into the data window.                                701*/
  747.     /*************************************************************************/
  748. caseBlowBy:
  749.     BlowBy = YES;                                                       /*701*/
  750.     return((int)func);                                                  /*701*/
  751.   }                                     /* end of switch on user input func. */
  752.  }                                      /* end for(;;) loop to handle funcs. */
  753. }                                       /* end typos();                      */
  754. /*****************************************************************************/
  755. /* AppendDataFile()                                                          */
  756. /*                                                                           */
  757. /* Description:                                                              */
  758. /*   Add a record at the end of the dfile chian.                             */
  759. /*                                                                           */
  760. /* Parameters:                                                               */
  761. /*   insdfp    input - ->to the dfile structure to insert.                   */
  762. /*                                                                           */
  763. /* Return:                                                                   */
  764. /*   dfp       pointer to the appended node.                                 */
  765. /*                                                                           */
  766. /*                                                                           */
  767. /* Assumptions:                                                              */
  768. /*  insdfp points to a dfile built on the stack by the caller.               */
  769. /*  dfplast and dfpfirst in same segment to validate pointer comparison.     */
  770. /*                                                                           */
  771. /*****************************************************************************/
  772. extern DFILE *dfpfirst;
  773. extern DFILE *dfplast;
  774.  
  775.  DFILE *
  776. AppendDataFile(DFILE *insdfp)
  777. {
  778.  DFILE *dfp;                            /* -> to dfile node.                 */
  779. /*****************************************************************************/
  780. /* We first make a copy of the caller's dfile node in dynamic storage.       */
  781. /* Then we scan for the last node in the dfile chain and append the          */
  782. /* new node.                                                                 */
  783. /*                                                                           */
  784. /*****************************************************************************/
  785.  dfp = (DFILE*) Talloc(sizeof(DFILE));  /* allocate dfile node.           521*/
  786.  memcpy( dfp,insdfp, sizeof(DFILE) );   /* copy stack dfile info into it.    */
  787.                                         /*                                   */
  788.  for( dfplast=dfpfirst;                 /* update the pointer to the last    */
  789.       dfplast->next;                    /* dfile node.                       */
  790.       dfplast=dfplast->next             /*                                   */
  791.     ){;}                                /*                                   */
  792.                                         /*                                   */
  793.  if( dfplast == dfpfirst )              /* if this is first node in chain,   */
  794.   dfp->lrn = VioStartOffSet;            /* then init first rec number.    701*/
  795.  else                                   /* otherwise,                        */
  796.   dfp->lrn=dfplast->lrn +               /* use last node info to compute     */
  797.            dfplast->lines;              /* loc of this node in the data file.*/
  798.                                         /*                                   */
  799.  dfplast->next=dfp;                     /* put the node into the chain.      */
  800.  dfplast=dfp;                           /*                                   */
  801.  dfp->next = NULL;                      /*                                   */
  802.                                         /*                                   */
  803.  return(dfp);                           /* return -> to added node.          */
  804. }                                       /*                                   */
  805.  
  806. /*****************************************************************************/
  807. /* InsDataFile()                                                             */
  808. /*                                                                           */
  809. /* Description:                                                              */
  810. /*   Insert a record or node into the data file.                             */
  811. /*                                                                           */
  812. /* Parameters:                                                               */
  813. /*   rec       input - where in the data file to put this record.            */
  814. /*   insdfp    input - ->to the dfile structure to insert.                   */
  815. /*                                                                           */
  816. /* Return:                                                                   */
  817. /*   void                                                                    */
  818. /*                                                                           */
  819. /*                                                                           */
  820. /* Assumptions:                                                              */
  821. /*  insdfp points to a dfile built on the stack by the caller.               */
  822. /*                                                                           */
  823. /*****************************************************************************/
  824.  /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  825.                       /* record number in data file to make insertion (0..N) */
  826.                       /* data file record to insert, or NULL if none */
  827.  
  828.  
  829.  void
  830. InsDataFile(uint rec,DFILE *insdfp)
  831.                                         /* insert dfile after this rec.      */
  832.                                         /* -> do dfile struct to insert.     */
  833. {                                       /*                                   */
  834.  DFILE *dfp;                            /* -> to dfile node.                 */
  835.                                         /*                                   */
  836.  /****************************************************************************/
  837.  /* - scan for the insert position.                                          */
  838.  /****************************************************************************/
  839.  dfp = (DFILE*)DataFileQ ;
  840.  for( ; dfp ; dfp = dfp->next )
  841.  {
  842.   if( dfp->lrn >= rec )                 /*                                   */
  843.    dfp->lrn += 1;                       /*                                   */
  844.  }                                       /*                                   */
  845.  if( insdfp )                           /* insert a node into the dfile.     */
  846.  {                                      /*                                   */
  847.   dfp = (DFILE*) Talloc(sizeof(*dfp));  /*                                521*/
  848.   memcpy(dfp , insdfp,  sizeof(*dfp) ); /*                                101*/
  849.   dfp->lrn = rec;                       /*                                   */
  850.   QueueDrec( dfp );                     /*                                   */
  851.  }                                      /*                                   */
  852.                                         /*                                   */
  853. }                                       /*                                   */
  854.  
  855.  
  856.  void
  857. DelDataFile(uint rec)
  858. {
  859.     DFILE *dfp;
  860.  
  861.     /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  862.     dfp = (DFILE*)DataFileQ ;
  863.     for( ; dfp ; dfp = dfp->next )
  864.     {
  865.         if( dfp->lrn == rec )
  866.         {
  867.             DropDrec( dfp );
  868.             break;
  869.         }
  870.     }
  871.  
  872.     /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  873.     dfp = (DFILE*)DataFileQ ;
  874.     for( ; dfp ; dfp = dfp->next )
  875.     {
  876.         if( dfp->lrn > rec )
  877.             dfp->lrn -= 1;
  878.     }
  879. }
  880.  
  881.  
  882.  
  883.  DFILE *
  884. FindDrec(uint recno)
  885. {
  886.     DFILE *dfp;
  887.  
  888.     /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  889.     dfp = (DFILE*)DataFileQ ;
  890.     for( ; dfp ; dfp = dfp->next )
  891.     {
  892.         if( dfp->lrn == recno )
  893.             break;
  894.         if( dfp->lrn > recno )
  895.             return( NULL );
  896.     }
  897.     return( dfp );
  898. }
  899.  
  900. /*****************************************************************************/
  901. /* FindNearDrec()                                                            */
  902. /*                                                                           */
  903. /* Description:                                                              */
  904. /*   Find the dfile node containing a specific record.                       */
  905. /*                                                                           */
  906. /* Parameters:                                                               */
  907. /*   recno     input - data file record.                                     */
  908. /*                                                                           */
  909. /* Return:                                                                   */
  910. /*   dfpx      -> to dfile node or NULL.                                     */
  911. /*                                                                           */
  912. /*****************************************************************************/
  913.  DFILE *
  914. FindNearDrec(uint recno)                /* data file record number.          */
  915. {                                       /*                                   */
  916.  DFILE *dfp;                            /* dfile node pointer.               */
  917.  DFILE *dfpx;                           /* dfile last node pointer.          */
  918.                                         /*                                   */
  919.  for( dfp = DataFileQ,                  /* scan the list of nodes for recno. */
  920.       dfpx = NULL ;                     /*                                   */
  921.       dfp ;                             /*                                   */
  922.       dfp = (dfpx = dfp) -> next        /*                                   */
  923.     )                                   /*                                   */
  924.  {                                      /*                                   */
  925.   if( dfp->lrn > recno )                /*                                   */
  926.    break;                               /*                                   */
  927.  }                                      /*                                   */
  928.  return( dfpx );                        /*                                   */
  929. }                                       /* end FindNearDrec().               */
  930.  
  931.  void
  932. QueueDrec(DFILE *dfp)
  933. {
  934.     DFILE *this, *prev;                 /* was register.                  112*/
  935.  
  936.     /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  937.     prev = (DFILE*)&DataFileQ ;
  938.     this = (DFILE*)DataFileQ ;
  939.     for( ; this ; this = (prev = this) -> next  )
  940.     {
  941.         if( this->lrn == dfp->lrn )
  942.             panic(OOqdatar);
  943.         if( this->lrn > dfp->lrn )
  944.             break;
  945.     }
  946.     dfp->next = prev->next;
  947.     prev->next = dfp;
  948. }
  949.  void
  950. DropDrec(DFILE *dfp)
  951. {
  952.     DFILE *ptr;                         /* was register.                  112*/
  953.  
  954.     /* Note: This code assumes "next" is the 1st field in the DFILE struct. */
  955.     for( ptr = (DFILE*)&DataFileQ; ptr ; ptr = ptr->next ){
  956.         if( ptr->next == dfp ){
  957.             ptr->next = dfp->next;
  958.             Tfree( ( void * )dfp);                                       /*521*/
  959.             return;
  960.     }   }
  961.     panic(OOdropdr);
  962. }
  963.  
  964.  uchar*
  965. ZapExpr(uint lrn,uchar *expr,uint *csroffptr,AFILE *fp)
  966. {
  967.     uchar *cp;                          /* was register.                  112*/
  968.     DFILE *dfp;
  969.     uint new;
  970.     uint mid = fp->mid;                 /* we'll tell parseexpr() the mid.   */
  971.     uint lno = fp->csrline+fp->Nbias;   /* add Nbias to get correct lno.  310*/
  972.     int  sfi = fp->sfi;                 /* add Nbias to get correct lno.  310*/
  973.  
  974.     new = ((dfp = FindDrec(lrn)) == NULL);
  975.  
  976.     if( strlen(expr) )
  977.     {
  978. #ifdef MSH
  979.         ParseMshExpr = 1; /*This is reset by ParseExpr.*/
  980. #endif
  981.         cp = ParseExpr(expr,0x10,mid,lno, sfi);
  982.         if( cp )
  983.         {
  984.             extern int DataRecalc;                                         /*903*/
  985.             if(((uint) cp) < 30)  {/*MSH return code.*/
  986.                 int iret=((uint)cp)-10;
  987.                 switch (iret)  {
  988.                 case -3:
  989.                    break;
  990.  
  991.                 case -2:
  992.                    return((uchar *) "MSH semantic error.");
  993.  
  994.                 case -1:
  995.                    return((uchar *) "MSH syntax error.");
  996.  
  997.                 case  0:
  998.                    FmtErr((uchar *) "MSH Return code 0.");
  999.                    Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  1000.                    DataRecalc = TRUE;
  1001.                    return(NULL);
  1002.  
  1003.                 case  1:
  1004.                    FmtErr((uchar *) "MSH Return code 1.");
  1005.                    Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  1006.                    DataRecalc = TRUE;
  1007.                    return(NULL);
  1008.  
  1009.                 case  8:
  1010.                    FmtErr((uchar *) "REXX Semantic error.");
  1011.                    Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  1012.                    DataRecalc = TRUE;
  1013.                    return(NULL);
  1014.  
  1015.                 case  10:
  1016.                    FmtErr((uchar *) "REXX Return code 0.");
  1017.                    Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  1018.                    DataRecalc = TRUE;
  1019.                    return(NULL);
  1020.  
  1021.                 case  11:
  1022.                    FmtErr((uchar *) "REXX Return code non-zero.");
  1023.                    Re_Parse_Data = TRUE;      /* Set the parse var flag         244*/
  1024.                    DataRecalc = TRUE;
  1025.                    return(NULL);
  1026.  
  1027.                 default:
  1028.                    return((uchar *) "MSH Unknown return code.");
  1029.  
  1030.                 } /* endswitch */
  1031.             }
  1032.             if( !*cp ){
  1033.                 if( new )
  1034.                     dfp = (DFILE*) Talloc(sizeof(*dfp));                /*521*/
  1035.                 memcpy(dfp->expr, expr, sizeof(dfp->expr) );            /*101*/
  1036.                 dfp->lrn = lrn;
  1037.                 dfp->mid = ExprMid;
  1038.                 dfp->lno = ExprLno;
  1039.                 dfp->sfi = sfi;
  1040.                 dfp->scope = ExprScope;
  1041.                 dfp->datatype = HandleUserDefs(ExprMid,ExprTid);        /*512*/
  1042.                                         /* Get primitive typeno in case   512*/
  1043.                                         /* of primitive user defs.        512*/
  1044.                 dfp->baseaddr = ExprAddr;                               /*112*/
  1045.                 SetShowType( dfp, dfp->datatype );
  1046.                 SetShowLines( dfp );
  1047.                 if( new )
  1048.                     QueueDrec(dfp);
  1049.             }else{
  1050.                 *csroffptr = cp - expr;
  1051.                 return( (uchar*)BadExprMsg );
  1052.             }
  1053.         }else{
  1054.             *csroffptr = 0;
  1055.             return( ParseError ? ParseError : (uchar*)BadExprMsg );
  1056.         }
  1057.     }else if( dfp )
  1058.         DropDrec(dfp);
  1059.  
  1060.     return( NULL );
  1061. }
  1062.  
  1063.  
  1064. /*****************************************************************************/
  1065. /* SetType()                                                              813*/
  1066. /*                                                                        813*/
  1067. /* Description:                                                           813*/
  1068. /*                                                                        813*/
  1069. /*   Set the typing of a data window variable to be reformatted.          813*/
  1070. /*                                                                        813*/
  1071. /* Parameters:                                                            813*/
  1072. /*                                                                        813*/
  1073. /*   dfp        input - -> the dfile structure defining the data item.    813*/
  1074. /*   fp         input - -> the view structure defining the data item.     813*/
  1075. /*                                                                        813*/
  1076. /* Return:                                                                813*/
  1077. /*                                                                        813*/
  1078. /*   void                                                                 813*/
  1079. /*                                                                        813*/
  1080. /* Assumptions:                                                           813*/
  1081. /*                                                                        813*/
  1082. /*************************************************************************813*/
  1083. #define MAXTYPNAMLEN 32  /* This is the # of underscores in the userdef   813*/
  1084.                          /* slot of the menuitems[].                      813*/
  1085. #define NMENUITEMS 12                                                   /*813*/
  1086. static  uint menutypes[ NMENUITEMS] =                                   /*813*/
  1087. {                                                                       /*813*/
  1088.  0,                                     /* slot for ?.                  /*813*/
  1089.  0,                                     /* slot for hex.                /*813*/
  1090.  TYPE_CHAR,                                                             /*813*/
  1091.  TYPE_SHORT,                                                            /*813*/
  1092.  TYPE_LONG,                                                             /*813*/
  1093.  TYPE_UCHAR,                                                            /*813*/
  1094.  TYPE_USHORT,                                                           /*813*/
  1095.  TYPE_ULONG,                                                            /*813*/
  1096.  TYPE_FLOAT,                                                            /*813*/
  1097.  TYPE_DOUBLE,                                                           /*813*/
  1098.  TYPE_LDOUBLE,                                                          /*813*/
  1099.  0                                      /* slot for user defined type.   *813*/
  1100. };                                                                      /*813*/
  1101.                                                                         /*813*/
  1102. void SetType(DFILE *dfp)                                                /*813*/
  1103. {                                                                       /*813*/
  1104.  UINT      n;                                                           /*813*/
  1105.  USHORT    len;                                                         /*813*/
  1106.  USHORT    typeno;                                                      /*813*/
  1107.  UINT      item;                                                        /*813*/
  1108.  UCHAR    *cp;                                                          /*813*/
  1109.  UCHAR    *mp;                                                          /*813*/
  1110.  PULLDOWN *PullPtr;
  1111.  PEVENT    Event;
  1112.  USHORT    row;
  1113.  USHORT    col;
  1114.  
  1115.  typeno = len = 0;
  1116.  /************************************************************************813*/
  1117.  /* 1.Get a ptr to the string of menuitems. It will look like so:         813*/
  1118.  /*                                                                       813*/
  1119.  /*   index        name     string terminator                             813*/
  1120.  /*     0          .........0                                             813*/
  1121.  /*     1          .........0                                             813*/
  1122.  /*     .          .........0                                             813*/
  1123.  /*     .          .........0                                             813*/
  1124.  /*     .          .........0                                             813*/
  1125.  /*     .          .........0                                             813*/
  1126.  /*   NMENUITEMS-1 0______________________________00<--user defined slot. 813*/
  1127.  /*                .                                                      813*/
  1128.  /*                ^                                                      813*/
  1129.  /*                |                                                      813*/
  1130.  /*                 --The "0" will be replace by a "." after the first    813*/
  1131.  /*                   time through the routine.                           813*/
  1132.  /*                                                                       813*/
  1133.  /*                   There are MAXTYPNAMLEN of the underscores.          813*/
  1134.  /*                                                                       813*/
  1135.  /****************************************************************************/
  1136.  PullPtr  = GetPullPointer( 12 );                                    /*813701*/
  1137.  mp = PullPtr->labels;                                               /*813701*/
  1138.  
  1139.  /****************************************************************************/
  1140.  /* 1.Get a ptr to the beginning of the user defined slot.                813*/
  1141.  /* 2.Initialize the typeno of the user defined slot.                     813*/
  1142.  /* 3.Get the type name.                                                  813*/
  1143.  /* 4.Replace the 0 prefix in the user defined slot with a '.'.           813*/
  1144.  /* 5.Set the type of the user defined slot.                              813*/
  1145.  /* 6.Copy the type name into the user defined slot and terminate it.     813*/
  1146.  /*                                                                       813*/
  1147.  /************************************************************************813*/
  1148.  for( n=NMENUITEMS-1; n ; n--, mp += strlen(mp)+1){;}                   /*813*/
  1149.  menutypes[ NMENUITEMS-1 ] = 0;                                         /*813*/
  1150.  if( (typeno = dfp->datatype) &&                                        /*813*/
  1151.      (cp = QtypeName(dfp->mid, typeno)) )                               /*813*/
  1152.  {                                                                      /*813*/
  1153.   *mp = '.';                                                            /*813*/
  1154.   menutypes[ NMENUITEMS-1 ] = typeno;                                   /*813*/
  1155.   if( (len = *(USHORT*)cp) > MAXTYPNAMLEN )                             /*813*/
  1156.    len = MAXTYPNAMLEN;                                                  /*813*/
  1157.   memcpy(mp+1, cp+2, len );                                             /*813*/
  1158.   *(USHORT*)(mp+len+1) = 0;                                             /*813*/
  1159.  }                                                                      /*813*/
  1160.  
  1161.  /************************************************************************813*/
  1162.  /* - Define the width of the pulldown. The width will be based on the    813*/
  1163.  /*   length of the predefined primitive names or the length of the       813*/
  1164.  /*   user defined name whichever is larger.                              813*/
  1165.  /* - Define the number of entries in the pulldown.                       813*/
  1166.  /****************************************************************************/
  1167.  PullPtr->width = 11;                                                /*813701*/
  1168.  if( (len + 5) > PullPtr->width )                                       /*813*/
  1169.    PullPtr->width = len + 5;                                            /*813*/
  1170.  PullPtr->entries = NMENUITEMS;                                      /*813806*/
  1171.  
  1172.  /************************************************************************813*/
  1173.  /* Define the starting upper left row,col position for the start of      813*/
  1174.  /* the pulldown. Test for the pulldown going below the screen and adjust 813*/
  1175.  /* upwards if it does.                                                   813*/
  1176.  /************************************************************************813*/
  1177.  Event = GetCurrentEvent();                                          /*813701*/
  1178.  if( Event->Value == C_ENTER )                                       /*813701*/
  1179.  {                                                                   /*813701*/
  1180.    VioGetCurPos( &row, &col, 0 );                                    /*813701*/
  1181.    if( (row + PullPtr->entries + 3 + 1) < VideoRows )                /*813701*/
  1182.      PullPtr->row = row + 1;                                         /*813701*/
  1183.    else                                                              /*813701*/
  1184.      PullPtr->row = VideoRows - PullPtr->entries - 3;                /*813701*/
  1185.    PullPtr->col = col;                                               /*813701*/
  1186.  }                                                                   /*813701*/
  1187.  else                                                                /*813701*/
  1188.  {                                                                   /*813701*/
  1189.    PullPtr->row = 11;                                                /*813701*/
  1190.    PullPtr->col = 35;                                                /*813701*/
  1191.  }                                                                   /*813701*/
  1192.  
  1193.  /****************************************************************************/
  1194.  /* - Get the primitive item or the tag/userdef name from the user.          */
  1195.  /* - Set the type of the shower in the dfile structure for this data        */
  1196.  /*   item.                                                                  */
  1197.  /****************************************************************************/
  1198.  {
  1199.   int  MouseState = STATE_BUTTON_RELEASED;
  1200.  
  1201.   item = GetObjectPullChoice( 12, &MouseState );
  1202.  
  1203.   switch( item )
  1204.   {
  1205.    default:
  1206.     SetShowType( dfp, menutypes[item-1] );
  1207.     break;
  1208.  
  1209.    case SETCURSORPOS:
  1210.    case DONOTHING:
  1211.     break;
  1212.  
  1213.    case 1:
  1214.     GetFormatType(dfp);
  1215.     break;
  1216.  
  1217.   }
  1218.   return;
  1219.  }
  1220. }
  1221.  
  1222. /* Note: The order of "showers" and "zappers" MUST match the TGROUP type */
  1223.  
  1224. static  SHOWER  showers[] = {
  1225.                              ShowHexBytes, /*  TG_UNKNOWN                    */
  1226.                              ShowScalar  , /*  TG_SCALAR                     */
  1227.                              ShowScalar  , /*  TG_POINTER                    */
  1228.                              ShowStruct  , /*  TG_STRUCT                     */
  1229.                              ShowArray   , /*  TG_ARRAY                      */
  1230.                              ShowScalar  , /*  TG_ENUM                       */
  1231.                              ShowScalar  , /*  TG_BITFLD                     */
  1232.                              ShowConstant, /*  TG_CONSTANT                   */
  1233.                              ShowClass   , /*  TG_CLASS                      */
  1234.                              ShowScalar    /*  TG_REF                        */
  1235.                             };
  1236. #ifdef MSH
  1237. static  FINDER  finders[] = {
  1238.                              FindHexBytes, /*  TG_UNKNOWN                    */
  1239.                              FindScalar  , /*  TG_SCALAR                     */
  1240.                              FindScalar  , /*  TG_POINTER                    */
  1241.                              FindStruct  , /*  TG_STRUCT                     */
  1242.                              FindArray   , /*  TG_ARRAY                      */
  1243.                              FindScalar  , /*  TG_ENUM                       */
  1244.                              FindScalar  , /*  TG_BITFLD                     */
  1245.                              FindConstant  /*  TG_CONSTANT                243*/
  1246.                             };
  1247. #endif
  1248. static  ZAPPER   zappers[] =
  1249. {
  1250.   ZapHexBytes ,                         /* TG_UNKNOWN                      */
  1251.   ZapScalar   ,                         /* TG_SCALAR                       */
  1252.   ZapPointer  ,                         /* TG_POINTER                      */
  1253.   ZapStruct   ,                         /* TG_STRUCT                       */
  1254.   ZapArray    ,                         /* TG_ARRAY                        */
  1255.   NULL        ,                         /* TG_ENUM                         */
  1256.   NULL        ,                         /* TG_BITFLD                       */
  1257.   NULL        ,                         /* TG_CONSTANT                     */
  1258.   ZapClass                              /* TG_CLASS                        */
  1259. };
  1260.  
  1261.  void
  1262. SetShowType( DFILE *dfp, uint tid )
  1263. {
  1264.     uint  tgroup = QtypeGroup(dfp->mid, tid);
  1265.  
  1266.     dfp->showtype = tid;
  1267.  
  1268.     if( (dfp->datatype != ADDRESS_CONSTANT) &&
  1269.       (dfp->datatype != VALUE_CONSTANT))/* if data type is not constant   243*/
  1270.     {                                   /* then set the required shower   243*/
  1271.       dfp->shower = showers[tgroup];    /* zapper, and finder.            243*/
  1272. #ifdef MSH
  1273.       dfp->finder = finders[tgroup];
  1274. #endif
  1275.       dfp->zapper = zappers[tgroup];    /*                                243*/
  1276.     }                                   /*                                243*/
  1277.     else                                /*                                243*/
  1278.     {                                   /* if data type is constant set   243*/
  1279.       dfp->shower = ShowConstant;       /* the shower to showconstant &   243*/
  1280. #ifdef MSH
  1281.       dfp->finder = FindConstant;       /* the finder to findconstant &   243*/
  1282. #endif
  1283.       dfp->zapper = NULL;               /* zapper to null.                243*/
  1284.     }                                   /*                                243*/
  1285.  
  1286. }
  1287. /*****************************************************************************/
  1288. /*SetShowLines()                                                             */
  1289. /*                                                                           */
  1290. /* Description:                                                              */
  1291. /*   Insert "lines" value into the dfile node.                               */
  1292. /*                                                                           */
  1293. /* Parameters:                                                               */
  1294. /*   dfp       input - -> to the dfile node we are working on.               */
  1295. /*                                                                           */
  1296. /* Return:                                                                   */
  1297. /*   void                                                                    */
  1298. /*                                                                           */
  1299. /* Assumptions:                                                              */
  1300. /*  dfp is valid and not NULL.                                               */
  1301. /*                                                                           */
  1302. /*****************************************************************************/
  1303.  int
  1304. SetShowLines(DFILE *dfp)
  1305. {
  1306.  uint   atomtype;                       /* type of array element.         101*/
  1307.  uint   atomsize;                       /* size of array element in bits.    */
  1308.  Trec  *tp;                             /* -> to type record for a typeno.   */
  1309.  
  1310. /*****************************************************************************/
  1311. /* We want to get the number of lines needed to display this data object.  We*/
  1312. /* will assume 1 line and make adjustments as necessary based on the complex */
  1313. /* data type.  Char arrays will be treated as strings and we will have one   */
  1314. /* line for each 16 bytes of string.                                         */
  1315. /*                                                                           */
  1316. /**u**************************************************************************/
  1317.   if( (dfp->datatype <  512) ||         /* handle primitive and constant  243*/
  1318.     (dfp->datatype == VALUE_CONSTANT)|| /* data types                     243*/
  1319.     (dfp->datatype == ADDRESS_CONSTANT))/*                                243*/
  1320.    return(dfp->lines = 1);              /* assume 1 line.                    */
  1321.                                         /* handle complex data types.        */
  1322.   tp=QbasetypeRec(dfp->mid,dfp->datatype); /* get base type record.          */
  1323.   if( !tp )                             /*                                   */
  1324.    return(0);                           /*                                   */
  1325.   switch(tp->RecType)                   /* handle each type individually. 813*/
  1326.   {                                     /*                                   */
  1327.    case T_CLASS:
  1328.    {
  1329.     dfp->lines = ((TD_CLASS*)tp)->NumMembers;
  1330.  
  1331.     if( GetViewMemFncs() == FALSE )
  1332.     {
  1333.      dfp->lines = GetLinesNoMemFncs( dfp->mid, tp );
  1334.     }
  1335.    }
  1336.    break;
  1337.  
  1338.    case T_STRUCT:                       /* type 121                          */
  1339.     dfp->lines = ((TD_STRUCT*)tp)->NumMembers;                          /*813*/
  1340.     break;                              /*                                   */
  1341.                                         /*                                   */
  1342.    case T_BITFLD:                       /* type 92.                          */
  1343.     dfp->lines = 1;                     /* assume 1 line.                    */
  1344.     break;                              /*                                   */
  1345.                                         /*                                   */
  1346.    case T_ARRAY:                        /* type 120.                         */
  1347.     atomtype = ((TD_ARRAY*)tp)->ElemType;                               /*813*/
  1348.     atomtype =  HandleUserDefs(dfp->mid,atomtype);                      /*813*/
  1349.     if(atomtype == TYPE_CHAR ||         /* if the type is char or            */
  1350.        atomtype == TYPE_UCHAR           /* unsigned char then                */
  1351.       )                                 /*                                   */
  1352.     {                                   /* treat the array as a string.      */
  1353.      uint nbytes;                       /* temp for array bytes.             */
  1354.      nbytes = ((TD_ARRAY*)tp)->ByteSize;                                /*813*/
  1355.      dfp->lines = nbytes/16;            /* this is base number of lines.     */
  1356.      if( nbytes-dfp->lines*16 > 0 )     /* if there is a vestigial, then     */
  1357.       dfp->lines += 1;                  /* add a line for it.                */
  1358.     }                                   /*                                   */
  1359.     else                                /* if the type is NOT char, then     */
  1360.     {                                   /*                                   */
  1361.      atomsize = QtypeSize(dfp->mid,     /* get the number of chars in the    */
  1362.                          atomtype);     /* string.                           */
  1363.      dfp->lines = ((TD_ARRAY*)tp)->ByteSize;                            /*813*/
  1364.      dfp->lines /= atomsize;            /* compute number of lines to display*/
  1365.     }                                   /*                                   */
  1366.     break;                              /* end case T_ARRAY:                 */
  1367.                                         /*                                   */
  1368.    case T_TYPDEF:                       /* type  93                          */
  1369.    case T_PROC  :                       /*      117                          */
  1370.    case T_PTR   :                       /*      122                          */
  1371.    case T_ENUM  :                       /*      123                          */
  1372.    case T_LIST  :                       /*      127                          */
  1373.    case T_NULL  :                       /*      128                          */
  1374.    default      :                       /*                                   */
  1375.     dfp->lines = 1;                     /*                                   */
  1376.     break;                              /*                                   */
  1377.   }                                     /*                                   */
  1378.   return(dfp->lines);                   /*                                   */
  1379. }                                       /* end SetShowLines()                */
  1380.  
  1381. /*****************************************************************************/
  1382. /* SetDataViewCsr()                                                       701*/
  1383. /*                                                                        701*/
  1384. /* Description:                                                           701*/
  1385. /*   Set the cursor position in the data window when a mouse event        701*/
  1386. /*   occurs.                                                              701*/
  1387. /*                                                                        701*/
  1388. /* Parameters:                                                            701*/
  1389. /*                                                                        701*/
  1390. /* Return:                                                                701*/
  1391. /*                                                                        701*/
  1392. /* Assumptions                                                            701*/
  1393. /*                                                                        701*/
  1394. /*****************************************************************************/
  1395. void  SetDataViewCsr( )                                                 /*701*/
  1396. {                                                                       /*701*/
  1397.   PEVENT  Event;                                                        /*701*/
  1398.                                                                         /*701*/
  1399.   Event = GetCurrentEvent();                                            /*701*/
  1400.   if( Event->Row >= TopLine )                                           /*701*/
  1401.    stgcsr[iview].row = TopLine-1;                                              /*701*/
  1402.   else if( Event->Row < VioStartOffSet )                                /*701*/
  1403.    stgcsr[iview].row = VioStartOffSet;                                         /*701*/
  1404.   else                                                                  /*701*/
  1405.    stgcsr[iview].row = Event->Row;                                             /*701*/
  1406. }                                                                       /*701*/
  1407.