home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR8 / TDE32.ZIP / MAIN.C < prev    next >
C/C++ Source or Header  |  1993-11-13  |  20KB  |  727 lines

  1. /*******************  start of original comments  ********************/
  2. /*
  3.  * Written by Douglas Thomson (1989/1990)
  4.  *
  5.  * This source code is released into the public domain.
  6.  */
  7.  
  8. /*
  9.  * Name:    dte - Doug's Text Editor program - hardware dependent module
  10.  * Purpose: This file contains all the code that needs to be different on
  11.  *           different hardware.
  12.  * File:    hwibm.c
  13.  * Author:  Douglas Thomson
  14.  * System:  This particular version is for the IBM PC and close compatibles.
  15.  *           It write directly to video RAM, so it is faster than other
  16.  *           techniques, but will cause "snow" on most CGA cards. See the
  17.  *           file "hwibmcga.c" for a version that avoids snow.
  18.  *          The compiler is Turbo C 2.0, using one of the large data memory
  19.  *           models.
  20.  * Date:    October 10, 1989
  21.  * Notes:   This module has been kept as small as possible, to facilitate
  22.  *           porting between different systems.
  23.  */
  24. /*********************  end of original comments   ********************/
  25.  
  26.  
  27. /*
  28.  * These routines were rewritten for Microsoft C.  They are pretty much system
  29.  * dependent and pretty much Microsoft C dependent.  I also renamed this file
  30.  * "main.c" - easier to find the main function.
  31.  *
  32.  * New editor name:  TDE, the Thomson-Davis Editor.
  33.  * Author:           Frank Davis
  34.  * Date:             June 5, 1991, version 1.0
  35.  * Date:             July 29, 1991, version 1.1
  36.  * Date:             October 5, 1991, version 1.2
  37.  * Date:             January 20, 1992, version 1.3
  38.  * Date:             February 17, 1992, version 1.4
  39.  * Date:             April 1, 1992, version 1.5
  40.  * Date:             June 5, 1992, version 2.0
  41.  * Date:             October 31, 1992, version 2.1
  42.  * Date:             April 1, 1993, version 2.2
  43.  * Date:             June 5, 1993, version 3.0
  44.  * Date:             August 29, 1993, version 3.1
  45.  * Date:             November 13, 1993, version 3.2
  46.  *
  47.  * This modification of Douglas Thomson's code is released into the
  48.  * public domain, Frank Davis.  You may distribute it freely.
  49.  */
  50.  
  51.  
  52. char *greatest_composer_ever = "W. A. Mozart, 1756-1791";
  53.  
  54.  
  55. #include "tdestr.h"             /* tde types */
  56. #include "common.h"
  57. #include "define.h"
  58. #include "help.h"
  59. #include "tdefunc.h"
  60.  
  61.  
  62. #include <fcntl.h>              /* open flags */
  63. #if defined( __UNIX__ )
  64.  #include <signal.h>            /* unix critical errors */
  65. #else
  66.  #include <dos.h>                /* for renaming files */
  67.  #include <bios.h>               /* for direct BIOS keyboard input */
  68.  #include <io.h>                 /* for file attribute code */
  69.  #if defined( __MSC__ )
  70.    #include <errno.h>
  71.    #include <sys\types.h>       /* S_IWRITE etc */
  72.  #endif
  73.  #include <sys\stat.h>           /* S_IWRITE etc */
  74. #endif
  75.  
  76. #if defined( __MSC__ )
  77.  void (interrupt FAR *old_control_c)( ); /* variable for old CNTL-C */
  78.  void (interrupt FAR *old_int1b)( );     /* variable for old int 1b */
  79. #endif
  80.  
  81.  
  82. /*
  83.  * original control-break checking flag
  84.  */
  85. static int s_cbrk;
  86.  
  87.  
  88. /*
  89.  * Name:    main
  90.  * Purpose: To do any system dependent command line argument processing,
  91.  *           and then call the main editor function.
  92.  * Date:    October 10, 1989
  93.  * Passed:  argc:   number of command line arguments
  94.  *          argv:   text of command line arguments
  95.  */
  96. void main( int argc, char *argv[] )
  97. {
  98. #if defined( __MSC__ )
  99.    union REGS inregs, outregs;
  100. #endif
  101.  
  102.    g_status.found_first = FALSE;
  103.    g_status.arg         = 1;
  104.    g_status.argc        = argc;
  105.    g_status.argv        = argv;
  106.  
  107. #if defined( __UNIX__ )
  108.  
  109.    /*
  110.     * unix signals are kinda analagous to DOS critical errors.
  111.     */
  112. /*
  113.    signal( SIGABRT,   crit_err_handler );
  114.    signal( SIGALRM,   crit_err_handler );
  115.    signal( SIGCHLD,   crit_err_handler );
  116.    signal( SIGCONT,   crit_err_handler );
  117.    signal( SIGFPE,    crit_err_handler );
  118.    signal( SIGHUP,    crit_err_handler );
  119.    signal( SIGILL,    crit_err_handler );
  120.    signal( SIGINT,    crit_err_handler );
  121.    signal( SIGIO,     crit_err_handler );
  122.    signal( SIGIOT,    crit_err_handler );
  123.    signal( SIGKILL,   crit_err_handler );
  124.    signal( SIGPIPE,   crit_err_handler );
  125.    signal( SIGPOLL,   crit_err_handler );
  126.    signal( SIGPWR,    crit_err_handler );
  127.    signal( SIGQUIT,   crit_err_handler );
  128.    signal( SIGSEGV,   crit_err_handler );
  129.    signal( SIGSTOP,   crit_err_handler );
  130.    signal( SIGTERM,   crit_err_handler );
  131.    signal( SIGTRAP,   crit_err_handler );
  132.    signal( SIGTSTP,   crit_err_handler );
  133.    signal( SIGTTIN,   crit_err_handler );
  134.    signal( SIGTTOU,   crit_err_handler );
  135.    signal( SIGURG,    crit_err_handler );
  136.    signal( SIGUSR1,   crit_err_handler );
  137.    signal( SIGUSR2,   crit_err_handler );
  138.    signal( SIGVTALRM, crit_err_handler );
  139.    signal( SIGWINCH,  crit_err_handler );
  140.    signal( SIGXCPU,   crit_err_handler );
  141.    signal( SIGXFSZ,   crit_err_handler );
  142. */
  143. #else
  144.    /*
  145.     * trap control-break to make it harmless, and turn checking off.
  146.     *   trap control-C to make it harmless.
  147.     */
  148. # if defined( __MSC__ )
  149.    inregs.h.ah = 0x33;
  150.    inregs.h.al = 0;
  151.    intdos( &inregs, &outregs );
  152.    s_cbrk = outregs.h.dl;
  153.    old_control_c = _dos_getvect( (unsigned)0x23 );
  154.    _dos_setvect( 0x23, harmless );
  155.    old_int1b = _dos_getvect( (unsigned)0x1b );
  156.    _dos_setvect( 0x1b, ctrl_break );
  157.    inregs.h.ah = 0x33;
  158.    inregs.h.al = 1;
  159.    inregs.h.dl = 0;
  160.    intdos( &inregs, &outregs );
  161. # else
  162.    s_cbrk = getcbrk( );
  163.    ctrlbrk( harmless );
  164.    setcbrk( 0 );
  165. # endif
  166.  
  167.    /*
  168.     * now, install and initialize our simple Critical Error Handler.
  169.     */
  170.    install_ceh( &ceh );
  171. #endif
  172.  
  173.    ceh.flag = OK;
  174.  
  175.    if (initialize( ) != ERROR)
  176.       editor( );
  177.    terminate( );
  178. }
  179.  
  180.  
  181. /*
  182.  * Name:    error
  183.  * Purpose: To report an error, and usually make the user type <ESC> before
  184.  *           continuing.
  185.  * Date:    June 5, 1991
  186.  * Passed:  kind:   an indication of how serious the error was:
  187.  *                      WARNING: continue after pressing a key
  188.  *                      FATAL:   abort the editor
  189.  *          line:    line to display message
  190.  *          message: string to be printed
  191.  * Notes:   Show user the message and ask for a key if needed.
  192.  */
  193. void error( int kind, int line, char *message )
  194. {
  195. char buff[MAX_COLS+2];          /* somewhere to store error before printing */
  196. #if defined( __UNIX__ )
  197.  chtype display_buff[MAX_COLS+2];       /* chtype is defined in curses.h */
  198. #else
  199.  char display_buff[(MAX_COLS+2)*2];
  200. #endif
  201.  
  202.    /*
  203.     * tell the user what kind of an error it is
  204.     */
  205.    switch (kind) {
  206.       case FATAL:
  207.          /*
  208.           * fatal error
  209.           */
  210.          assert( strlen( main1 ) < (size_t)g_display.ncols );
  211.          strcpy( buff, main1 );
  212.          break;
  213.      case WARNING:
  214.      default:
  215.          /*
  216.           * warning
  217.           */
  218.          assert( strlen( main2 ) < (size_t)g_display.ncols );
  219.          strcpy( buff, main2 );
  220.          break;
  221.    }
  222.  
  223.    /*
  224.     * prepare the error message itself
  225.     */
  226.    strcat( buff, message );
  227.  
  228.    /*
  229.     * tell the user how to continue editing if necessary
  230.     */
  231.    if (kind == WARNING)
  232.       /*
  233.        * press a key
  234.        */
  235.       strcat( buff, main3 );
  236.  
  237.    /*
  238.     * output the error message
  239.     */
  240.    save_screen_line( 0, line, display_buff );
  241.    set_prompt( buff, line );
  242.  
  243.    if (kind == FATAL) {
  244.       /*
  245.        * no point in making the user type <ESC>, since the program is
  246.        *  about to abort anyway...
  247.        */
  248.       terminate( );
  249.       exit( 1 );
  250.    }
  251.  
  252.    getkey( );
  253.    restore_screen_line( 0, line, display_buff );
  254.    if (g_status.wrapped) {
  255.       g_status.wrapped = FALSE;
  256.       show_search_message( CLR_SEARCH, g_display.mode_color );
  257.    }
  258. }
  259.  
  260.  
  261. /*
  262.  * Name:    harmless
  263.  * Purpose: Do nothing when control-C is pressed
  264.  * Date:    June 5, 1991
  265.  * Notes:   Interrupt 23, the Control-C handler, is a MS DOS system function.
  266.  *            Since we want to use Control-C as a regular function key,
  267.  *            let's do absolutely nothing when Control-C is pressed.
  268.  */
  269. #if defined( __UNIX__ )
  270.   void harmless( void )
  271. #else
  272.  #if defined( __MSC__ )
  273.   void interrupt FAR harmless( void )
  274.  #else
  275.   static int harmless( void )
  276.  #endif
  277. #endif
  278. {
  279. }
  280.  
  281.  
  282. /*
  283.  * Name:    ctrl_break
  284.  * Purpose: Set our control-break flag when control-break is pressed.
  285.  * Date:    June 5, 1992
  286.  * Notes:   Control-break is a little different from Control-C.  When
  287.  *           Control-C is pressed, MS DOS processes it as soon as possible,
  288.  *           which may be quite a while.  On the other hand, when
  289.  *           Control-break is pressed on IBM and compatibles, interrupt 0x1b
  290.  *           is generated immediately.  Since an interrupt is generated
  291.  *           immediately, we can gain control of run-away functions, like
  292.  *           recursive macros, by checking our Control-break flag.
  293.  */
  294. #if !defined( __UNIX__ )
  295.  void interrupt FAR ctrl_break( void )
  296.  {
  297.     g_status.control_break = TRUE;
  298.  }
  299. #endif
  300.  
  301.  
  302. /*
  303.  * Name:    terminate
  304.  * Purpose: To free all dynamic structures and unload anything we loaded
  305.  * Date:    June 5, 1991
  306.  */
  307. void terminate( void )
  308. {
  309. #if !defined( __UNIX__ )
  310.  union REGS inregs, outregs;
  311. #endif
  312. register TDE_WIN    *wp;        /* register for scanning windows */
  313. TDE_WIN             *w;         /* free window */
  314. register file_infos *fp;        /* register for scanning files */
  315. file_infos          *f;         /* free files */
  316. int                 i;
  317.  
  318.    /*
  319.     * restore control-break checking
  320.     */
  321. #if defined( __UNIX__ )
  322.    noraw( );
  323.    endwin( );
  324.  
  325.    /*
  326.     * if we were doing any multi-file searching, close the directory pointer
  327.     */
  328.    if (g_status.dp != NULL)
  329.       closedir( g_status.dp );
  330.    if (g_status.sas_dp != NULL)
  331.       closedir( g_status.sas_dp );
  332. #elif defined( __MSC__ )
  333.    _dos_setvect( 0x1b, old_int1b );
  334.    _dos_setvect( 0x23, old_control_c );
  335.    inregs.h.ah = 0x33;
  336.    inregs.h.al = 1;
  337.    inregs.h.dl = (char)s_cbrk;
  338.    intdos( &inregs, &outregs );
  339. #else
  340.    setcbrk( s_cbrk );
  341. #endif
  342.  
  343.    /*
  344.     * free the file structures, if not already free.
  345.     */
  346.    fp = g_status.file_list;
  347.    while (fp != NULL) {
  348.       f  = fp;
  349.       fp = fp->next;
  350.       free( f );
  351.    }
  352.  
  353.    /*
  354.     * free the window structures, if not already free.
  355.     */
  356.    wp = g_status.window_list;
  357.    while (wp != NULL) {
  358.       w  = wp;
  359.       wp = wp->next;
  360.       free( w );
  361.    }
  362.  
  363.  
  364.    /*
  365.     * free any character classes in the nfa's.
  366.     */
  367.    for (i=0; i < REGX_SIZE; i++) {
  368.       if (sas_nfa.class[i] == nfa.class[i]  &&  nfa.class[i] != NULL)
  369.          free( nfa.class[i] );
  370.       else if (sas_nfa.class[i] != NULL)
  371.          free( sas_nfa.class[i] );
  372.       else if (nfa.class[i] != NULL)
  373.          free( nfa.class[i] );
  374.    }
  375.  
  376. #if defined( __UNIX__ )
  377.  
  378.    /*
  379.     * leave residue from the editing session on the screen.
  380.     */
  381.    puts( "" );
  382. #else
  383.    /*
  384.     * reset the cursor size and unload the 83/84 key keyboard utility
  385.     */
  386.    set_cursor_size( mode.cursor_size == SMALL_INS ? g_display.insert_cursor :
  387.                                                     g_display.overw_cursor );
  388.    if (mode.enh_kbd == FALSE)
  389.       simulate_enh_kbd( 0 );
  390.  
  391.    /*
  392.     * restore the overscan (border) color
  393.     */
  394.    if (g_display.adapter != MDA)
  395.       set_overscan_color( g_display.old_overscan );
  396. #endif
  397. }
  398.  
  399.  
  400. /*
  401.  * Name:    initialize
  402.  * Purpose: To initialize all the screen status info that is not hardware
  403.  *           dependent, and call the hardware initialization routine to
  404.  *           pick up the hardware dependent stuff.
  405.  * Date:    June 5, 1991
  406.  * Returns: [g_status and g_display]: all set up ready to go
  407.  * Notes:   It is assumed that g_status and g_display are all \0's to begin
  408.  *           with (the default if they use static storage). If this may
  409.  *           not be the case, then clear them explicitly here.
  410.  */
  411. int  initialize( void )
  412. {
  413. int i;
  414. int rc;
  415.  
  416.    rc = OK;
  417.    /*
  418.     * do the hardware initialization first.
  419.     */
  420.    hw_initialize( );
  421.  
  422.    /*
  423.     * now, initialize the editor modes, pointers, and counters.
  424.     */
  425.    bm.search_defined        = ERROR;
  426.    sas_bm.search_defined    = ERROR;
  427.    g_status.sas_defined     = ERROR;
  428.    g_status.sas_search_type = ERROR;
  429.  
  430.    regx.search_defined      = ERROR;
  431.    sas_regx.search_defined  = ERROR;
  432.  
  433.    if (mode.undo_max < 2)
  434.       mode.undo_max = 2;
  435.  
  436.    g_status.marked_file = NULL;
  437.    g_status.current_window = NULL;
  438.    g_status.current_file = NULL;
  439.    g_status.window_list = NULL;
  440.    g_status.file_list = NULL;
  441.    g_status.buff_node = NULL;
  442.  
  443.    g_status.window_count = 0;
  444.    g_status.file_count = 0;
  445.    g_status.line_buff_len = 0;
  446.    g_status.tabout_buff_len = 0;
  447.    g_status.command = 0;
  448.    g_status.key_pressed = 0;
  449.    g_status.sas_rcol  = 0;
  450.    g_status.sas_rline = 0;
  451.    g_status.recording_key = 0;
  452.  
  453.    g_status.key_pending = FALSE;
  454.    g_status.found_first = FALSE;
  455.    g_status.sas_found_first = FALSE;
  456.    g_status.copied = FALSE;
  457.    g_status.wrapped = FALSE;
  458.    g_status.marked = FALSE;
  459.    g_status.macro_executing = FALSE;
  460.    g_status.replace_defined = FALSE;
  461.  
  462.    g_status.screen_display = TRUE;
  463.  
  464.    g_status.file_chunk = DEFAULT_BIN_LENGTH;
  465.  
  466.    g_status.sas_tokens[0] = '\0';
  467.    g_status.path[0]       = '\0';
  468.    g_status.sas_path[0]   = '\0';
  469.    g_status.rw_name[0]    = '\0';
  470.    g_status.pattern[0]    = '\0';
  471.    g_status.subst[0]      = '\0';
  472.  
  473.    /*
  474.     * set the number of lines from one page that should still be visible
  475.     *  on the next page after page up or page down.
  476.     */
  477.    g_status.overlap = 1;
  478.  
  479. #if defined( __UNIX__ )
  480.    g_status.dp = NULL;
  481.    g_status.sas_dp = NULL;
  482. #endif
  483.  
  484.    /*
  485.     * initialize the nodes in the nfa.
  486.     */
  487.    for (i=0; i < REGX_SIZE; i++) {
  488.       sas_nfa.node_type[i] = nfa.node_type[i] = 0;
  489.       sas_nfa.term_type[i] = nfa.term_type[i] = 0;
  490.       sas_nfa.c[i] = nfa.c[i] = 0;
  491.       sas_nfa.next1[i] = nfa.next1[i] = 0;
  492.       sas_nfa.next2[i] = nfa.next2[i] = 0;
  493.       sas_nfa.class[i] = nfa.class[i] = NULL;
  494.    }
  495.  
  496.    /*
  497.     * no macro is executing
  498.     */
  499.    connect_macros( );
  500.  
  501.    /*
  502.     * clear the screen and show the author's names
  503.     */
  504.    cls( );
  505.    show_credits( );
  506.    return( rc );
  507. }
  508.  
  509.  
  510. /*
  511.  * Name:    hw_initialize
  512.  * Purpose: To initialize the display ready for editor use.
  513.  * Date:    June 5, 1991
  514.  */
  515. void hw_initialize( void )
  516. {
  517. #if defined( __UNIX__ )
  518.  
  519. int i;
  520. int y;
  521. int x;
  522. register int *clr;
  523.  
  524.    clr =  &colour.clr[1][0];
  525.  
  526.    /*
  527.     * if we are in a linux environment, init the curses package.
  528.     */
  529.    initscr( );
  530.    keypad( stdscr, TRUE );
  531.    cbreak( );
  532.    noecho( );
  533.    raw( );
  534.    scrollok( stdscr, TRUE );
  535.    if (has_colors( ))
  536.       start_color( );
  537.  
  538.    move( 0, 0 );
  539.    init_pair( 0, COLOR_WHITE, COLOR_BLACK );
  540.    init_pair( 1, COLOR_WHITE, COLOR_BLUE );
  541.    init_pair( 2, COLOR_BLUE, COLOR_BLACK );
  542. /*   init_pair( 2, COLOR_RED, COLOR_GREEN ); */
  543.    init_pair( 3, COLOR_YELLOW, COLOR_CYAN );
  544.    init_pair( 4, COLOR_WHITE, COLOR_RED );
  545. /*   init_pair( 5, COLOR_BLUE, COLOR_CYAN ); */
  546.    init_pair( 5, COLOR_GREEN, COLOR_MAGENTA );
  547. /*   init_pair( 6, COLOR_MAGENTA, COLOR_YELLOW ); */
  548.    init_pair( 6, COLOR_GREEN, COLOR_BLACK );
  549.    init_pair( 7, COLOR_BLUE, COLOR_WHITE );
  550.  
  551.    /*
  552.     * lets try to emulate the PC color table.  in normal color mode,
  553.     *  there are 8 background colors and 16 foreground colors.
  554.     */
  555.    for (i=0; i<8; i++) {
  556.       tde_color_table[i]     = COLOR_PAIR( 0 );
  557.       tde_color_table[i+16]  = COLOR_PAIR( 1 );
  558.       tde_color_table[i+32]  = COLOR_PAIR( 2 );
  559.       tde_color_table[i+48]  = COLOR_PAIR( 3 );
  560.       tde_color_table[i+64]  = COLOR_PAIR( 4 );
  561.       tde_color_table[i+80]  = COLOR_PAIR( 5 );
  562.       tde_color_table[i+96]  = COLOR_PAIR( 6 );
  563.       tde_color_table[i+112] = COLOR_PAIR( 7 ) | A_DIM;
  564.    }
  565.  
  566.    for (i=0; i<8; i++) {
  567.       tde_color_table[i+8]   = COLOR_PAIR( 0 ) | A_BOLD;
  568.       tde_color_table[i+24]  = COLOR_PAIR( 1 ) | A_BOLD;
  569.       tde_color_table[i+40]  = COLOR_PAIR( 2 ) | A_BOLD;
  570.       tde_color_table[i+56]  = COLOR_PAIR( 3 ) | A_BOLD;
  571.       tde_color_table[i+72]  = COLOR_PAIR( 4 ) | A_BOLD;
  572.       tde_color_table[i+88]  = COLOR_PAIR( 5 ) | A_BOLD;
  573.       tde_color_table[i+104] = COLOR_PAIR( 6 ) | A_BOLD;
  574.       tde_color_table[i+120] = COLOR_PAIR( 7 );
  575.    }
  576.  
  577.    g_display.head_color    = *clr++;
  578.    g_display.text_color    = *clr++;
  579.    g_display.dirty_color   = *clr++;
  580.    g_display.mode_color    = *clr++;
  581.    g_display.block_color   = *clr++;
  582.    g_display.message_color = *clr++;
  583.    g_display.help_color    = *clr++;
  584.    g_display.diag_color    = *clr++;
  585.    g_display.eof_color     = *clr++;
  586.    g_display.curl_color    = *clr++;
  587.    g_display.ruler_color   = *clr++;
  588.    g_display.ruler_pointer = *clr++;
  589.    g_display.hilited_file  = *clr++;
  590.    g_display.overscan      = *clr;
  591.  
  592.    g_display.dirty_color   = 96;
  593.    g_display.hilited_file  = 96;
  594. /*   g_display.head_color    = 64;
  595.    g_display.ruler_pointer = 104;   */
  596.    g_display.help_color    = 48;
  597.    g_display.eof_color     = 40;
  598. /*
  599.    g_display.dirty_color   = 96;
  600.    g_display.help_color    = 56;
  601.    g_display.hilited_file  = 16;
  602. */
  603.  
  604. #else
  605.  struct vcfg cfg;       /* defined in .h */
  606.  register int *clr;
  607.  
  608.    /*
  609.     * work out what kind of display is in use, and set attributes and
  610.     *  display address accordingly. Note that this will only work with
  611.     *  close IBM compatibles.
  612.     */
  613.  
  614.    video_config( &cfg );
  615.    g_display.display_address = (char FAR *)cfg.videomem;
  616.  
  617.    /*
  618.     * Use an integer pointer to go thru the color array for setting up the
  619.     * various color fields.
  620.     */
  621.    clr =  cfg.color == FALSE ? &colour.clr[0][0] : &colour.clr[1][0];
  622.  
  623.    g_display.head_color    = *clr++;
  624.    g_display.text_color    = *clr++;
  625.    g_display.dirty_color   = *clr++;
  626.    g_display.mode_color    = *clr++;
  627.    g_display.block_color   = *clr++;
  628.    g_display.message_color = *clr++;
  629.    g_display.help_color    = *clr++;
  630.    g_display.diag_color    = *clr++;
  631.    g_display.eof_color     = *clr++;
  632.    g_display.curl_color    = *clr++;
  633.    g_display.ruler_color   = *clr++;
  634.    g_display.ruler_pointer = *clr++;
  635.    g_display.hilited_file  = *clr++;
  636.    g_display.overscan      = *clr;
  637.  
  638.    /*
  639.     * set the overscan color.
  640.     * in terminate( ), the overscan color is returned to old state.
  641.     */
  642.    if (g_display.adapter != MDA)
  643.       set_overscan_color( g_display.overscan );
  644. #endif
  645.  
  646.  
  647.    /*
  648.     * set up screen size
  649.     */
  650. #if defined( __UNIX__ )
  651.  
  652.    /*
  653.     * getmaxyx( ) is a curses macro that sets y and x. stdscr is the
  654.     *  standard curses screen.
  655.     */
  656.    getmaxyx( stdscr, y, x );
  657.    g_display.ncols = x;
  658.    g_display.nlines = y - 2;
  659.    g_display.mode_line = y - 1;
  660.  
  661. #else
  662.    g_display.ncols     = MAX_COLS;
  663.    g_display.nlines    = MAX_LINES - 1;
  664.    g_display.mode_line = MAX_LINES;
  665. #endif
  666.    g_display.line_length = MAX_LINE_LENGTH;
  667. }
  668.  
  669.  
  670. /*
  671.  * Name:    get_help
  672.  * Purpose: save the screen and display key definitions
  673.  * Date:    June 5, 1991
  674.  * Notes:   This routine is dependent on the length of the strings in the
  675.  *          help screen.  To make it easy to load in a new help screen,
  676.  *          the strings are assumed to be 80 characters long followed by
  677.  *          the '\0' character.  It is assumed each that string contains
  678.  *          exactly 81 characters.
  679.  */
  680. int  get_help( TDE_WIN *window )
  681. {
  682. register char *help;
  683. register int line;
  684.  
  685.    xygoto( -1, -1 );
  686.    help = help_screen[1];
  687.    for (line=0; help != NULL; line++) {
  688.       s_output( help, line, 0, g_display.help_color );
  689.       help = help_screen[line+2];
  690.    }
  691.  
  692. #if defined( __UNIX__ )
  693.    refresh( );
  694. #endif
  695.  
  696.    line = getkey( );
  697.  
  698. #if defined( __UNIX__ )
  699.    cls( );
  700. #endif
  701.  
  702.    redraw_screen( window );
  703. #if defined( __UNIX__ )
  704.    refresh( );
  705. #endif
  706.    return( OK );
  707. }
  708.  
  709.  
  710. /*
  711.  * Name:    show_credits
  712.  * Purpose: display authors
  713.  * Date:    June 5, 1991
  714.  */
  715. void show_credits( void )
  716. {
  717. register char *credit;
  718. int  line;
  719.  
  720.    xygoto( -1, -1 );
  721.    credit = credit_screen[0];
  722.    for (line=0; credit != NULL; ) {
  723.       s_output( credit, line+2, 11, g_display.text_color );
  724.       credit = credit_screen[++line];
  725.    }
  726. }
  727.