home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / c-kermit / ckmwin.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  18KB  |  695 lines

  1. /* $Id: ckmwin.c,v 1.2 91/12/27 21:51:47 fdc Exp $
  2.  * $Source: /uw/mackermit/RCS/ckmwin.c,v $
  3.  *------------------------------------------------------------------
  4.  * $Log:    ckmwin.c,v $
  5.  * Revision 1.2  91/12/27  21:51:47  fdc
  6.  * Change fatal to macfatal.
  7.  * 
  8.  * Revision 1.1  91/10/30  23:06:06  rick
  9.  * Initial revision
  10.  * 
  11.  *------------------------------------------------------------------
  12.  * $Endlog$
  13.  */
  14.  
  15. /*
  16.  * cmkwin.c
  17.  * Common window handling routines for the command and remote
  18.  * windows.
  19.  * 
  20.  * R. Watson
  21.  * The University of Texas
  22.  * 12-Sep-1991
  23.  */
  24. /*
  25.   Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New
  26.   York.  Permission is granted to any individual or institution to use this
  27.   software as long as it is not sold for profit.  This copyright notice must be
  28.   retained.  This software may not be included in commercial products without
  29.   written permission of Columbia University.
  30. */
  31. #include "ckcdeb.h"
  32. #include "ckcasc.h"
  33. #include "ckcker.h"
  34. #include "ckmdef.h"            /* General Mac defs */
  35. #include "ckmres.h"            /* Resource file defs */
  36. #include "ckmwin.h"            /* Window handling defs */
  37. #include "ckmcon.h"
  38. #include "ckmptp.h"            /* Prototypes */
  39.  
  40. #define LMARGIN 4            /* left margin in teviewr */
  41.  
  42. struct cmdw *cmdwl = NULL;        /* list of TE windows */
  43. struct cmdw *rcmdw = NULL;        /* remote command window */
  44. struct cmdw *prntw = NULL;        /* local "printer" window */
  45. struct cmdw *activecmdw = NULL;        /* cmdw if window is active */
  46. struct cmdw *docmdw;            /* cmdw for rdoscroll() */
  47. int cmdinterminal = FALSE;        /* cmd output to term window if true */
  48.  
  49. extern MenuHandle menus[];
  50. extern int connected;
  51. extern Boolean have_128roms;    /* actually, a Mac + or better */
  52. extern Cursor *textcurs, *normcurs, *watchcurs;    /* mouse cursor shapes */
  53. extern Cursor *lastCursor;        /* what we set the cursor to last */
  54.  
  55. void cmdwSelectWindow (struct cmdw *cmdw);
  56. void updateTakeMenu (struct cmdw *cmdw);
  57. void setWindowLoc (int id);
  58.  
  59. /*
  60.  * initcmdw()
  61.  * Initialize a TE based window.
  62.  */
  63. struct cmdw *initcmdw (id, vscroll, hscroll)
  64.     int id;                /* window id */
  65.     int vscroll;            /* vertical scroll CTRL id */
  66.     int hscroll;            /* horiz scroll CTRL id */
  67. {
  68.     struct cmdw *cmdw;
  69.     GrafPtr savePort;
  70.     static int ourid = 1;        /* unique id of this cmdw */
  71.  
  72.     GetPort (&savePort);        /* save current port */
  73.  
  74.     cmdw = (struct cmdw *)malloc(sizeof(struct cmdw));
  75.     if (!cmdw)
  76.     macfatal("No memory for cmdw", 0);
  77.     bzero((char *)cmdw, sizeof(struct cmdw));
  78.     cmdw->next = cmdwl;            /* link on list */
  79.     cmdwl = cmdw;
  80.     cmdw->id = ourid++;            /* allocate unique id */
  81.  
  82.     setWindowLoc(id);
  83. #ifdef notdef
  84.     cmdw->window = GetNewWindow(id, (Ptr) &cmdw->WRec, (WindowPtr) 0L);
  85. #else
  86.     cmdw->window = GetNewWindow(id, (Ptr) 0L, (WindowPtr) -1L);
  87. #endif
  88.     SetPort (cmdw->window);        /* set new stuff */
  89.     TextFont (monaco);
  90.     TextSize (9);
  91.  
  92.     /* min and max are defined in the resource declaration */
  93.     cmdw->vscroll = GetNewControl(vscroll, cmdw->window);
  94.     cmdw->hscroll = GetNewControl(hscroll, cmdw->window); 
  95.  
  96.     sizescrollbars(cmdw);        /* make controls adjust to wind size */
  97.     sizeteviewr(cmdw);            /* resize text edit rect */
  98.  
  99.     /* create text edit portion */
  100.     cmdw->teh = TENew (&cmdw->teviewr, &cmdw->teviewr);
  101.     HLock((Handle)cmdw->teh);
  102.     (*cmdw->teh)->crOnly = -1;    /* only break lines at CR */
  103.  
  104.     cmdw->theorigin.h = 0;
  105.     cmdw->theorigin.v = 0;
  106.  
  107.     SetPort (savePort);        /* restore previous port */
  108.  
  109.     return cmdw;
  110. }
  111.  
  112.  
  113. /****************************************************************************/
  114. /* sizescrollbars - called when window is created and after a window grow */
  115. /*                      sequence to resize the scroll window's bars. */
  116. /****************************************************************************/
  117. sizescrollbars (cmdw)
  118.     struct cmdw *cmdw;
  119. {
  120.     register Rect *r;
  121.  
  122.     r = &cmdw->window->portRect;    /* window size */
  123.     HideControl (cmdw->vscroll);
  124.     HideControl (cmdw->hscroll);
  125.  
  126.     MoveControl (cmdw->vscroll, r->right - 15, r->top - 1);
  127.     SizeControl (cmdw->vscroll, 16, r->bottom - r->top - 13);
  128.  
  129.     MoveControl (cmdw->hscroll, r->left - 1, r->bottom - 15);
  130.     SizeControl (cmdw->hscroll, r->right - r->left - 13, 16);
  131.  
  132.     ShowControl (cmdw->vscroll);
  133.     ShowControl (cmdw->hscroll);
  134. }
  135.  
  136.  
  137. /****************************************************************************/
  138. /****************************************************************************/
  139. sizeteviewr (cmdw)
  140.     struct cmdw *cmdw;
  141. {
  142.     cmdw->teviewr = cmdw->window->portRect;
  143.     cmdw->teviewr.left = cmdw->teviewr.left + LMARGIN;
  144.     cmdw->teviewr.right = cmdw->teviewr.right - 15;
  145.     cmdw->teviewr.bottom = cmdw->teviewr.bottom - 15;
  146.  
  147.  
  148. /****************************************************************************/
  149. /****************************************************************************/
  150. void
  151. growremwindow (cmdw, p)
  152.     struct cmdw *cmdw;
  153.     Point p;
  154. {
  155.     long gr;
  156.     int height;
  157.     int width;
  158.     Rect growRect;
  159.     GrafPtr savePort;
  160.  
  161.     growRect = qd.screenBits.bounds;
  162.     growRect.top = 50;        /* minimal horizontal size */
  163.     growRect.left = 50;        /* minimal vertical size */
  164.  
  165.     gr = GrowWindow (cmdw->window, p, &growRect);
  166.  
  167.     if (gr == 0)
  168.     return;
  169.     height = HiWord (gr);
  170.     width = LoWord (gr);
  171.  
  172.     SizeWindow (cmdw->window, width, height, FALSE); /* resize the window */
  173.     sizescrollbars(cmdw);        /* size the scroll bars */
  174.     sizeteviewr(cmdw);            /* size for text edit */
  175.     (*cmdw->teh)->viewRect = cmdw->teviewr; /* set it */
  176.  
  177.     GetPort (&savePort);
  178.     SetPort (cmdw->window);
  179.     InvalRect (&cmdw->window->portRect);/* invalidate whole window rectangle */
  180.     SetPort (savePort);
  181. }
  182.  
  183.  
  184. /****************************************************************************/
  185. /****************************************************************************/
  186. rcmdwhide (cmdw)
  187.     struct cmdw *cmdw;
  188. {
  189.     HideWindow(cmdw->window);        /* hide it */
  190.     HideControl(cmdw->vscroll);        /* these will be shown on select */
  191.     HideControl(cmdw->hscroll);
  192. }
  193.  
  194.  
  195. /*
  196.  * rrcmdwshow
  197.  * Show the remote window.
  198.  * Here so ckuus4.c doesn't need to know about window details.
  199.  */
  200. rrcmdwshow()
  201. {
  202.     rcmdwshow(rcmdw);
  203. }
  204.  
  205.  
  206. /****************************************************************************/
  207. /****************************************************************************/
  208. rcmdwshow (cmdw)
  209.     struct cmdw *cmdw;
  210. {
  211.     ShowWindow (cmdw->window);        /* show it */
  212.     cmdwSelectWindow (cmdw);
  213. }
  214.  
  215.  
  216. /****************************************************************************/
  217. /* rcdactivate - activate event on rcd window */
  218. /****************************************************************************/
  219. rcdactivate (cmdw, mod)
  220.     struct cmdw *cmdw;
  221.     int mod;
  222. {
  223.     DrawGrowIcon(cmdw->window);
  224.     if (mod & activeFlag) {
  225.     TEFromScrap();
  226.     TEActivate(cmdw->teh);
  227.     ShowControl (cmdw->vscroll);
  228.     ShowControl (cmdw->hscroll);
  229.     DisableItem(menus[EDIT_MENU], UNDO_EDIT);
  230.     updateTakeMenu(cmdw);
  231.     activecmdw = cmdw;
  232.     } else {
  233.     ZeroScrap();
  234.     TEToScrap();
  235.     TEDeactivate(cmdw->teh);
  236.     HideControl(cmdw->vscroll);
  237.     HideControl(cmdw->hscroll);
  238.     EnableItem(menus[EDIT_MENU], UNDO_EDIT);
  239.     activecmdw = NULL;
  240.     }
  241. }
  242.  
  243.  
  244. /****************************************************************************/
  245. /****************************************************************************/
  246. pascal void
  247. rdoscroll (WHICHCONTROL, THECODE)
  248.     ControlHandle WHICHCONTROL;
  249.     short THECODE;
  250. {
  251.     register int amount = 0, val, max;
  252.  
  253.     if (THECODE == inUpButton)
  254.     amount = -1;
  255.     if (THECODE == inDownButton)
  256.     amount = 1;
  257.     if (amount == 0)
  258.     return;
  259.     val = GetCtlValue (WHICHCONTROL) + amount;
  260.     max = GetCtlMax (WHICHCONTROL);
  261.     if ((val < 0) || (val > max))
  262.     return;
  263.     SetCtlValue (WHICHCONTROL, GetCtlValue (WHICHCONTROL) + amount);
  264.     scrollbits(docmdw);
  265. }                /* rdoscroll */
  266.  
  267.  
  268. /****************************************************************************/
  269. /* rcdkey - key event on rcd window */
  270. /****************************************************************************/
  271. rcdkey (cmdw, evt)
  272.     struct cmdw *cmdw;
  273.     EventRecord *evt;
  274. {
  275.     int i, y;
  276.     int nl;                /* num lines in window */
  277.     unsigned char the_char;
  278.     TEPtr ptr;
  279.     Point pt;
  280.     
  281.     the_char = evt->message & charCodeMask;
  282.     TEKey(the_char, cmdw->teh);
  283.     cmdw->flags |= CMDWF_MODIFIED;    /* buffer is modified */
  284.  
  285.     if (the_char == '\n')        /* if extending number of lines */
  286.     setscrollmax(cmdw);
  287.  
  288.     /*
  289.      * Find location of insertion point.  
  290.      * TODO: Do this for horizontal locations also.  Will need to
  291.      * use TextWidth() I think.
  292.      */
  293.     ptr = *cmdw->teh;
  294.     for (i = ptr->nLines; i >= 0; i--)    /* set i to line number */
  295.     if (ptr->selEnd >= ptr->lineStarts[i])
  296.         break;
  297.     y = (i - GetCtlValue(cmdw->vscroll)) * ptr->lineHeight;
  298.     pt.h = LMARGIN;
  299.     pt.v = y + ptr->lineHeight/2;
  300.  
  301.     nl = ((ptr->viewRect.bottom-ptr->viewRect.top) / ptr->lineHeight);
  302.     if (!PtInRect(pt, &cmdw->teviewr)) {
  303.     if (pt.v > cmdw->teviewr.bottom) { /* if past bottom */
  304.         SetCtlValue(cmdw->vscroll, i-nl+1);
  305.         scrollbits(cmdw);
  306.     } else {            /* must be above top */
  307.         SetCtlValue(cmdw->vscroll, i);
  308.         scrollbits(cmdw);
  309.     }
  310.     }
  311. }
  312.  
  313. /****************************************************************************/
  314. /* rcdmouse - mouse event on rcd window */
  315. /****************************************************************************/
  316. rcdmouse (cmdw, evt)
  317.     struct cmdw *cmdw;
  318.     EventRecord *evt;
  319. {
  320.     int actrlcode;
  321.     int t;
  322.     ControlHandle acontrol;
  323.     GrafPtr savePort;
  324.     
  325.     GetPort (&savePort);    /* save the current port */
  326.     SetPort (cmdw->window);
  327.  
  328.     GlobalToLocal (&evt->where);/* convert to local */
  329.     if (PtInRect (evt->where, &cmdw->teviewr)) {    /* in text edit? */
  330.     TEClick(evt->where, (evt->modifiers) & shiftKey, cmdw->teh);
  331.     SetPort (savePort);    /* restore previous port */
  332.     return;            /* yes, do nothing */
  333.     }
  334.     actrlcode = FindControl (evt->where, cmdw->window, &acontrol);
  335.     switch (actrlcode) {
  336.       case inUpButton:
  337.       case inDownButton:
  338.     docmdw = cmdw;            /* save pointer for rdoscroll */
  339.     t = TrackControl (acontrol, evt->where, (ProcPtr) rdoscroll);
  340.     break;
  341.  
  342.       case inPageUp:
  343.     pagescroll (cmdw, actrlcode, -10, acontrol);
  344.     break;
  345.  
  346.       case inPageDown:
  347.     pagescroll (cmdw, actrlcode, 10, acontrol);
  348.     break;
  349.  
  350.       case inThumb:
  351.     t = TrackControl (acontrol, evt->where, (ProcPtr) NIL);
  352.     scrollbits(cmdw);
  353.     break;
  354.     }
  355.     SetPort (savePort);        /* restore previous port */
  356. }                /* rcdmouse */
  357.  
  358. rcd_cut(cmdw)
  359.     struct cmdw *cmdw;
  360. {
  361.     invalidate_scr_clip();
  362.     TECut(cmdw->teh);
  363. }
  364.  
  365. rcd_copy(cmdw)
  366.     struct cmdw *cmdw;
  367. {
  368.     invalidate_scr_clip();
  369.     TECopy(cmdw->teh);
  370. }
  371.  
  372. rcd_paste(cmdw)
  373.     struct cmdw *cmdw;
  374. {
  375.     /*
  376.      * If the internal clip is newer, it will have been already copied to the
  377.      * global clip, so this will just work.
  378.      */
  379.     TEPaste(cmdw->teh);
  380. }
  381.  
  382. rcd_clear(cmdw)
  383.     struct cmdw *cmdw;
  384. {
  385.     TEDelete(cmdw->teh);
  386. }
  387.  
  388.  
  389. /****************************************************************************/
  390. /****************************************************************************/
  391. rcdupdate (cmdw)
  392.     struct cmdw *cmdw;
  393. {
  394.     EraseRect(&cmdw->teviewr);
  395.     TEUpdate(&cmdw->teviewr, cmdw->teh);
  396.     DrawGrowIcon(cmdw->window);
  397.     DrawControls(cmdw->window);
  398. }
  399.  
  400.  
  401. /****************************************************************************/
  402. /****************************************************************************/
  403. scrollbits (cmdw)
  404.     struct cmdw *cmdw;
  405. {
  406.     Point oldorigin;
  407.     int dh, dv;
  408.  
  409.     oldorigin = cmdw->theorigin;
  410.     cmdw->theorigin.h = GetCtlValue(cmdw->hscroll);
  411.     cmdw->theorigin.v = GetCtlValue(cmdw->vscroll);
  412.     dh = (oldorigin.h - cmdw->theorigin.h);
  413.     dv = (oldorigin.v - cmdw->theorigin.v) * (*cmdw->teh)->lineHeight;
  414.     TEScroll (dh, dv, cmdw->teh);
  415. }
  416.  
  417.  
  418. /****************************************************************************/
  419. /****************************************************************************/
  420. rcdwscroll (cmdw)
  421.     struct cmdw *cmdw;
  422. {
  423.     GrafPtr savePort;
  424.  
  425.     GetPort (&savePort);
  426.     SetPort (cmdw->window);        /* our window is the port */
  427.     setscrollmax (cmdw);        /* set the max */
  428.     SetCtlValue (cmdw->vscroll, GetCtlMax (cmdw->vscroll)); /* & set control */
  429.     scrollbits(cmdw);            /* do scroll */
  430.     SetPort (savePort);            /* back to old port */
  431. }
  432.  
  433.  
  434. /****************************************************************************/
  435. /****************************************************************************/
  436. pagescroll (cmdw, code, amount, ctrlh)
  437.     struct cmdw *cmdw;
  438.     ControlHandle ctrlh;
  439. {
  440.     Point myPt;
  441.  
  442.     do {
  443.     GetMouse (&myPt);
  444.     if (TestControl (ctrlh, myPt) != code)
  445.         continue;
  446.     SetCtlValue (ctrlh, GetCtlValue (ctrlh) + amount);
  447.     scrollbits(cmdw);
  448.     } while (StillDown ());
  449. }
  450.  
  451.  
  452. /****************************************************************************/
  453. /* setscrollmax - sets the vertical scroll control's maximum value.
  454.  *                    The max is the total number of lines in the te record
  455.  *                    minus the number of lines that can be displayed in the
  456.  *                    viewing rectangle (plus 1).  This makes the max setting
  457.  *                    of the control result in the display of the last chunk
  458.  *                    of text.
  459.  */
  460. /****************************************************************************/
  461. int setscrollmax (cmdw)
  462.     struct cmdw *cmdw;
  463. {
  464.     int maxv;
  465.  
  466.     maxv = (*cmdw->teh)->nLines + 1 -
  467.     (((*cmdw->teh)->viewRect.bottom-(*cmdw->teh)->viewRect.top) / 
  468.      (*cmdw->teh)->lineHeight);
  469.     if (maxv < 0)            /* for less than one page */
  470.     maxv = 0;            /* use this value as max */
  471.     SetCtlMax (cmdw->vscroll, maxv);    /* set it... */
  472.     return maxv;
  473. }                    /* setscrollmax */
  474.  
  475.  
  476. /****************************************************************************/
  477. /* PWP: trimcon(length) should be called before TEInsert()ing <length>    */
  478. /*      number of bytes.  This function checks to see if there is enough  */
  479. /*    room for this many characters, and deletes a bit from the beginning  */
  480. /*    if there isn't space.  */
  481. /*      Returns 1 if it trimmed, 0 if it didn't.  */
  482. /****************************************************************************/
  483. int
  484. trimcon(cmdw, l)
  485.     struct cmdw *cmdw;
  486.     register int l;
  487. {
  488.     if (cmdw) {
  489.     if (((*cmdw->teh)->teLength + l) > TE_TOOBIG) {
  490.         TESetSelect(0, TE_TRIM, cmdw->teh);/* select beginning part */
  491.         TEDelete(cmdw->teh);    /* nuke it */
  492.         /* and make insertion point at end again */
  493.         TESetSelect(TE_MAX, TE_MAX, cmdw->teh);
  494.         return (1);
  495.     }
  496.     }
  497.     return (0);
  498. }
  499.  
  500.  
  501. /*
  502.  * cmdwbywindow
  503.  * Find a cmdw given a WindowPtr
  504.  */
  505. struct cmdw *cmdwbywindow (WindowPtr w)
  506. {
  507.     struct cmdw *cmdw;
  508.  
  509.     cmdw = cmdwl;
  510.     while (cmdw) {
  511.     if (cmdw->window == w)
  512.         break;
  513.     cmdw = cmdw->next;
  514.     }
  515.     return(cmdw);
  516. }
  517.  
  518.  
  519. /*
  520.  * termwbywindow
  521.  * Find a termw given a WindowPtr
  522.  */
  523. struct termw *termwbywindow (WindowPtr w)
  524. {
  525.     struct termw *termw;
  526.     extern struct termw *termwl;
  527.  
  528.     termw = termwl;
  529.     while (termw) {
  530.     if (termw->window == w)
  531.         break;
  532.     termw = termw->next;
  533.     }
  534.     return(termw);
  535. }
  536.  
  537.  
  538. /*
  539.  * cmdwSelectWindow
  540.  */
  541. void cmdwSelectWindow (struct cmdw *cmdw)
  542. {
  543.     SelectWindow(cmdw->window);
  544.     updateTakeMenu(cmdw);
  545. }
  546.  
  547.  
  548. /*
  549.  * updateTakeMenu
  550.  */
  551. void updateTakeMenu (struct cmdw *cmdw)
  552. {
  553.     char scratch[255];
  554.  
  555.     /*
  556.      * If this is a file window, update and enable the Take
  557.      * Command from Window menu item.  Otherwise, disable
  558.      * the item.
  559.      */
  560.     if (cmdw->flags & CMDWF_FILE) {
  561.     if (have_128roms) {
  562.         sprintf(scratch, "Take \"%s\"", p2c_tmp(cmdw->wname));
  563.         c2pstr(scratch);
  564.         DelMenuItem(menus[FILE_MENU], TAKEW_FIL);
  565.         InsMenuItem(menus[FILE_MENU], scratch, TAKEW_FIL-1);
  566.     }
  567.     EnableItem(menus[FILE_MENU], TAKEW_FIL);
  568.     } else {
  569.     DisableItem(menus[FILE_MENU], TAKEW_FIL);
  570.     }
  571. }
  572.  
  573.  
  574. /*
  575.  * kSelectWindow
  576.  */
  577. VOID kSelectWindow (WindowPtr w)
  578. {
  579.     SelectWindow(w);
  580.  
  581.     /*
  582.      * Selecting the terminal window or the command window implicitly
  583.      * connects or disconnects us.
  584.      */
  585.     if (ttermw->window == w)
  586.     connected = TRUE;
  587.     else if (ctermw->window == w)
  588.     connected = FALSE;
  589.  
  590.     DisableItem(menus[FILE_MENU], TAKEW_FIL);
  591. }
  592.  
  593.  
  594. /*
  595.  * kShowWindow
  596.  * Only call ShowWindow if window is not showing.
  597.  */
  598. VOID kShowWindow (struct termw *termw)
  599. {
  600.     if (termw->showing)
  601.     return;
  602.  
  603.     ShowWindow(termw->window);
  604.  
  605.     termw->showing = TRUE;
  606. }
  607.  
  608.  
  609. /*
  610.  * kHideWindow
  611.  * Only call HideWindow if window is showing.
  612.  */
  613. VOID kHideWindow (struct termw *termw)
  614. {
  615.     if (!termw->showing)
  616.     return;
  617.  
  618.     HideWindow(termw->window);
  619.  
  620.     termw->showing = FALSE;
  621. }
  622.  
  623.  
  624. /*
  625.  * setWindowLoc
  626.  * Set initial location of a window we're about to create.
  627.  */
  628. #define TCORNER 40            /* corner of first window */
  629. #define LCORNER 5
  630. #define TINC 15                /* how far to move each window */
  631. #define LINC 10
  632.  
  633. void setWindowLoc (int id)
  634. {
  635.     int ldiff, tdiff;
  636.     Handle wh;                /* window handle */
  637.     Rect *rectp;
  638.     static int tcorner = TCORNER;    /* window (top, left) corner */
  639.     static int lcorner = LCORNER;
  640.     static int n = 0;
  641.  
  642.     /*
  643.      * Wrap window location after so many windows.
  644.      */
  645.     if (++n > 9) {
  646.     n = 0;
  647.     tcorner = TCORNER + TINC;    /* don't re-use first slot */
  648.     lcorner = LCORNER + LINC;
  649.     }
  650.  
  651.     /*
  652.      * Get the window resource and modify the location.
  653.      * Since it will already be in memory, GetNewWindow will use
  654.      * the values we just set.
  655.      */
  656.     wh = GetResource('WIND', id);
  657.     rectp = (Rect *)*wh;
  658.     ldiff = lcorner - rectp->left;
  659.     tdiff = tcorner - rectp->top;
  660.     rectp->top = tcorner;
  661.     rectp->left = lcorner;
  662.     rectp->bottom = rectp->bottom + tdiff;
  663.     rectp->right = rectp->right + ldiff;
  664.     tcorner += TINC;
  665.     lcorner += LINC;
  666. }
  667.  
  668.  
  669. /*
  670.  * cmdwUpdateCursor
  671.  * Update cursor when a cmdw window is the front window.
  672.  */
  673. void cmdwUpdateCursor (struct cmdw *cmdw)
  674. {
  675.     Point MousePt;
  676.     GrafPtr savePort;
  677.     Cursor *curs;
  678.  
  679.     GetPort (&savePort);
  680.     SetPort (cmdw->window);
  681.  
  682.     GetMouse(&MousePt);
  683.  
  684.     if (PtInRect(MousePt, &cmdw->teviewr))
  685.     curs = textcurs;
  686.     else
  687.     curs = normcurs;
  688.  
  689.     if  (lastCursor!= curs) {
  690.     SetCursor(curs);
  691.     lastCursor = curs;
  692.     }
  693. }
  694.