home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / applic / ncsa / Mac / Telnet2.6 / prerelease / d3 / Telnet2.6.1d3.src.sit.hqx / Telnet 2.6.1d3 source / source / main / menuseg.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-19  |  37.7 KB  |  1,385 lines

  1. /****************************************************************
  2. *    NCSA Telnet for the Macintosh                                *
  3. *                                                                *
  4. *    National Center for Supercomputing Applications                *
  5. *    Software Development Group                                    *
  6. *    152 Computing Applications Building                            *
  7. *    605 E. Springfield Ave.                                        *
  8. *    Champaign, IL  61820                                        *
  9. *                                                                *
  10. *    Copyright (c) 1986-1992,                                    *
  11. *    Board of Trustees of the University of Illinois                *
  12. *****************************************************************
  13. *
  14. *    Menu Handling and initialization code.
  15. *
  16. *    
  17. *    Revisions:
  18. *    7/92 Telnet 2.6 initial version: reorganized defines, put all stray globals in a struct, and
  19. *                put all cursors in a nice array.  Moved some routines to other places -    Scott Bulmahn            
  20. *
  21. *    6/94 Added support for Keypad and Function menus - Carl Bell (Baylor U.)
  22. */
  23.  
  24. #ifdef MPW
  25. #pragma segment 4
  26. #endif
  27.  
  28. #include    <stdio.h>
  29. #include <stdlib.h>
  30. #include <string.h>
  31.  
  32. #include "TelnetHeader.h"
  33. #include    "wind.h"
  34. #include "menuseg.proto.h"
  35. #include "mainseg.proto.h"
  36. #include "Sets.proto.h"                /* JMB: For Saved Sets functions */
  37. #include    "configure.proto.h"
  38. #include "parse.proto.h"
  39. #include "InternalEvents.h"
  40. #include "mydnr.proto.h"
  41. #include "rsmac.proto.h"
  42. #include "network.proto.h"
  43. #include "maclook.proto.h"
  44. #include "vrrgmac.proto.h"
  45. #include "rgmp.proto.h"
  46. #include "tekrgmac.proto.h"
  47. #include "vgtek.proto.h"
  48. #include "netevent.proto.h"
  49. #include "Connections.proto.h"
  50.  
  51. #include "vsdata.h"
  52. #include "vsinterf.proto.h"
  53.  
  54. #include "event.proto.h"
  55. #include "macros.proto.h"
  56. #include "DlogUtils.proto.h"            /* For VersionNumber, OutlineItem, and DialogProc Protos */
  57. #include "telneterrors.h"
  58. #include "debug.h"
  59.  
  60. #include <Printing.h>
  61. #include "printing.proto.h"
  62. #include "menuseg.proto.h"
  63. #include "translate.proto.h"
  64. #include "parse.proto.h"                // For SendNAWSinfo proto
  65. #include "keypadmenus.proto.h"
  66.  
  67. MenuHandle
  68.     myMenus[NMENUS];        /* Menu Handles .... */
  69.  
  70. char *tempspot;                /* temporary storage ~255 bytes malloc-ed */
  71.  
  72.  
  73. /*
  74.  * External variable declarations (those which we borrow )
  75.  *
  76.  */
  77. extern short scrn;
  78. extern Cursor *theCursors[];
  79. extern WindRec
  80.     *screens,            /* The screen array from Maclook */
  81.     *ftplog;                    /* The FTP log screen from Maclook */
  82. extern SysEnvRec theWorld;                        /* System Environment record */
  83. extern    short    nNational;
  84.  
  85. void CloseCaptureFile(short w)
  86. {
  87.     VSclosecapture(w);                                /* BYU 2.4.18 */
  88.     CheckItem(myMenus[Emul], EMcapture,FALSE);        /* BYU 2.4.18 */
  89. }
  90.  
  91. /*    portsOpen()    - Count the number of ports open. Returns 3 different answers
  92.  *                  0= no ports at all, 1= at least active, -1= ports/none active. */
  93. short    portsOpen(void)
  94. {
  95.     short pnum;
  96.  
  97.     pnum=TelInfo->numwindows-1;
  98.     if (pnum<0)  return(0);
  99.     while (pnum>=0) 
  100. //        if (!screens[pnum--].active && !screens[pnum+1].corpse) return(1);
  101.         // corpse status now part of active flag
  102.         if (screens[pnum--].active == CNXN_ACTIVE) return(1);
  103.     return(-1);
  104. }
  105.  
  106. void    AdjustMenus(void)
  107. {
  108.     short        i;
  109.     WindowPtr    wind;
  110.     
  111.     if ((wind = FrontWindow()) != NULL && (((WindowPeek)wind)->windowKind >= userKind))
  112.         EnableItem( myMenus[Fil],FLclose);
  113.     else
  114.         DisableItem( myMenus[Fil],FLclose);
  115.         
  116.     if ((i=portsOpen()) <1) {
  117.         DisableItem( myMenus[Fil],FLsave);
  118.         DisableItem( myMenus[Fil],FLprint);
  119.         DisableItem( myMenus[Edit],EDcut);
  120.         DisableItem( myMenus[Edit],EDundo);
  121.         DisableItem( myMenus[Edit],EDclear);
  122.         DisableItem( myMenus[Edit],EDcopy);
  123.         DisableItem( myMenus[Edit],EDcopyt);
  124.  
  125.  
  126.         DisableItem( myMenus[Emul],EMbs);
  127.         DisableItem( myMenus[Emul],EMdel);
  128.         DisableItem( myMenus[Emul],EMecho);
  129.         DisableItem( myMenus[Emul],EMwrap);
  130.         DisableItem( myMenus[Emul],EMscroll);
  131.         DisableItem( myMenus[Emul],EMreset);
  132.         DisableItem ( myMenus[Emul],EMjump);
  133.         DisableItem ( myMenus[Emul],EMpage);
  134.         DisableItem ( myMenus[Emul],EMclear);    /* BYU 2.4.14 */
  135.         DisableItem ( myMenus[Emul],EMscreensize);
  136.         DisableItem ( myMenus[Emul],EMsetup);
  137.         DisableItem ( myMenus[Emul],EMfont);
  138.         DisableItem ( myMenus[Emul],EMsize);
  139.         DisableItem ( myMenus[Emul],EMcolor);
  140.         DisableItem ( myMenus[Emul],EMcapture);    /* BYU 2.4.18 */
  141.  
  142.         DisableItem( myMenus[Net ],NEftp);
  143.         DisableItem( myMenus[Net ],NEip);
  144.         DisableItem( myMenus[Net ],NEayt);
  145.         DisableItem( myMenus[Net ],NEao);
  146.         DisableItem( myMenus[Net ],NEinter);
  147.         DisableItem( myMenus[Net ],NEec);
  148.         DisableItem( myMenus[Net ],NEel);
  149.         DisableItem( myMenus[Net ],NEscroll);
  150.  
  151.         if (TelInfo->ScrlLock) {
  152.             TelInfo->ScrlLock=0;
  153.             CheckItem(myMenus[Net ], NEscroll,FALSE);
  154.             }
  155.         }
  156.     else {
  157.         EnableItem ( myMenus[Fil],FLsave);
  158.  
  159. /*        EnableItem ( myMenus[Fil],FLprint); */
  160.  
  161.         EnableItem ( myMenus[Emul],EMbs);
  162.         EnableItem ( myMenus[Emul],EMdel);
  163.         EnableItem ( myMenus[Emul],EMecho);
  164.         EnableItem ( myMenus[Emul],EMwrap);
  165.         if (nNational > 0) {
  166.             EnableItem ( myMenus[National], 0);
  167.             }
  168.         EnableItem ( myMenus[Emul],EMscroll);
  169.         EnableItem ( myMenus[Emul],EMreset);
  170.         EnableItem ( myMenus[Emul],EMjump);
  171.         EnableItem ( myMenus[Emul],EMpage);
  172.         EnableItem ( myMenus[Emul],EMclear);    /* BYU 2.4.14 */
  173.         EnableItem ( myMenus[Emul],EMscreensize);
  174.         EnableItem ( myMenus[Emul],EMsetup);
  175.         EnableItem ( myMenus[Emul],EMfont);
  176.         EnableItem ( myMenus[Emul],EMsize);
  177.         EnableItem ( myMenus[Emul],EMcapture);    /* BYU 2.4.18 */
  178.     
  179.         if (theWorld.hasColorQD) 
  180.             EnableItem ( myMenus[Emul],EMcolor);
  181.  
  182.         EnableItem ( myMenus[Net ],NEftp);
  183.         EnableItem ( myMenus[Net ],NEip);
  184.         EnableItem ( myMenus[Net ],NEayt);
  185.         EnableItem ( myMenus[Net ],NEao);
  186.         EnableItem ( myMenus[Net ],NEinter);
  187.         EnableItem ( myMenus[Net ],NEec);
  188.         EnableItem ( myMenus[Net ],NEel);
  189.         EnableItem ( myMenus[Net ],NEscroll);
  190.     }
  191.  
  192. }
  193.  
  194. /*    switchMenus( which) - Switch from our current menus to the key menus (1)
  195.  *                          or the normal menus (0). */
  196. void switchMenus(short which)
  197. {
  198.     short i;
  199.  
  200.     DeleteMenu( fileMenu);                    /* Take them from the menu bar */
  201.     DeleteMenu( editMenu);
  202.     DeleteMenu( termMenu);
  203.     DeleteMenu(  netMenu);
  204. //    if (gApplicationPrefs->KeyPadAndFuncMenus) {    /* Baylor */
  205.         DeleteMenu(  keyMenu);                /* Baylor */
  206.         DeleteMenu( funcMenu);                /* Baylor */
  207. //        }                                    /* Baylor */
  208.     DeleteMenu(NfileMenu);                    /* Take them from the menu bar */
  209.     DeleteMenu(NeditMenu);
  210.     DeleteMenu(NtermMenu);
  211.     DeleteMenu(NnetMenu);
  212.  
  213.     if (which) {
  214.         myMenus[Fil ] = GetMenu(NfileMenu);
  215.         myMenus[Edit] = GetMenu(NeditMenu);
  216.         myMenus[Emul] = GetMenu(NtermMenu);
  217.         myMenus[Net ] = GetMenu(NnetMenu );
  218.         myMenus[Keypad] = GetMenu(keyMenu);            /* Baylor */
  219.         myMenus[Function] = GetMenu(funcMenu);        /* Baylor */
  220.  
  221.         DelMenuItem(myMenus[Conn],COnext);
  222.         InsMenuItem(myMenus[Conn],(StringPtr)"\017Next Session/N\0",0);
  223.         }
  224.     else {
  225.         myMenus[Fil ] = GetMenu(fileMenu);
  226.         myMenus[Edit] = GetMenu(editMenu);
  227.         myMenus[Emul] = GetMenu(termMenu);
  228.         myMenus[Net ] = GetMenu( netMenu);
  229.         myMenus[Keypad] = GetMenu(keyMenu);            /* Baylor */
  230.         myMenus[Function] = GetMenu(funcMenu);        /* Baylor */
  231.  
  232.         DelMenuItem(myMenus[Conn],COnext);
  233.         InsMenuItem(myMenus[Conn],(StringPtr)"\015Next Session\0",0);
  234.         }
  235.  
  236.     for(i=1; i<Conn; i++)
  237.         InsertMenu( myMenus[i], connMenu);    /* Put them in the menu bar */
  238.  
  239.     if (gApplicationPrefs->KeyPadAndFuncMenus) {            /* Baylor */
  240.         InsertMenu(myMenus[Keypad], 0);                        /* Baylor */
  241.         InsertMenu(myMenus[Function], 0);                    /* Baylor */
  242.         }
  243.  
  244.     AdjustMenus();            /* Hilite the right stuff */
  245.  
  246.     if (TelInfo->MacBinary)
  247.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  248.     else
  249.         CheckItem(myMenus[Fil],FLbin,FALSE);
  250.  
  251.     if (TelInfo->ftplogon)
  252.         CheckItem(myMenus[Fil],FLlog,TRUE);        /* and the log .... */
  253.     else
  254.         CheckItem(myMenus[Fil],FLlog,FALSE);
  255.  
  256.     if (TelInfo->ScrlLock)                                 /* and the Suspend network ... */
  257.         CheckItem(myMenus[Net], NEscroll,TRUE);
  258.     else 
  259.         CheckItem(myMenus[Net], NEscroll,FALSE);
  260.  
  261.     if (TelInfo->numwindows>0)                            /* and set the BSDEL flag */
  262.         CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,FALSE);
  263.  
  264.     DrawMenuBar();                                /* Draw what we have done */
  265.  
  266.     SetupOpSpecSubmenu(myMenus[OpSpec]);
  267.  
  268.     if (!theWorld.hasColorQD)
  269.         DisableItem( myMenus[Emul], EMcolor);
  270. }
  271.  
  272. /*    setupmenu - Set up (load) all menus and prepare menu bar.
  273.  *                set default check marks. */
  274. void setupmenu(short def)
  275. {
  276.     myMenus[0] = GetMenu(appleMenu);                /* Get all of our friendly menus */
  277.     myMenus[Conn] = GetMenu(connMenu);
  278.     myMenus[Font] = GetMenu(fontMenu);
  279.     myMenus[Sizem] = GetMenu(sizeMenu);
  280.     myMenus[OpSpec] = GetMenu(opspecMenu);
  281.     myMenus[PrefsSub] = GetMenu(prefsMenu);
  282.     myMenus[National] = GetMenu(transMenu);
  283.     myMenus[Keypad] = GetMenu(keyMenu);            /* Baylor */
  284.     myMenus[Function] = GetMenu(funcMenu);        /* Baylor */
  285.  
  286.     gApplicationPrefs->KeyPadAndFuncMenus = true;    /* Baylor - oh, what the heck. Just use'em. */
  287.  
  288.     AddResMenu(myMenus[0], 'DRVR');                    /* Add in the DA's */
  289.  
  290.     InsertMenu(myMenus[0], 0);                        /* Insert the Menus into the bar */
  291.     InsertMenu(myMenus[Conn], 0);
  292.     if (gApplicationPrefs->KeyPadAndFuncMenus) {    /* Baylor */
  293.         InsertMenu(myMenus[Keypad], 0);                /* Baylor */
  294.         InsertMenu(myMenus[Function], 0);            /* Baylor */
  295.         }
  296.     InsertMenu(myMenus[Font], -1);
  297.     InsertMenu(myMenus[Sizem], -1);
  298.     InsertMenu(myMenus[OpSpec], -1);
  299.     InsertMenu(myMenus[National], -1);
  300.     InsertMenu(myMenus[PrefsSub], -1);
  301.  
  302.     AddResMenu(myMenus[Font], 'FONT');                /* Put the fonts in the font menu */
  303.  
  304.     SetupOpSpecSubmenu(myMenus[OpSpec]);
  305.     switchMenus(def);
  306. }
  307.  
  308. void CheckOpSpecSubmenu(void)
  309. {
  310.     SetupOpSpecSubmenu(myMenus[OpSpec]);
  311. }
  312.  
  313. void SetupOpSpecSubmenu(MenuHandle theMenu)
  314. {
  315.     short            scratchshort;
  316.         
  317.     scratchshort = CountMItems(theMenu);
  318.     for (; scratchshort>0; scratchshort--) DelMenuItem(theMenu, scratchshort);
  319.  
  320.     UseResFile(TelInfo->SettingsFile);
  321.     AddResMenu(theMenu, SESSIONPREFS_RESTYPE);
  322. }
  323.  
  324. /*    updateMenuChecks() - update the check marks for file transfer
  325.  *                         (MacBinary) */
  326.  
  327. void updateMenuChecks( void)
  328. {
  329.     if (TelInfo->MacBinary)
  330.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  331.     else
  332.         CheckItem(myMenus[Fil],FLbin,FALSE);
  333. }
  334.  
  335. /*    DisplayMacBinary()    - Sets the macbinary check mark according to the MacBinary flag */
  336. void DisplayMacBinary( void)
  337. {
  338.     if (TelInfo->MacBinary)
  339.         CheckItem(myMenus[Fil],FLbin,TRUE);        /* Check MacBinary ... */
  340.     else
  341.         CheckItem(myMenus[Fil],FLbin,FALSE);
  342. }
  343.  
  344. /*CheckFonts()        - Place checkmarks and outlines on the appropriate
  345.  *                          menu items for the fonts */
  346. void CheckFonts(void)
  347. {
  348.     short     i, fsiz, fnum;
  349.     long    itemFontSize;
  350.     Str255     temp, itemString;
  351.  
  352.     RSgetfont( screens[scrn].vs, &fnum, &fsiz);
  353.     GetFontName(fnum, temp);
  354.     
  355.     for(i=1; i<= CountMItems( myMenus[Font]); i++)
  356.         {
  357.         GetItem( myMenus[Font], i, itemString);
  358.         if (EqualString(temp, itemString, FALSE, FALSE))
  359.             CheckItem( myMenus[Font], i, TRUE);            /* Check the current font */
  360.         else
  361.             CheckItem( myMenus[Font], i, FALSE);
  362.         }
  363.     
  364.     for(i=1; i<=CountMItems( myMenus[Sizem]); i++) {
  365.         GetItem( myMenus[Sizem], i, itemString);            /* JMB 2.6 -- Much safer to do it */
  366.         StringToNum(itemString, &itemFontSize);            /*                this way! */
  367.  
  368.         if (fsiz == (short)itemFontSize)
  369.             CheckItem( myMenus[Sizem], i, TRUE);            /* Check Our Current Size */
  370.         else
  371.             CheckItem( myMenus[Sizem], i, FALSE);
  372.  
  373.         if (RealFont( fnum, (short)itemFontSize))        /* Outline All Available REAL Sizes */
  374.             SetItemStyle( myMenus[Sizem], i, outline);
  375.         else
  376.             SetItemStyle( myMenus[Sizem], i, 0);
  377.         }
  378. }
  379.  
  380. /*    applAbout - display the about dialog for the application.*/
  381. void applAbout( void)
  382. {
  383.     DialogPtr About;
  384.     short itemhit;
  385.  
  386.     About=GetNewMyDialog( AboutDLOG, (Ptr) 0L,(WindowPtr) -1L, (void *)ThirdCenterDialog);
  387.     if (About) {
  388.         UItemAssign( About, 2, VersionNumberUPP);
  389.         ModalDialog(NULL, &itemhit);
  390.         DisposDialog(About);
  391.         }
  392. }
  393.  
  394. short ReallyClose( short scrn)
  395. {
  396.     DialogPtr    dtemp;
  397.     short        item;
  398.     Str255        scratchPstring;
  399.     
  400.     SetCursor(theCursors[normcurs]);
  401.  
  402.     GetWTitle(screens[scrn].wind, scratchPstring);
  403.     ParamText(scratchPstring, NULL, NULL, NULL);
  404.     
  405.     dtemp = GetNewMyDialog( CloseDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
  406.  
  407.     item = DLOGCancel +1;
  408.     while (item> DLOGCancel)
  409.         ModalDialog(DLOGwOK_CancelUPP, &item);
  410.  
  411.     DisposDialog( dtemp);
  412.  
  413.     updateCursor(1);
  414.     
  415.     if (item == DLOGCancel) return(0);
  416.  
  417.     return(1);
  418. }
  419.  
  420. PicHandle RGtoPICT(short i)
  421. {
  422.     short j;
  423.     PicHandle tpic;
  424.     Rect trect;
  425.  
  426.     SetRect(&trect,0,0,384,384);
  427.     j=VGnewwin(3,VGgetVS(i));            /* NCSA 2.5: get the right VS */
  428.     RGMPsize( &trect );
  429.     VGzcpy( i, j);                /* Love dat zm factr */
  430.     tpic=OpenPicture(&trect);
  431.     ClipRect(&trect);
  432.     
  433.     VGredraw(i,j);
  434.     ClosePicture();
  435.     VGclose(j);
  436.  
  437.     return(tpic);
  438. }
  439.  
  440. /* 
  441.  * copyGraph    - Copy the current graphics screen.
  442.  *            dnum - the number of the drawing to copy .
  443.  */
  444. void copyGraph( short dnum)
  445. {
  446.     long tlong;                    /* Temporary Variable */
  447.     PicHandle tpic;                /* Mental picture of the thing */
  448.  
  449.     tpic=RGtoPICT(dnum);            /* Get the picture */
  450.     tlong=ZeroScrap();                /* Nobody else can live here */
  451.     HLock((Handle) tpic);                    /* Lock it for Puting */
  452.     tlong=PutScrap(GetHandleSize((Handle) tpic),'PICT', (Ptr) *tpic);    /* Store as a PICT */
  453.     HUnlock((Handle) tpic);                    /* Unlock so we can toss it */
  454.     KillPicture(tpic);                /* Kill the picture..... */
  455. }                
  456.  
  457. /* 
  458.  * copyText    - Copy the current selection on the virtual screen
  459.  *            vs - the number of the virtual screen to copy from
  460.  */
  461.  
  462. void copyText( short vs)
  463. {
  464.     char **charh;            /* where to store the characters */
  465.     long tlong;                /* Necessary temporary variable */
  466.  
  467.     tlong=ZeroScrap();        /* This Scrap aint big enough for the both of us */
  468.  
  469.     charh=RSGetTextSel(vs,0);        /* Get the text selection */
  470.  
  471.     if (charh == (char **)-1L)
  472.         OutOfMemory(400);
  473.     else if (charh != (char **)0L) {    /* BYU LSC - Can't do anything without characters */
  474.         HLock(charh);                /* Lock for putting */
  475.         tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
  476.                                     /* Put it as a TEXT resource */
  477.         HUnlock(charh);                /* Unlock for disposal */
  478.         DisposHandle(charh);        /* Kill the chars */
  479.         }
  480. }
  481.  
  482. /* 
  483.  * copyTable   - Copy the current selection on the virtual screen
  484.  *            vs - the number of the virtual screen to copy from
  485.  */
  486.  
  487. void copyTable( short vs)
  488. {
  489.     char **charh;            /* where to store the characters */
  490.     long tlong;                /* Necessary temporary variable */
  491.  
  492.     tlong=ZeroScrap();        /* This Scrap aint big enough for the both of us */
  493.  
  494.     charh=RSGetTextSel(vs, gApplicationPrefs->CopyTableThresh);        /* Get the text selection */
  495.  
  496.     if (charh>(char **)0L) {                    /* BYU LSC - Can't do anything without characters */
  497.         HLock(charh);                /* Lock for putting */
  498.         tlong=PutScrap(GetHandleSize(charh),'TEXT',*charh);
  499.                                     /* Put it as a TEXT resource */
  500.         HUnlock(charh);                /* Unlock for disposal */
  501.         DisposHandle(charh);        /* Kill the chars */
  502.         }
  503.     else putln("No characters to copy darn it!");
  504. }
  505.  
  506. /*
  507.  *    paste - Paste the resource from the scrap into the current WIND, if
  508.  *            and only if it is really text
  509.  */
  510.  
  511. void paste( void)
  512. {
  513.     long
  514.         off,                /* offset */
  515.         length;                /* the lenght of what is on the Scrap */
  516.  
  517.     if (screens[scrn].clientflags & PASTE_IN_PROGRESS) {  // One paste at a time, please
  518.         SysBeep(4);
  519.         return;
  520.         }
  521.         
  522.     /* Flush the buffer if we have echo */
  523.     if ((screens[scrn].ftpstate == 0) &&    /* BYU */
  524.         screens[scrn].echo &&                 /* BYU */
  525.         screens[scrn].kblen>0) {            /* BYU */
  526.         netwrite( screens[scrn].port, screens[scrn].kbbuf,
  527.                     screens[scrn].kblen);    /* if full send buffer */
  528.         screens[scrn].kblen=0;
  529.         }
  530.  
  531.     if (GetScrap(0L, 'TEXT', &off)<=0L)        /* If there are no TEXT res's */
  532.             return;                        /* then we can't paste it */
  533.  
  534.     screens[scrn].outhand=NewHandle(0L);    /* create a handle to put chars in */
  535.  
  536.     length= GetScrap( screens[scrn].outhand, 'TEXT',&off);
  537.                                             /* Store the scrap into the handle */
  538.     screens[scrn].outlen = length;            /* Set the length */
  539.     HLock(screens[scrn].outhand);            /* Lock the Handle down for safety */
  540.     screens[scrn].outptr=*screens[scrn].outhand;    /* Set the pointer */
  541.  
  542.     screens[scrn].clientflags |= PASTE_IN_PROGRESS;
  543.     screens[scrn].incount = 0;
  544.     screens[scrn].outcount = 0;
  545.     
  546.     trbuf_mac_nat((unsigned char *)screens[scrn].outptr,screens[scrn].outlen, screens[scrn].national);    /* LU: translate to national chars */
  547.  
  548.     pasteText( scrn);    /* BYU LSC - routine to paste to net, w/echo if neccessary */
  549. }
  550.  
  551. void displayStatus(short n)
  552. {
  553.     DialogPtr        dptr;
  554.     short            item;
  555.     Str255            scratchPstring;
  556.     
  557.     SetCursor(theCursors[normcurs]);
  558.     
  559.     switch(screens[n].active) {
  560.         case CNXN_ISCORPSE:
  561.             GetWTitle(screens[n].wind, scratchPstring);
  562.             ParamText( scratchPstring, "\pawaiting dismissal", NULL, NULL);
  563.             break;
  564.         case CNXN_OPENING:
  565.             ParamText( screens[n].machine,"\pbeing opened", NULL, NULL);
  566.             break;
  567.         default:
  568.             ParamText( screens[n].machine,"\pbeing looked up", NULL, NULL);
  569.         }
  570.  
  571.     dptr = GetNewMyDialog( StatusDLOG, NULL, kInFront, (void *)ThirdCenterDialog);
  572.  
  573.     item = DLOGCancel+1;
  574.     while (item > DLOGCancel)
  575.         ModalDialog(DLOGwOK_CancelUPP, &item);
  576.  
  577.     updateCursor(1);
  578.     
  579.     if (item == DLOGCancel) {
  580.         netclose(screens[n].port);
  581.         destroyport( n);
  582.         }    
  583.  
  584.     DisposDialog(dptr);
  585. }
  586.  
  587. /*
  588.  *    changeport - handle the menu updates for changing from one port to another
  589.  */
  590. void changeport(short oldprt, short newprt)
  591. {
  592.  
  593.     sprintf(tempspot,"oldscrn: %d, newscrn: %d",oldprt,newprt); putln(tempspot);
  594.     
  595.     if (screens[oldprt].active == CNXN_ACTIVE) 
  596.         CheckItem(myMenus[Conn], oldprt + FIRST_CNXN_ITEM, FALSE);        /* Adjust Conn menu */
  597.     CheckItem(myMenus[Conn], newprt + FIRST_CNXN_ITEM, TRUE);
  598.  
  599.     CheckItem(myMenus[Emul], EMbs,FALSE);                        /* Adjust BS */
  600.     CheckItem(myMenus[Emul], EMdel,FALSE);
  601.     CheckItem(myMenus[Emul], EMbs+screens[newprt].bsdel,TRUE);    /* and DEL */
  602.  
  603.     if (screens[newprt].tektype < 0) {    // TEK is inhibited
  604.         DisableItem(myMenus[Emul],EMclear);
  605.         DisableItem(myMenus[Emul],EMpage);
  606.         }
  607.     else {
  608.         EnableItem(myMenus[Emul],EMclear);
  609.         EnableItem(myMenus[Emul],EMpage);
  610.     
  611.         if (screens[newprt].tekclear)                /* BYU 2.4.8 */
  612.             CheckItem(myMenus[Emul],EMclear,TRUE);    /* BYU 2.4.8 */
  613.         else                                         /* BYU 2.4.8 */
  614.             CheckItem(myMenus[Emul],EMclear,FALSE);    /* BYU 2.4.8 */
  615.         }
  616.         
  617.     if (screens[newprt].ESscroll)
  618.         CheckItem(myMenus[Emul],EMscroll,TRUE);
  619.     else 
  620.         CheckItem(myMenus[Emul],EMscroll,FALSE);
  621.  
  622.     if (screens[newprt].echo)                     /* LOCAL ECHO */
  623.         CheckItem(myMenus[Emul],EMecho,TRUE);
  624.     else                                         /* REMOTE ECHO */
  625.         CheckItem(myMenus[Emul],EMecho,FALSE);
  626.         
  627.     if (screens[newprt].wrap)                     /* wrap on */
  628.         CheckItem(myMenus[Emul],EMwrap,TRUE);
  629.     else                                         /* wrap off */
  630.         CheckItem(myMenus[Emul],EMwrap,FALSE);
  631.  
  632.     if (VSiscapturing(screens[newprt].vs))                /* BYU 2.4.18 */
  633.         CheckItem(myMenus[Emul], EMcapture,TRUE);        /* BYU 2.4.18 */
  634.     else                                                /* BYU 2.4.18 */
  635.         CheckItem(myMenus[Emul], EMcapture,FALSE);        /* BYU 2.4.18 */
  636.  
  637.     if (screens[newprt].arrowmap)                        /* JMB */
  638.         CheckItem(myMenus[Emul],EMarrowmap, TRUE);        /* JMB */
  639.     else                                                /* JMB */
  640.         CheckItem(myMenus[Emul],EMarrowmap, FALSE);        /* JMB */
  641.         
  642.     if (screens[newprt].pgupdwn)                        /* JMB */
  643.         CheckItem(myMenus[Emul],EMpgupdwn, TRUE);        /* JMB */
  644.     else                                                /* JMB */
  645.         CheckItem(myMenus[Emul],EMpgupdwn, FALSE);        /* JMB */
  646.     
  647.     scrn=newprt;
  648.  
  649.     CheckFonts();
  650.  
  651.     CheckNational(screens[newprt].national);
  652. }
  653.  
  654. // Returns TRUE if the user cancelled the quit
  655. Boolean    HandleQuit(void)
  656. {
  657.     short    i;
  658.     
  659.     if (TelInfo->numwindows>0) {
  660.         if (AskUserAlert(REALLY_QUIT_QUESTION, FALSE)) {
  661.             for (i = TelInfo->numwindows - 1; i >= 0; i--) {
  662.                 netclose(screens[i].port);
  663.                 destroyport(i);
  664.                 }
  665.             }
  666.         else
  667.             return (TRUE);
  668.       }
  669.       
  670.     quit();
  671.     return (FALSE);
  672. }
  673.  
  674. /*
  675.  *    HandleMenuCommand - preform a command denoted by the arguments.
  676.  *        mResult - the result of the menu event
  677.  *        modifiers- modifiers from the menu event
  678.  */
  679.  
  680. void HandleMenuCommand( long mResult, short modifiers)
  681. {
  682.     register short i;
  683.     short theItem, theMenu;
  684.  
  685.     theMenu = mResult >> 16;
  686.     theItem = mResult & 0xffff;
  687.     switch(theMenu) {
  688.     case appleMenu:
  689.         if (theItem==1)                /* About Dialog */
  690.             applAbout();
  691.         else
  692.           {
  693.             Str255
  694.                 name;
  695.             GetItem(myMenus[0], theItem, name);        /* Desk accessory */
  696.             OpenDeskAcc(name);
  697.           }
  698.         break;
  699.  
  700.     case fileMenu:
  701.     case NfileMenu:
  702.         switch(theItem) {            
  703.             
  704.         case FLopen:
  705.             PresentOpenConnectionDialog();                    /* Open a connection */                
  706.             break;
  707.  
  708.         case FLclose:
  709. //            if ( TelInfo->numwindows<1 ) break;                /* Close a connection */
  710.             CloseAWindow(FrontWindow());
  711. #if 0
  712.             if ( screens[scrn].active == CNXN_ISCORPSE) {
  713.                 netclose( screens[scrn].port);
  714.                 destroyport( scrn);
  715.                 }
  716.             else {
  717.                 if ( !ReallyClose( scrn) ) break;
  718.                 netclose(screens[scrn].port);
  719.                 removeport( scrn);
  720.                 }
  721.             if (TelInfo->numwindows <1) 
  722.                 {
  723.                 DisableItem( myMenus[Conn],0);
  724.                 DisableItem(myMenus[Conn],COnext);
  725.                 DrawMenuBar();
  726.                 }
  727. #endif
  728.             break;
  729.  
  730.         case FLload:                                /* Load a set */
  731.             LoadSet();
  732.             break;
  733.         case FLsave:                                /* Save a set */
  734.             if (TelInfo->numwindows<1) break;
  735.             SaveSet();
  736.             break;
  737.         case FLbin:                                    /* Toggle MacBinary on/off */
  738.             TelInfo->MacBinary = !TelInfo->MacBinary;
  739.             if (TelInfo->MacBinary) {
  740.                 CheckItem(myMenus[Fil], FLbin,TRUE);
  741.                 }
  742.             else {
  743.                 CheckItem(myMenus[Fil], FLbin,FALSE);
  744.                 }
  745.             break;
  746.  
  747.         case FLlog:                                        /* Toggle FTP window on/off*/
  748.             TelInfo->ftplogon=!TelInfo->ftplogon;
  749.             if(TelInfo->ftplogon) {
  750.                 CheckItem(myMenus[Fil],FLlog,TRUE);
  751.                 RSshow(ftplog->vs);
  752.                 SelectWindow(ftplog->wind);
  753.                 }
  754.             else {
  755.                 CheckItem(myMenus[Fil],FLlog,FALSE);
  756.                 RShide(ftplog->vs);
  757.                 }
  758.             break;
  759.  
  760.         case FLprint:                                /* Print Selection (or gr) */
  761.             PrintSelection();
  762.             break;
  763.  
  764.         case FLpset:                                    /* Set up for printer */
  765.             PrintPageSetup();
  766.             break;
  767.  
  768.         case FLquit:
  769.             (void) HandleQuit();
  770.             break;
  771.  
  772.         }
  773.         break;
  774.  
  775.     case editMenu:
  776.     case NeditMenu:
  777.         if (!SystemEdit(theItem-1)) {                /* Is this mine? */
  778.             switch(theItem) {
  779.             case EDcopy:                            /* Copy */
  780.                 i = MacRGfindwind(FrontWindow());    /* is ICR window? */
  781.                 if (i >= 0)
  782.                     MacRGcopy(FrontWindow());        /* copy the ICR window */
  783.                 else {
  784.                     i=RGgetdnum(FrontWindow());
  785.                     if (i>-1)                        /* Copy Graphics */
  786.                         copyGraph( i);
  787.                     else                            /* Copy Text */
  788.                         if ( (i=RSfindvwind(FrontWindow())) >-1)
  789.                             copyText( i);
  790.                 }
  791.                 break;
  792.  
  793.             case EDcopyt:                            /* Copy Table */
  794.                 /* 
  795.                 *  tech note #180 trick to get MultiFinder to pay attention 
  796.                 */
  797.                 if (!SystemEdit(EDcopy-1)) {        /* tell it we did a copy */
  798.                     i=RGgetdnum(FrontWindow());
  799.                     if (i>-1)            /* Copy Graphics */
  800.                         copyGraph( i);
  801.                     else                /* Copy Text */
  802.                         if ( (i=RSfindvwind(FrontWindow())) >-1)
  803.                             copyTable( i);
  804.                 }
  805.                 break;
  806.  
  807.             case EDpaste:                            /* Paste */
  808.                 if (TelInfo->numwindows<1)
  809.                         break;
  810.                     else paste();            /* Paste if there is a wind to do to*/
  811.                 break;
  812.             case EDmacros:                            /* Set them Macros */
  813.                 Macros();
  814.                 break;
  815.             default:
  816.                 break;
  817.             }
  818.         }
  819.         break;
  820.  
  821.     case connMenu:
  822.     case NconnMenu:
  823.         if (theItem == COnext) {
  824.             short    scratchshort;
  825.             if (TelInfo->numwindows >1) {
  826.                 scratchshort = WindowPtr2ScreenIndex(FrontWindow()) + 1;
  827.                 // Skip over inactive connections
  828.                 while(    (screens[scratchshort].active != CNXN_ACTIVE) &&
  829.                         (screens[scratchshort].active != CNXN_ISCORPSE) &&
  830.                         (scratchshort <= TelInfo->numwindows+1))                        
  831.                     scratchshort++;
  832.                     
  833.                 if ((scratchshort < 0) || (scratchshort >= TelInfo->numwindows))
  834.                     scratchshort = 0;
  835.                 SelectWindow(screens[scratchshort].wind);
  836.                 }
  837.             break;
  838.             }
  839.         
  840.         if (theItem == COtitle)    {
  841.             ChangeWindowName(FrontWindow());
  842.             break;
  843.             }
  844.             
  845.         if (theItem >= FIRST_CNXN_ITEM) {
  846.             if ((theItem - FIRST_CNXN_ITEM-1)>(TelInfo->numwindows+1)) break;  /* rotten danish */
  847.             if (screens[theItem - FIRST_CNXN_ITEM].active != CNXN_ACTIVE) {
  848.                 displayStatus(theItem - FIRST_CNXN_ITEM);    /* Tell them about it..... */
  849.                 break;
  850.                 }
  851.             else {
  852.                 HiliteWindow(screens[scrn].wind, FALSE);
  853.                 changeport(scrn,(theItem - FIRST_CNXN_ITEM));
  854.                 if (!(modifiers &  optionKey)) SelectWindow(screens[scrn].wind);
  855.                 else HiliteWindow(screens[scrn].wind, TRUE);
  856.                 }
  857.             }
  858.         break;
  859.  
  860.     case netMenu:
  861.     case NnetMenu:
  862.         switch(theItem) {
  863.         case NEftp:                                        /* Send FTP command */
  864.         case NEip:                                        /* Send IP Number */
  865.             if (TelInfo->numwindows<1) break;
  866.             {    char tmpout[30];                        /* Basically the same except for */
  867.                 unsigned char tmp[4];                    /* The ftp -n phrase in NEftp */
  868.  
  869.                 if (screens[scrn].echo && (screens[scrn].kblen>0)) {
  870.                     netwrite( screens[scrn].port, screens[scrn].kbbuf,
  871.                                 screens[scrn].kblen);/* if not empty send buffer */
  872.                     screens[scrn].kblen=0;
  873.                     }
  874.                 netgetip(tmp);
  875.                 if (theItem == NEftp) {
  876.                     if ((gFTPServerPrefs->ServerState == 1) && !(modifiers & shiftKey))
  877.                         sprintf(tmpout,"ftp -n %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]);
  878.                     else
  879.                         sprintf(tmpout,"ftp %d.%d.%d.%d\015\012",tmp[0],tmp[1],tmp[2],tmp[3]);
  880.                     }
  881.                 else
  882.                     sprintf(tmpout,"%d.%d.%d.%d",tmp[0],tmp[1],tmp[2],tmp[3]);
  883.                 netwrite(screens[scrn].port,tmpout,strlen(tmpout));
  884.                 if (screens[scrn].echo)
  885.                     VSwrite(screens[scrn].vs,tmpout, strlen(tmpout));
  886.             }
  887.             break;
  888.  
  889.         case NEayt:                                /* Send "Are You There?"*/
  890.             if (TelInfo->numwindows<1) break;
  891.             netpush(screens[scrn].port);
  892.             netwrite(screens[scrn].port, "\377\366",2);
  893.             break;
  894.  
  895.         case NEao:                                /* Send "Abort Output"*/
  896.             if (TelInfo->numwindows<1) break;
  897.             netpush(screens[scrn].port);
  898.             netwrite(screens[scrn].port, "\377\365",2);
  899.             screens[ scrn].timing = 1;                        /* set emulate to TMwait */
  900.             netwrite(screens[scrn].port, "\377\375\006",3);        /* send TM */
  901.             break;
  902.  
  903.         case NEinter:                                /* Send "Interrupt Process"*/
  904.             if (TelInfo->numwindows<1) break;
  905.             netpush(screens[scrn].port);
  906.             netwrite(screens[scrn].port, "\377\364",2);
  907.             screens[ scrn].timing = 1;                        /* set emulate to TMwait */
  908.             netwrite(screens[scrn].port, "\377\375\006",3);        /* send TM */
  909.             break;
  910.  
  911.         case NEec:                                /* Send "Erase Character"*/
  912.             if (TelInfo->numwindows<1) break;
  913.             netpush(screens[scrn].port);
  914.             netwrite(screens[scrn].port, "\377\367",2);
  915.             break;
  916.  
  917.         case NEel:                                /* Send "Erase Line"*/
  918.             if (TelInfo->numwindows<1) break;
  919.             netpush(screens[scrn].port);
  920.             netwrite(screens[scrn].port, "\377\370",2);
  921.             break;
  922.             
  923.         case NEscroll:                            /* Suspend Network */
  924.             TelInfo->ScrlLock=!TelInfo->ScrlLock;
  925.             if (TelInfo->ScrlLock) 
  926.                 CheckItem(myMenus[Net], NEscroll,TRUE);
  927.             else 
  928.                 CheckItem(myMenus[Net], NEscroll,FALSE);
  929.             break;
  930.  
  931.         case NEnet:                                /* Show Network Numbers */
  932.             showNetNumbers();
  933.             break;
  934.  
  935.         default:
  936.             break;
  937.         }
  938.         break;
  939.  
  940.     case termMenu:
  941.     case NtermMenu:
  942.         switch(theItem) {
  943.  
  944.         case EMbs:                                /* Backspace for backspace  */
  945.             if (TelInfo->numwindows<1) break;
  946.             CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,FALSE);
  947.             screens[scrn].bsdel=0;
  948.             CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,TRUE);
  949.             break;
  950.         
  951.         case EMdel:                                /* Delete for backspace */
  952.             if (TelInfo->numwindows<1) break;
  953.             CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,FALSE);
  954.             screens[scrn].bsdel=1;
  955.             CheckItem(myMenus[Emul], EMbs+screens[scrn].bsdel,TRUE);
  956.             break;
  957.  
  958.         case EMecho:                                /* Toggle Local Echo (if poss.) */
  959.             if (TelInfo->numwindows < 1) break;
  960.             if (screens[scrn].echo && (screens[scrn].kblen>0)) {
  961.                 netwrite( screens[scrn].port, screens[scrn].kbbuf,
  962.                             screens[scrn].kblen);    /* if not empty send buffer */
  963.                 screens[scrn].kblen=0;
  964.                 }
  965.             screens[scrn].echo= !screens[scrn].echo;    /* toggle */
  966.             if (screens[scrn].echo) {                    /* LOCAL ECHO */
  967.                 netwrite(screens[scrn].port,"\377\376\001",3);
  968.                 CheckItem(myMenus[Emul],EMecho,TRUE);
  969.                 }
  970.             else {                                        /* REMOTE ECHO */
  971.                 netwrite(screens[scrn].port,"\377\375\001",3);
  972.                 CheckItem(myMenus[Emul],EMecho,FALSE);
  973.                 }
  974.             break;
  975.             
  976.         case EMwrap:                                /* wrap mode */
  977.             if (TelInfo->numwindows < 1) break;
  978.             if (!screens[scrn].wrap) {                /* is off, turn on */
  979.                 screens[scrn].wrap = 1;
  980.                 CheckItem( myMenus[Emul],EMwrap, TRUE);
  981.                 VSwrite(screens[scrn].vs, "\033[?7h",5);    /* kick emulator */
  982.                 }
  983.             else {
  984.                 screens[scrn].wrap = 0;
  985.                 CheckItem( myMenus[Emul],EMwrap, FALSE);
  986.                 VSwrite(screens[scrn].vs, "\033[?7l",5);
  987.                 }
  988.             break;
  989.         
  990.         case EMarrowmap:                                        /* JMB */
  991.             if (TelInfo->numwindows < 1) break;                    /* JMB */
  992.             screens[scrn].arrowmap = !screens[scrn].arrowmap;    /* JMB */
  993.             if (screens[scrn].arrowmap)                            /* JMB */
  994.                 CheckItem( myMenus[Emul], EMarrowmap, TRUE);    /* JMB */
  995.             else                                                /* JMB */
  996.                 CheckItem( myMenus[Emul], EMarrowmap, FALSE);    /* JMB */
  997.             break;                                                /* JMB */
  998.             
  999.         case EMpgupdwn:
  1000.             if (TelInfo->numwindows < 1) break;                    /* JMB */
  1001.             screens[scrn].pgupdwn = !screens[scrn].pgupdwn;        /* JMB */
  1002.             if (screens[scrn].pgupdwn)                            /* JMB */
  1003.                 CheckItem( myMenus[Emul], EMpgupdwn, TRUE);        /* JMB */
  1004.             else                                                /* JMB */
  1005.                 CheckItem( myMenus[Emul], EMpgupdwn, FALSE);    /* JMB */
  1006.             break;                                                /* JMB */
  1007.             
  1008.         case EMscroll:                                        /* Scrollback on CLS */
  1009.             if (TelInfo->numwindows<1) break;
  1010.             screens[scrn].ESscroll = !screens[scrn].ESscroll;
  1011.             VSscrolcontrol( screens[scrn].vs, -1, screens[scrn].ESscroll);
  1012.             if (screens[scrn].ESscroll)
  1013.                 CheckItem(myMenus[Emul],EMscroll, TRUE);
  1014.             else
  1015.                 CheckItem(myMenus[Emul],EMscroll, FALSE);
  1016.             break;
  1017.             
  1018.         case EMpage:                                    /* TEK page command */
  1019.             if (TelInfo->numwindows<1) break;
  1020.             parse( &screens[scrn],  (unsigned char *) "\033\014",2);    /* BYU LSC */
  1021.             break;
  1022.  
  1023.         case EMclear:                                /* BYU 2.4.8 - Clear on TEK page */
  1024.             if (TelInfo->numwindows<1) break;
  1025.             screens[scrn].tekclear = !screens[scrn].tekclear;
  1026.             if (screens[scrn].tekclear)
  1027.                 CheckItem(myMenus[Emul],EMclear, TRUE);
  1028.             else
  1029.                 CheckItem(myMenus[Emul],EMclear, FALSE);
  1030.             break;
  1031.  
  1032.         case EMscreensize:
  1033.             if (TelInfo->numwindows<1) break;        /* NCSA: SB */
  1034.             SetScreenDimensions((short)scrn);        /* NCSA: SB */
  1035.             break;
  1036.  
  1037.         case EMreset:                                    /* Reset Screen */
  1038.             if (TelInfo->numwindows<1) break;
  1039.             VSreset(screens[scrn].vs);                    /* Reset it */
  1040.             screens[scrn].timing=0;
  1041.             screens[scrn].wrap = 0;                        /* turns wrap off */
  1042.             CheckItem( myMenus[Emul],EMwrap, FALSE);
  1043.             break;
  1044.         case EMjump:                                    /* Jump Scroll */
  1045.             if (TelInfo->numwindows<1) break;
  1046.             FlushNetwork(scrn);                            /* Flush it */
  1047.             break;
  1048.             
  1049.         case EMsetup:                            /* need dialog to enter new key values */
  1050.             setupkeys();
  1051.             break;
  1052.  
  1053.         case EMcolor:                                        /* Set color */
  1054.             if (TelInfo->numwindows<1) break;
  1055.             if (theWorld.hasColorQD)
  1056.                 RScprompt(screens[scrn].vs);    /* Color it */
  1057.             break;
  1058.  
  1059.         case EMcapture:                                            /* BYU 2.4.18 - Capture session to file */
  1060.             if (VSiscapturing(screens[scrn].vs)) {                /* BYU 2.4.18 */
  1061.                 CloseCaptureFile(screens[scrn].vs);                /* BYU 2.4.18 */
  1062.             } else {                                            /* BYU 2.4.18 */
  1063.                 if(VSopencapture(scrn, screens[scrn].vs))        /* BYU 2.4.18 */
  1064.                     CheckItem(myMenus[Emul], EMcapture,TRUE);    /* BYU 2.4.18 */
  1065.             }                                                    /* BYU 2.4.18 */
  1066.  
  1067.             break;                                                /* BYU 2.4.18 */
  1068.  
  1069.         default:
  1070.             break;
  1071.         }
  1072.         break;
  1073.     case fontMenu:
  1074.         if (TelInfo->numwindows>0) {
  1075.             short     itemFontNum;
  1076.             Str255     temp;
  1077.     
  1078.             GetItem( myMenus[Font], theItem, temp);
  1079.             GetFNum( temp, &itemFontNum);
  1080.  
  1081.             RSchangefont( screens[scrn].vs, itemFontNum, 0, 1);
  1082.             CheckFonts();
  1083.             }
  1084.         break;
  1085.     case sizeMenu:
  1086.         if (TelInfo->numwindows>0) {
  1087.             long    itemFontSize;
  1088.             Str255     temp;
  1089.             
  1090.             GetItem( myMenus[Sizem], theItem, temp);    /* JMB 2.6 -- Much safer to do it */
  1091.             StringToNum(temp, &itemFontSize);        /*                this way! */
  1092.  
  1093.             RSchangefont( screens[scrn].vs, -1, itemFontSize, 1);
  1094.             CheckFonts();
  1095.             }
  1096.         break;
  1097.     case opspecMenu:                                            // JMB
  1098.         OpenPortSpecial(myMenus[OpSpec], theItem);                // JMB
  1099.         break;                                                    // JMB
  1100.     case prefsMenu:
  1101.         switch(theItem) {
  1102.             case prfGlobal:
  1103.                 Cenviron();
  1104.                 break;
  1105.             case prfFTP:
  1106.                 Cftp();
  1107.                 break;
  1108.             case prfSess:
  1109.                 EditConfigType(SESSIONPREFS_RESTYPE, &EditSession);
  1110.                 CheckOpSpecSubmenu();
  1111.                 break;
  1112.             case prfTerm:
  1113.                 EditConfigType(TERMINALPREFS_RESTYPE, &EditTerminal);
  1114.                 break;
  1115.             case prfFTPUser:
  1116.                 EditConfigType(FTPUSER, &EditFTPUser);
  1117.             }
  1118.         break;
  1119.     case transMenu:
  1120.         if (TelInfo->numwindows>0) {
  1121.             CheckNational(theItem-1);        // Set up the menu
  1122.             transBuffer(screens[scrn].national, theItem-1);    // Translate the scrollback buffer
  1123.             // and redraw the screen
  1124.             VSredraw(screens[scrn].vs,0,0,VSmaxwidth(screens[scrn].vs),VSgetlines(screens[scrn].vs)-1);    /* LU */
  1125.             screens[scrn].national = theItem-1;
  1126.             }
  1127.         break;
  1128.     case keyMenu:
  1129.         KeyMenu(theItem);
  1130.         break;
  1131.     case funcMenu:
  1132.         FuncMenu(theItem);
  1133.         break;
  1134.     default:
  1135.         break;
  1136.     
  1137.     }
  1138.     HiliteMenu(0);
  1139.   } /* HandleMenuCommand */
  1140.  
  1141. //    Take the user's new translation choice and make sure the proper tables exist to do 
  1142. //        the translations.  If there is a problem, return the default translation as the chouce.
  1143. void    CheckNational(short choice)
  1144. {
  1145.     short i;
  1146.             
  1147.     for(i=1; i<=(nNational+1);i++)
  1148.         if ((choice+1) == i)                    /* Check the Current NatLang */
  1149.             CheckItem( myMenus[National], i, TRUE);
  1150.         else
  1151.             CheckItem( myMenus[National], i, FALSE);
  1152.  
  1153. }
  1154.  
  1155. /*
  1156.  *    extractmenu - remove a connection from the menu.
  1157.  */
  1158.  
  1159. void extractmenu(short screen)
  1160. {
  1161.     DelMenuItem(myMenus[Conn], screen + FIRST_CNXN_ITEM);
  1162.     AdjustMenus();
  1163. }
  1164.  
  1165. /*
  1166.  *    addinmenu - add a connection's name to the menu in position pnum. (name is
  1167.  *        an str255 pointed at by temps).
  1168.  */
  1169.  
  1170. void addinmenu( short screen, Str255 temps, char mark)
  1171. {
  1172.     InsMenuItem(myMenus[Conn], "\pDoh", (screen-1) + FIRST_CNXN_ITEM);
  1173.     SetItem(myMenus[Conn], screen + FIRST_CNXN_ITEM, temps);        // Avoid metas
  1174.     SetItemMark( myMenus[Conn], screen + FIRST_CNXN_ITEM, mark);
  1175.     AdjustMenus();
  1176. }
  1177.  
  1178. /*    Set the item mark for <scrn> to opening connection */
  1179. void SetMenuMarkToOpeningForAGivenScreen( short scrn)
  1180. {
  1181.     unsigned char c=0xa5;
  1182.  
  1183.     SetItemMark( myMenus[Conn], scrn + FIRST_CNXN_ITEM, c );
  1184. }
  1185.  
  1186. /*    Set the item mark for <scrn> to opened connection */
  1187. void SetMenuMarkToLiveForAGivenScreen( short scrn)
  1188. {
  1189.     SetItemMark( myMenus[Conn], scrn + FIRST_CNXN_ITEM, noMark);
  1190.     AdjustMenus();
  1191. }
  1192.  
  1193. void DoTheMenuChecks(void)
  1194. {
  1195.     short    active;
  1196.     short    windownum;
  1197.  
  1198.     if (TelInfo->numwindows>0)
  1199.         {
  1200.         EnableItem( myMenus[Conn],0);
  1201.         EnableItem(myMenus[Keypad], 0);            /* Baylor */
  1202.         EnableItem(myMenus[Function], 0);        /* Baylor */
  1203.         DrawMenuBar();
  1204.         }
  1205.  
  1206.     else 
  1207.         {
  1208.         DisableItem(myMenus[Conn],0);
  1209.         DisableItem(myMenus[Keypad], 0);        /* Baylor */
  1210.         DisableItem(myMenus[Function], 0);        /* Baylor */
  1211.         DrawMenuBar();
  1212.         }
  1213.  
  1214.     active =0;
  1215.     
  1216.     for (windownum=0;windownum<TelInfo->numwindows;windownum++)
  1217.         if (screens[windownum].active == CNXN_ACTIVE) active++;
  1218.         
  1219.     if (active<2)    
  1220.         DisableItem(myMenus[Conn],COnext);
  1221.     else EnableItem(myMenus[Conn],COnext);
  1222.  
  1223.     if (!active)
  1224.         {
  1225. /*        DisableItem(myMenus[Edit],EDcopy);
  1226.         DisableItem(myMenus[Edit],EDcopyt); */
  1227.         DisableItem(myMenus[Edit],EDpaste);
  1228.         DisableItem(myMenus[Emul],0);
  1229.         DrawMenuBar();
  1230.         }
  1231.     else 
  1232.         {
  1233. /*        EnableItem(myMenus[Edit],EDcopy);
  1234.         EnableItem(myMenus[Edit],EDcopyt); */
  1235.         EnableItem(myMenus[Edit],EDpaste);
  1236.         EnableItem( myMenus[Emul],0);
  1237.         DrawMenuBar();
  1238.         }
  1239. }
  1240.  
  1241.  
  1242.  
  1243. /*--------------------------------------------------------------------------*/
  1244. /* SetupMenusForSelection                                                    */
  1245. /* If there is a selection on screen, then let the user copy and print.        */
  1246. /* If not, then, oh well....just disable the menus and forget about it        */
  1247. /* ...and to think that this good stuff USED to be in rsmac.c.                 */
  1248. /* This is called from RSselect after the user clicks in the window, and     */
  1249. /* was moved here for modularity    - SMB                                    */
  1250. /*--------------------------------------------------------------------------*/
  1251. void SetMenusForSelection (short selected)                    /* NCSA: SB */    
  1252. {                                                            /* NCSA: SB */
  1253.     if (!selected)                                            /* NCSA: SB */
  1254.         {                                                    /* NCSA: SB */
  1255.         DisableItem(myMenus[Fil],FLprint);                    /* NCSA: SB */
  1256.         DisableItem(myMenus[Edit],EDcopy);                    /* NCSA: SB */
  1257.         DisableItem(myMenus[Edit],EDcopyt);                    /* NCSA: SB */
  1258.         }                                                    /* NCSA: SB */
  1259.     else                                                     /* NCSA: SB */
  1260.         {                                                    /* NCSA: SB */
  1261.         EnableItem(myMenus[Fil],FLprint);                    /* NCSA: SB */
  1262.         EnableItem(myMenus[Edit],EDcopy);                    /* NCSA: SB */
  1263.         EnableItem(myMenus[Edit],EDcopyt);                    /* NCSA: SB */
  1264.         }                                                    /* NCSA: SB */
  1265. }                                                            /* NCSA: SB */
  1266.  
  1267.  
  1268. /*----------------------------------------------------------------------*/
  1269. /* NCSA: SB - SetColumnWidth                                            */
  1270. /*    Allow the user to FINALLY pick how many columns he wants on the     */
  1271. /*    screen.  Set up a dialog box to pick the # of columns, and then        */
  1272. /*    size-up the Telnet screen accordingly.  NOTE: The user still needs    */
  1273. /*     to do a "resize", unless he is using NAWS                            */
  1274. /*----------------------------------------------------------------------*/
  1275. void SetScreenDimensions(short scrn)
  1276. {
  1277.     DialogPtr    dtemp;
  1278.     Str255        ColumnsSTR, LinesSTR;
  1279.     long        columns, lines;
  1280.     short        ditem, notgood;
  1281.     
  1282.     dtemp=GetNewMyDialog( SizeDLOG, NULL, kInFront, (void *)ThirdCenterDialog); 
  1283.     
  1284.     SetCursor(theCursors[normcurs]);
  1285.  
  1286.     notgood = 1;
  1287.     lines = VSgetlines(screens[scrn].vs);
  1288.     columns = VSgetcols(screens[scrn].vs) + 1;
  1289.     
  1290.     while (notgood) {
  1291.         notgood = 0;                                /* Default to good */
  1292.         NumToString(columns, ColumnsSTR);
  1293.         NumToString(lines, LinesSTR);
  1294.         SetTEText(dtemp, ColumnsNumber, ColumnsSTR);
  1295.         SetTEText(dtemp, LinesNumber, LinesSTR);
  1296.         SelIText( dtemp, ColumnsNumber, 0, 32767);
  1297.     
  1298.         ditem = 3;
  1299.         while(ditem>2)
  1300.             ModalDialog(DLOGwOK_CancelUPP, &ditem);
  1301.     
  1302.         if (ditem == DLOGCancel) {
  1303.             DisposeDialog( dtemp);
  1304.             return;
  1305.             }
  1306.         
  1307.         GetTEText(dtemp, ColumnsNumber, ColumnsSTR);
  1308.         StringToNum(ColumnsSTR, &columns);
  1309.         GetTEText(dtemp, LinesNumber, LinesSTR);
  1310.         StringToNum(LinesSTR, &lines);
  1311.         
  1312.         if (columns < 10) {
  1313.             columns = 10;
  1314.             notgood = 1;
  1315.             }
  1316.         else if (columns > 132) {
  1317.             columns = 132;
  1318.             notgood = 1;
  1319.             }
  1320.  
  1321.         if (lines < 10) {
  1322.             lines = 10;
  1323.             notgood = 1;
  1324.             }
  1325.         else if (lines > 200) {
  1326.             lines = 200;
  1327.             notgood = 1;
  1328.             }
  1329.         
  1330.         if (notgood) SysBeep(4);
  1331.     }
  1332.     
  1333.     DisposeDialog( dtemp);
  1334.     
  1335.     VSsetlines( screens[scrn].vs, lines);
  1336.     RScalcwsize( screens[scrn].vs, columns);
  1337. /*    RSsize( screens[scrn].wind, NULL, 0); */
  1338.  
  1339.     if (screens[scrn].naws)
  1340.         SendNAWSinfo(&screens[scrn], (short)columns, (short)lines);
  1341.         
  1342.     updateCursor(1);
  1343. }
  1344.  
  1345. void    ChangeWindowName(WindowPtr    theWindow)
  1346. {
  1347.     DialogPtr    dptr;
  1348.     short        itemHit;
  1349.     Str255        theName;
  1350.  
  1351.     if( theWindow != NULL) {
  1352.         InitCursor();
  1353.         dptr = GetNewMySmallDialog(WinTitlDLOG, NULL, kInFront, (void *)ThirdCenterDialog );
  1354.  
  1355.         GetWTitle(theWindow, theName); 
  1356.         SetTEText( dptr, kWinNameTE, theName);
  1357.         SelIText( dptr, kWinNameTE, 0, 250 );
  1358.  
  1359.         itemHit = 0;
  1360.         while(itemHit != DLOGOk && itemHit != DLOGCancel)
  1361.             ModalDialog(DLOGwOK_CancelUPP, &itemHit);
  1362.         
  1363.         if(itemHit == DLOGOk) {
  1364.             GetTEText(dptr, kWinNameTE, theName);
  1365.             set_new_window_name(theName, theWindow);
  1366.             }
  1367.             
  1368.         DisposDialog(dptr);
  1369.         }
  1370. }
  1371.  
  1372. void    set_new_window_name(Str255 theName, WindowPtr theWindow)
  1373. {
  1374.     short    i;
  1375.     
  1376.     if(theName[0]) {
  1377.         i = WindowPtr2ScreenIndex(theWindow);
  1378.         if (i >= 0) {
  1379.             i += FIRST_CNXN_ITEM;
  1380.             SetWTitle(theWindow, theName);
  1381.             SetItem(myMenus[Conn], i, theName);
  1382.             }
  1383.         }
  1384. }
  1385.