home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / modem / cvt100.zip / VTSETUP.C < prev    next >
Text File  |  1988-08-03  |  25KB  |  767 lines

  1. #include <stdio.h>
  2. #include <dos.h>
  3.  
  4. #define F1    0x3B00              /* Scancode for function key F1  */
  5. #define F2    0x3C00              /* Scancode for function key F2  */
  6. #define F3    0x3D00              /* Scancode for function key F3  */
  7. #define F4    0x3E00              /* Scancode for function key F4  */
  8. #define F5    0x3F00              /* Scancode for function key F5  */
  9. #define F6    0x4000              /* Scancode for function key F6  */
  10. #define F7    0x4100              /* Scancode for function key F7  */
  11. #define F8    0x4200              /* Scancode for function key F8  */
  12. #define F9    0x4300              /* Scancode for function key F9  */
  13. #define F10   0x4400              /* Scancode for function key F10 */
  14. #define ESC   0x011b              /* Scancode for ESCape key */
  15.  
  16. /*****************************************************************************/
  17. /* function prototypes                                                       */
  18.  
  19. void TTSetup( void );             /* Communications setup function */
  20. void VidSetup( void );            /* Video setup function */
  21. void KeySetup( void );            /* Keyboard setup function */
  22. void VTSetup( void );             /* VT emulation setup */
  23. void FileSetup( void );           /* File system setup */
  24.  
  25. static void ToggleBaud( void );        /* Toggle the baud setting */
  26. static void TogglePort( void );        /* Toggle the port setting */
  27. static void ToggleParity( void );      /* Toggle the parity setting */
  28. static void ToggleDataBits( void );    /* Toggle the databits setting */
  29. static void ToggleStopBits( void );    /* Toggle the stopbits setting */
  30. static void DisplayBaud( void );       /* Display the baud setting */
  31. static void DisplayPort( void );       /* Display the port setting */
  32. static void DisplayParity( void );     /* Display the parity setting */
  33. static void DisplayDataBits( void );   /* Display the databits setting */
  34. static void DisplayStopBits( void );   /* Display the stopbits setting */
  35. static void ToggleRetrace( void );     /* Toggle the video retrace mode */
  36. static void DisplayRetrace( void );    /* Display the video retrace mode */
  37. static void ToggleBackSpace( void );   /* Toggle the backspace interpretation */
  38. static void DisplayBackSpace( void );  /* Display backspace interpretation */
  39. static void ToggleKeyClick( void );    /* Toggle the key click mode */
  40. static void DisplayKeyClick( void );   /* Display the Keyclick mode */
  41. static void ToggleKeyPadMode( void );  /* Toggle the key pad mode */
  42. static void DisplayKeyPadMode( void ); /* Display the Key Pad mode */
  43. static void ToggleForeColor( void );   /* Toggle foreground colors */
  44. static void DisplayForeColor( void );  /* Display the foreground colors */
  45. static void ToggleBackColor( void );   /* Toggle background colors */
  46. static void DisplayBackColor( void );  /* Display the background colors */
  47. static void ToggleOriginMode( void );  /* Toggle the origin Mode */
  48. static void ToggleInsertMode( void );  /* Toggle the Insert/replace Mode */
  49. static void ToggleAutoWrapMode( void );/* Toggle auto wrap mode */
  50. static void ToggleNewLine( void );     /* Toggle new line mode */
  51. static void ToggleCursorVisible( void );/* Toggle cursor visibility */
  52. static void ToggleReverseBackGround( void );/* Toggle reversed background mode */
  53. static void ToggleScreenWid( void );   /* Toggle the screen width setting */
  54. static void DisplayOriginMode( void ); /* Display the origin Mode */
  55. static void DisplayInsertMode( void ); /* Display the Insert/replace Mode */
  56. static void DisplayAutoWrapMode( void );/* Display auto wrap mode */
  57. static void DisplayNewLine( void );    /* Display new line mode */
  58. static void DisplayCursorVisible( void );/* Display cursor visibility */
  59. static void DisplayReverseBackGround( void );/* Display reversed background mode */
  60. static void DisplayScreenWid( void );  /* Display the screen width setting */
  61. static void DisplaySaveSetup( void );  /* Display Setup saved status */
  62. static void ToggleLogMode( void );     /* Toggle Log File mode */
  63. static void DisplayLogMode( void );    /* Display status of Log File */
  64. static void StartSetup(char *);        /* Begin a setup screen */
  65. static void EndSetup( void );          /* End a setup screen */
  66.  
  67. unsigned int GetKey( void );      /* Function to retrieve a keystroke */
  68.  
  69. /*****************************************************************************/
  70. /* Global Data                                                               */
  71.  
  72.  
  73. /*****************************************************************************/
  74. /* External Data                                                             */
  75.  
  76. extern unsigned int port;         /* COM port */
  77. extern unsigned int speed;        /* BAUD rate */
  78. extern char parity[5];            /* Parity setting */
  79. extern unsigned int databits;     /* Number of Data bits */
  80. extern unsigned int stopbits;     /* Number of Stop bits */
  81.  
  82. extern unsigned char retracemode; /* Video snow retrace wait mode flag */
  83. extern unsigned char forecolor;   /* Default foreground color */
  84. extern unsigned char backcolor;   /* Default background color */
  85.  
  86. extern unsigned char backspace;   /* Backspace interpretation flag */
  87. extern unsigned char keyclick;    /* Keyclick on/off flag */
  88. extern unsigned char applkeypad;  /* Application key pad mode flag */
  89.  
  90. extern unsigned originmode;       /* Origin mode, relative or absolute */
  91. extern unsigned insertmode;       /* Insert mode, off or on */
  92. extern unsigned autowrap;         /* Automatic wrap mode, off or on */
  93. extern unsigned newline;          /* Newline mode, off or on,  GLOBAL data!*/
  94. extern unsigned cursorvisible;    /* Cursor visibility, on or hidden */
  95. extern unsigned reversebackground;/* Reverse background attribute, on or off*/
  96. extern unsigned screenwid;        /* Screen column width */
  97. extern unsigned char log;         /* Logging characters */
  98.  
  99. extern char setupfile[];          /* Filename of setup file */
  100. extern char logfile[];            /* Filename of log file */
  101. extern unsigned char vidmode;     /* Video mode */
  102.  
  103. /*****************************************************************************/
  104. /* Local Static Data                                                               */
  105.  
  106. static char *vcolors[] = {        /* Array of color names */
  107.     "BLACK",        "BLUE",           "GREEN",
  108.     "CYAN",         "RED",            "MAGENTA",
  109.     "BROWN",        "LIGHTGRAY",      "DARKGRAY",
  110.     "LIGHTBLUE",    "LIGHTGREEN",     "LIGHTCYAN",
  111.     "LIGHTRED",     "LIGHTMAGENTA",   "YELLOW",
  112.     "WHITE",
  113.     };
  114.  
  115. static unsigned holdbackground;   /* Temporary holder for background setting */
  116. static unsigned char saved;       /* Flag indication setup already saved */
  117. /*****************************************************************************/
  118. /*****************************************************************************/
  119.  
  120. /*  T T S E T U P -- Enter Communications Setup Mode */
  121.  
  122. void TTSetup() {
  123.    int thru = 0;
  124.    int changes = 0;
  125.  
  126.  
  127.    StartSetup("Communications");  /* Begin this Setup Screen */
  128.  
  129.    DisplayPort();                 /* Display initial current port setting */
  130.    DisplayBaud();                 /* Display initial current baud rate setting */
  131.    DisplayParity();               /* Display initial current parity setting */
  132.    DisplayDataBits();             /* Display initial current data bits setting */
  133.    DisplayStopBits();             /* Display initial current stop bits setting */
  134.  
  135.    while( !thru ) {
  136.  
  137.       switch (GetKey()) {
  138.           case F1:                /* Toggle the COM port setting */
  139.               TogglePort();
  140.               DisplayPort();
  141.               changes = 1;
  142.               break;
  143.           case F2:                /* Toggle the baud rate setting */
  144.               ToggleBaud();
  145.               DisplayBaud();
  146.               changes = 1;
  147.               break;
  148.           case F3:                /* Toggle the parity setting */
  149.               ToggleParity();
  150.               DisplayParity();
  151.               changes = 1;
  152.               break;
  153.           case F4:                /* Toggle the data bits setting */
  154.               ToggleDataBits();
  155.               DisplayDataBits();
  156.               changes = 1;
  157.               break;
  158.           case F5:                /* Toggle the stop bits setting */
  159.               ToggleStopBits();
  160.               DisplayStopBits();
  161.               changes = 1;
  162.               break;
  163.           case F10:
  164.           case ESC:
  165.               thru = 1;
  166.               break;
  167.           default:
  168.       }
  169.    }
  170.    RestoreScreen();               /* Restore the initial emulation screen */
  171.    if (changes) {                 /* If changes have been made */
  172.       ttclose();                    /* Close the port */
  173.       ttopen();                     /* Reopen the port to update COM values */
  174.    }
  175. }
  176.  
  177.  
  178.  
  179.  
  180. /*  T O G G L E P O R T -- toggle the COM port setting */
  181.  
  182. static void TogglePort() {
  183.    static int vports[] = {        /* Array of Valid port settings */
  184.        1, 2,
  185.        0 };                       /* Terminated by a 0 */
  186.    static int * pptr = vports;    /* Pointer to port value setting in array */
  187.  
  188.    ++pptr;                      /* look at next port setting in array */
  189.    if (*pptr == 0)              /* if setting is 0 then time for wrap */
  190.       pptr = vports;
  191.    port = *pptr;                /* set the port to this setting */
  192. }
  193.  
  194.  
  195.  
  196. /*  T O G G L E B A U D -- Toggle the baud rate setting */
  197.  
  198. static void ToggleBaud() {
  199.    static int vbauds[] = {        /* Array of valid baud rate settings */
  200.        50, 75, 110, 150, 300,
  201.        600, 1200, 1800, 2000,
  202.        2400, 4800, 9600, 19200,
  203.        38400,                     /* Terminated by a 0 */
  204.        0 };
  205.    static int *bptr = &vbauds[9]; /* Pointer to baud rate setting in array */
  206.  
  207.    ++bptr;                        /* look at next baud rate setting in array */
  208.    if (*bptr == 0)                /* if setting is 0 then time for wrap */
  209.       bptr = vbauds;
  210.    speed = *bptr;                 /* Set the speed to this setting */
  211. }
  212.  
  213.  
  214.  
  215. /*  T O G G L E P A R I T Y -- Toggle the parity setting */
  216.  
  217. static void ToggleParity() {
  218.    static char *vparitys[] = {    /* Array of valid parity settings */
  219.        "NONE", "EVEN", "ODD",
  220.        NULL };                    /* Terminated by a NULL */
  221.    static char **pptr = vparitys; /* Pointer to parity setting in array */
  222.  
  223.    ++pptr;                        /* look at next parity setting in array */
  224.    if (*pptr == NULL)             /* if setting == NULL then time for wrap */
  225.       pptr = vparitys;
  226.    strcpy(parity,*pptr);          /* set the parity to this setting */
  227. }
  228.  
  229.  
  230.  
  231. /*  T O G G L E D A T A B I T S -- Toggle databits setting */
  232.  
  233. static void ToggleDataBits() {
  234.    static int vdatabits[] = {     /* Array of valid databit settings */
  235.        5,6,7,8,
  236.        0 };                       /* Terminated by a 0 */
  237.    static int *dptr=vdatabits;    /* Pointer to databit setting in array */
  238.  
  239.    ++dptr;                        /* look at next databit setting in array */
  240.    if (*dptr == 0)                /* if setting is 0 then time for wrap */
  241.       dptr = vdatabits;
  242.    databits = *dptr;              /* set the databits to this setting */
  243. }
  244.  
  245.  
  246.  
  247. /*  T O G G L E S T O P B I T S -- Toggle StopBits setting */
  248.  
  249. static void ToggleStopBits() {
  250.    static int vstopbits[] = {     /* Array of valid stopbit settings */
  251.        1,2,
  252.        0 };                       /* Terminated by a 0 */
  253.    static int *sptr=&vstopbits[0];/* Pointer to stopbit setting in array */
  254.  
  255.    ++sptr;                        /* look at next stopbits setting in array */
  256.    if (*sptr == 0)                /* if setting is 0 then time for wrap */
  257.        sptr = vstopbits;
  258.    stopbits = *sptr;              /* set the stopbits to this setting */
  259. }
  260.  
  261. /*  D I S P L A Y P O R T -- Display COM port setting */
  262.  
  263. static void DisplayPort() {
  264.    vtprintf(5,2,0," F1)  COM port  = %5d",port);
  265. }
  266.  
  267.  
  268. /*  D I S P L A Y B A U D -- Display baud rate setting */
  269.  
  270. static void DisplayBaud() {
  271.    vtprintf(7,2,0," F2)  Baud rate = %5u",speed);
  272. }
  273.  
  274.  
  275. /*  D I S P L A Y P A R I T Y -- Display parity setting */
  276.  
  277. static void DisplayParity() {
  278.    vtprintf(9,2,0," F3)  Parity =     %4s",parity);
  279. }
  280.  
  281.  
  282. /*  D I S P L A Y D A T A B I T S -- Display databits setting */
  283.  
  284. static void DisplayDataBits() {
  285.    vtprintf(11,2,0," F4)  Data bits = %4d",databits);
  286. }
  287.  
  288.  
  289. /*  D I S P L A Y S T O P B I T S -- Display stopbits setting */
  290.  
  291. static void DisplayStopBits() {
  292.    vtprintf(13,2,0," F5)  Stop bits = %4d",stopbits);
  293. }
  294.  
  295. /*****************************************************************************/
  296.  
  297.  
  298. /*  V I D S E T U P -- Enter Video Setup Mode */
  299.  
  300. void VidSetup() {
  301.    int thru = 0;
  302.    int colorchange = 0;
  303.  
  304.    StartSetup("Video");           /* Begin this Setup Screen */
  305.  
  306.  
  307.    DisplayRetrace();              /* Display initial retrace mode setting */
  308.    DisplayForeColor();            /* Display initial foreground color */
  309.    DisplayBackColor();            /* Display initial background color */
  310.  
  311.    while( !thru ) {
  312.  
  313.       switch (GetKey()) {
  314.           case F1:                /* Toggle the Retrace mode setting */
  315.               ToggleRetrace();
  316.               DisplayRetrace();
  317.               break;
  318.           case F2:                /* Toggle the Foreground color */
  319.               ToggleForeColor();
  320.               DisplayForeColor();
  321.               colorchange = 1;
  322.               break;
  323.           case F3:                /* Toggle the Background color */
  324.               ToggleBackColor();
  325.               DisplayBackColor();
  326.               colorchange = 1;
  327.               break;
  328.           case F10:
  329.           case ESC:
  330.               thru = 1;
  331.               break;
  332.           default:
  333.       }
  334.    }
  335.  
  336.    RestoreScreen();               /* Restore the initial emulation screen */
  337.    if (colorchange)
  338.       SetColor();
  339. }
  340.  
  341.  
  342. /*  T O G G L E R E T R A C E -- Toggle Video Retrace mode setting */
  343.  
  344. static void ToggleRetrace() {
  345.  
  346.    if (vidmode != 7)              /* Don't allow toggling on a monochrome */
  347.       retracemode ^= 1;
  348.    else {
  349.       retracemode = 0;
  350.       sound(324);
  351.       delay(400);
  352.       nosound();
  353.    }
  354. }
  355.  
  356. /*  T O G G L E F O R E C O L O R -- Toggle the foreground color */
  357.  
  358. static void ToggleForeColor() {
  359.  
  360.    if (++forecolor >= 16)         /* Index to next color Setting */
  361.       forecolor = 0;              /*  watch for wrap when past WHITE */
  362. }
  363.  
  364. /*  T O G G L E B A C K C O L O R -- Toggle the background color */
  365.  
  366. static void ToggleBackColor() {
  367.  
  368.    if (++backcolor >= 8)          /* Index to next color Setting */
  369.       backcolor = 0;              /*  watch for wrap when past LIGHTGREY */
  370. }
  371.  
  372.  
  373. /*  D I S P L A Y R E T R A C E -- Display video retrace mode setting */
  374.  
  375. static void DisplayRetrace() {
  376.    vtprintf(5,2,0," F1)  Video Snow Retrace Wait = %s",
  377.       (retracemode == 0 ? "OFF" : "ON "));
  378. }
  379.  
  380.  
  381. /*  D I S P L A Y F O R E C O L O R -- Display foreground color */
  382.  
  383. static void DisplayForeColor() {
  384.    vtprintf(7,2,0," F2)  Foreground Color = %12s",vcolors[forecolor]);
  385. }
  386.  
  387.  
  388. /*  D I S P L A Y B A C K C O L O R -- Display background color */
  389.  
  390. static void DisplayBackColor() {
  391.    vtprintf(9,2,0," F3)  Background Color = %12s",vcolors[backcolor]);
  392. }
  393.  
  394.  
  395.  
  396.  
  397. /*****************************************************************************/
  398.  
  399.  
  400. /*  K E Y S E T U P -- Enter Keyboard Setup Mode */
  401.  
  402. void KeySetup() {
  403.    int thru = 0;
  404.  
  405.    StartSetup("KeyBoard");        /* Begin this Setup Screen */
  406.  
  407.    DisplayBackSpace();            /* Display initial retrace mode setting */
  408.    DisplayKeyClick();             /* Display initial Key Click mode setting */
  409.    DisplayKeyPadMode();           /* Display initial Key Pad mode setting */
  410.  
  411.    while( !thru ) {
  412.  
  413.       switch (GetKey()) {
  414.           case F1:                /* Toggle the Backspace key interpretation*/
  415.               ToggleBackSpace();
  416.               DisplayBackSpace();
  417.               break;
  418.           case F2:                /* Toggle the KeyClick Setting */
  419.               ToggleKeyClick();
  420.               DisplayKeyClick();
  421.               break;
  422.           case F3:                /* Toggle the KeyPadMode Setting */
  423.               ToggleKeyPadMode();
  424.               DisplayKeyPadMode();
  425.               break;
  426.           case F10:
  427.           case ESC:
  428.               thru = 1;
  429.               break;
  430.           default:
  431.       }
  432.    }
  433.    RestoreScreen();               /* Restore the initial emulation screen */
  434.  
  435. }
  436.  
  437.  
  438. /*  T O G G L E B A C K S P A C E -- Toggle Backspace interpretation */
  439.  
  440. static void ToggleBackSpace() {
  441.  
  442.    backspace ^= 1;
  443. }
  444.  
  445. /*  T O G G L E K E Y C L I C K -- Toggle Keyclick mode */
  446.  
  447. static void ToggleKeyClick() {
  448.  
  449.    keyclick ^= 1;
  450. }
  451.  
  452. /*  T O G G L E K E Y P A D M O D E -- Toggle KeyPad mode */
  453.  
  454. static void ToggleKeyPadMode() {
  455.  
  456.    applkeypad ^= 1;
  457. }
  458.  
  459.  
  460. /*  D I S P L A Y B A C K S P A C E -- Display backspace interpretation */
  461.  
  462. static void DisplayBackSpace() {
  463.    vtprintf(5,2,0," F1)  BackSpace Interpretation = %s",
  464.       (backspace == 0 ? "DELETE   " : "BACKSPACE"));
  465. }
  466.  
  467.  
  468. /*  D I S P L A Y K E Y C L I C K -- Display keyclick mode */
  469.  
  470. static void DisplayKeyClick() {
  471.    vtprintf(7,2,0," F2)  KeyClick is %s",
  472.       (keyclick == 0 ? "OFF" : "ON "));
  473. }
  474.  
  475. /*  D I S P L A Y K E Y P A D M O D E -- Display keypad mode */
  476.  
  477. static void DisplayKeyPadMode() {
  478.    vtprintf(9,2,0," F3)  Key Pad is set to %s",
  479.       (applkeypad == 0 ? "NUMERIC    " : "APPLICATION"));
  480. }
  481.  
  482.  
  483. /*****************************************************************************/
  484.  
  485.  
  486. /*  V T S E T U P -- Enter Emulation Setup Mode */
  487.  
  488. void VTsetup() {
  489.    int thru = 0;
  490.    int cursorchange = 0;
  491.    int backgroundchange = 0;
  492.    int screenwidchange = 0;
  493.  
  494.    holdbackground = reversebackground; /* Get value of background setting */
  495.  
  496.    StartSetup("Emulation");       /* Begin this Setup Screen */
  497.  
  498.    DisplayOriginMode();           /* Display initial origin mode setting */
  499.    DisplayInsertMode();           /* Display initial insert mode setting */
  500.    DisplayAutoWrapMode();         /* Display initial autowrap mode setting */
  501.    DisplayNewLine();              /* Display initial newline mode setting */
  502.    DisplayCursorVisible();        /* Display initial cursorvisible setting */
  503.    DisplayReverseBackGround();    /* Display initial setting for backgroun */
  504.    DisplayScreenWid();            /* Display initial logical screen width */
  505.  
  506.    while( !thru ) {
  507.  
  508.       switch (GetKey()) {
  509.           case F1:                /* Toggle origin mode setting */
  510.               ToggleOriginMode();
  511.               DisplayOriginMode();
  512.               break;
  513.           case F2:                /* Toggle insert mode setting */
  514.               ToggleInsertMode();
  515.               DisplayInsertMode();
  516.               break;
  517.           case F3:                /* Toggle autowrap mode setting */
  518.               ToggleAutoWrapMode();
  519.               DisplayAutoWrapMode();
  520.               break;
  521.           case F4:                /* Toggle newline mode setting */
  522.               ToggleNewLine();
  523.               DisplayNewLine();
  524.               break;
  525.           case F5:                /* Toggle cursor visibility */
  526.               ToggleCursorVisible();
  527.               DisplayCursorVisible();
  528.               cursorchange = 1;
  529.               break;
  530.           case F6:                /* Toggle background appearance */
  531.               ToggleReverseBackGround();
  532.               DisplayReverseBackGround();
  533.               backgroundchange = 1;
  534.               break;
  535.           case F7:                /* Toggle screen width */
  536.               ToggleScreenWid();
  537.               DisplayScreenWid();
  538.               screenwidchange = 1;
  539.               break;
  540.  
  541.           case F10:
  542.           case ESC:
  543.               thru = 1;
  544.               break;
  545.           default:
  546.       }
  547.    }
  548.  
  549.    RestoreScreen();               /* Restore the initial emulation screen */
  550.    if (cursorchange)              /* Change the cursor type if needed */
  551.       SetCursorVisibility(cursorvisible);
  552.    if (backgroundchange)          /* Change the background if needed */
  553.       SetBackGround(holdbackground);
  554.    if (screenwidchange)           /* Change the screenwidth if needed */
  555.       SetScreenWidth(screenwid);
  556. }
  557.  
  558. /*  T O G G L E O R I G I N M O D E -- Toggle the origin mode */
  559.  
  560. static void ToggleOriginMode() {
  561.  
  562.    originmode ^= 1;
  563. }
  564.  
  565. /*  T O G G L E I N S E R T M O D E -- Toggle insert/replace mode */
  566.  
  567. static void ToggleInsertMode() {
  568.  
  569.    insertmode ^= 1;
  570. }
  571.  
  572.  
  573. /*  T O G G L E A U T O W R A P -- Toggle the autowrap mode */
  574.  
  575. static void ToggleAutoWrapMode() {
  576.  
  577.    autowrap ^= 1;
  578. }
  579.  
  580.  
  581. /*  T O G G L E N E W L I N E -- Toggle the newline mode */
  582.  
  583. static void ToggleNewLine() {
  584.  
  585.    newline ^= 1;
  586. }
  587.  
  588.  
  589. /*  T O G G L E C U R S O R V I S I B L E -- Toggle the cursor visibility */
  590.  
  591. static void ToggleCursorVisible() {
  592.  
  593.    cursorvisible ^= 1;
  594. }
  595.  
  596.  
  597. /*  T O G G L E R E V E R S E B A C K G R O U N D -- Toggle background */
  598.  
  599. static void ToggleReverseBackGround() {
  600.  
  601.    holdbackground ^= 1;
  602. }
  603.  
  604. /*  T O G G L E S C R E E N W I D -- Toggle the screen width */
  605.  
  606. static void ToggleScreenWid() {
  607.  
  608.    if (screenwid == 80)
  609.        screenwid = 132;
  610.    else
  611.        screenwid = 80;
  612. }
  613.  
  614.  
  615. /*  D I S P L A Y O R I G I N M O D E -- Display the origin mode */
  616.  
  617. static void DisplayOriginMode() {
  618.    vtprintf(7,2,0," F1)  Origin Mode is %s",
  619.       (originmode == 0 ? "ABSOLUTE" : "RELATIVE"));
  620.  
  621. }
  622.  
  623. /*  D I S P L A Y I N S E R T M O D E -- Display insert/replace mode */
  624.  
  625. static void DisplayInsertMode() {
  626.    vtprintf(9,2,0," F2)  Insert/Replace mode is set to %s",
  627.       (insertmode == 0 ? "REPLACE" : "INSERT  "));
  628.  
  629. }
  630.  
  631.  
  632. /*  D I S P L A Y A U T O W R A P -- Display the autowrap mode */
  633.  
  634. static void DisplayAutoWrapMode() {
  635.    vtprintf(11,2,0," F3)  Auto Wrap mode is %s",
  636.       (autowrap == 0 ? "OFF" : "ON "));
  637.  
  638. }
  639.  
  640.  
  641. /*  D I S P L A Y N E W L I N E -- Display the newline mode */
  642.  
  643. static void DisplayNewLine() {
  644.    vtprintf(13,2,0," F4)  New Line mode is %s",
  645.       (newline == 0 ? "OFF" : "ON "));
  646.  
  647. }
  648.  
  649.  
  650. /*  D I S P L A Y C U R S O R V I S I B L E -- Display the cursor visibility */
  651.  
  652. static void DisplayCursorVisible() {
  653.    vtprintf(15,2,0," F5)  Cursor is %s",
  654.       (cursorvisible == 0 ? "HIDDEN " : "VISIBLE"));
  655.  
  656. }
  657.  
  658.  
  659. /*  D I S P L A Y R E V E R S E B A C K G R O U N D -- Display background */
  660.  
  661. static void DisplayReverseBackGround() {
  662.    vtprintf(17,2,0," F6)  Background is %s",
  663.       (holdbackground == 0 ? "NORMAL  " : "REVERSED"));
  664.  
  665. }
  666.  
  667. /*  D I S P L A Y S C R E E N W I D -- Display the screen width */
  668.  
  669. static void DisplayScreenWid() {
  670.    vtprintf(19,2,0," F7)  Logical Screen width is %3d columns",screenwid);
  671. }
  672.  
  673. /*****************************************************************************/
  674.  
  675.  
  676. /*  F I L E S E T U P -- Enter File Setup Mode */
  677.  
  678. void FileSetup() {
  679.    int thru = 0;
  680.  
  681.    StartSetup("File");           /* Begin this Setup Screen */
  682.    saved = 0;                    /* Start with information not saved */
  683.  
  684.    DisplaySaveSetup();           /* Display initially unsaved setup */
  685.    DisplayLogMode();             /* Display status of Log File */
  686.  
  687.    while( !thru ) {
  688.  
  689.       switch (GetKey()) {
  690.           case F1:                /* Save the setup information to disk */
  691.               SaveSetup();
  692.               saved = 1;
  693.               DisplaySaveSetup();
  694.               break;
  695.           case F2:                /* Set/reset logging to disk */
  696.               ToggleLogMode();
  697.               DisplayLogMode();
  698.               if (log)
  699.                  OpenLogFile();
  700.               else
  701.                  CloseLogFile();
  702.               break;
  703.           case F10:
  704.           case ESC:
  705.               thru = 1;
  706.               break;
  707.           default:
  708.       }
  709.    }
  710.  
  711.    RestoreScreen();               /* Restore the initial emulation screen */
  712. }
  713.  
  714.  
  715. /*  T O G G L E L O G M O D E -- Toggle the log file status */
  716.  
  717. static void ToggleLogMode() {
  718.    log ^= 1;
  719. }
  720.  
  721.  
  722. /*  D I S P L A Y S A V E S E T U P -- Display video retrace mode setting */
  723.  
  724. static void DisplaySaveSetup() {
  725.    vtprintf(5,2,0," F1)  Save Setup to '%s' %s",setupfile,
  726.       (saved == 0 ? " " : " *DONE*"));
  727. }
  728.  
  729. /*  D I S P L A Y L O G M O D E -- Display log file status */
  730.  
  731. static void DisplayLogMode() {
  732.  
  733.    if (log)
  734.        vtprintf(7,2,0," F2)  Logging incoming characters to '%s'",logfile);
  735.    else
  736.        vtprintf(7,2,0," F2)  Logging of incoming characters is OFF            ");
  737. }
  738.  
  739.  
  740. /*****************************************************************************/
  741.  
  742.  
  743. /* S T A R T S E T U P -- Begin a setup mode screen */
  744.  
  745. static void StartSetup(char * title) {
  746.  
  747.    SaveScreen();
  748.    ClearScreen();
  749.    vtprintf(0,0,1,"%80s"," ");
  750.    vtprintf(0,0,1,"%s %s",title,
  751.        "Setup Mode,   Use the function keys to toggle settings");
  752.    vtprintf(24,2,0,"%s %s %s","ESC) or F10)   Exit",title,"Setup");
  753. }
  754.  
  755.  
  756. /* E N D S E T U P -- End the setup mode screen */
  757.  
  758. static void EndSetup() {
  759.  
  760.    RestoreScreen();               /* Restore the pre-setup screen */
  761. }
  762.  
  763.  
  764.  
  765.  
  766.  
  767.