display.cc
/*
** termcap - reads termcap file setting all the terminal capabilities
**           which we\'ll use.
*/
reads termcap file setting all the terminal capabilities
which we\'ll use.
reads termcap file setting all the terminal capabilities which we \ ' ll use .
void termcap(const char *term_type)
{
    static char capability_buffer[512], *bp = capability_buffer;
    char termcap_buffer[2048];
    switch (tgetent(termcap_buffer, term_type))
    {
      case -1:
        (void)fputs("couldn't open termcap database\n", stderr);
        exit(1);
      case 0:
        (void)fprintf(stderr, "invalid terminal type: `%s'\n", term_type);
        exit(1);
      default: break;
    }
    AL = tgetstr("al", &bp);
    ALN = tgetstr("AL", &bp);
    AM = tgetflag("am");
    BC = tgetstr("bc", &bp);
    BS = tgetflag("bs");
    CD = tgetstr("cd", &bp);
    CE = tgetstr("ce", &bp);
    CL = tgetstr("cl", &bp);
    CM = tgetstr("cm", &bp);
    CR = tgetstr("cr", &bp);
    CS = tgetstr("cs", &bp);
    DA = tgetflag("da");
    DB = tgetflag("db");
    DC = tgetstr("dc", &bp);
    DL = tgetstr("dl", &bp);
    DLN = tgetstr("DL", &bp);
    DM = tgetstr("dm", &bp);
    DO = tgetstr("do", &bp);
    ED = tgetstr("ed", &bp);
    HC = tgetflag("hc");
    HO = tgetstr("ho", &bp);
    IS = tgetstr("is", &bp);
    KD = tgetstr("kd", &bp);
    KE = tgetstr("ke", &bp);
    KS = tgetstr("ks", &bp);
    KU = tgetstr("ku", &bp);
    LE = tgetstr("le", &bp);
    LL = tgetstr("ll", &bp);
    MR = tgetstr("mr", &bp);
    ME = tgetstr("me", &bp);
    OS = tgetflag("os");
    PCstr = tgetstr("pc", &bp);
    SE = tgetstr("se", &bp);
    SF = tgetstr("sf", &bp);
    SO = tgetstr("so", &bp);
    SR = tgetstr("sr", &bp);
    TE = tgetstr("te", &bp);
    TI = tgetstr("ti", &bp);
    UP = tgetstr("up", &bp);
    VE = tgetstr("ve", &bp);
    VS = tgetstr("vs", &bp);
    XN = tgetstr("xn", &bp);
    PC = PCstr ? PCstr[0] :  0;
    if (!BC && !LE && !BS)
    {
        (void)fputs("terminal can't backspace - unusable\n", stderr);
        exit(1);
    }
    if (!BC) BC = LE ? LE : "\b";
    if (!CR) CR = "\r";
#ifdef __EMX__
    int sz[2];
    _scrsize(sz);
    CO = sz[0];
    LI = sz[1];
#endif
    const char *tmp = getenv("LINES");
    if (tmp) LI = atoi(tmp);
    tmp = getenv("COLUMNS");
    if (tmp) CO = atoi(tmp);
#ifdef TIOCGWINSZ
    struct winsize win;
    if (ioctl(2, TIOCGWINSZ, (char *)&win) == 0)
    {
        if (LI == 0 && win.ws_row > 0) LI = win.ws_row;
        if (CO == 0 && win.ws_col > 0) CO = win.ws_col;
    }
#endif
    if (CO == 0) CO = tgetnum("co");
    if (LI == 0) LI = tgetnum("li");
    if (LI == -1 || CO == -1 || HC || !CM || !CE)
    {
        (void)fputs("terminal too dumb to be useful\n", stderr);
        exit(1);
    }
    if (LI < 5)
    {
        (void)fputs("too few rows to be useful\n", stderr);
        exit(1);
    }
}
void termcap ( const char * term_type ) { static char capability_buffer [ 512 ] , * bp = capability_buffer ; char termcap_buffer [ 2048 ] ; switch ( tgetent ( termcap_buffer , term_type ) ) { case -1 : ( void ) fputs ( " \n " , stderr ) ; exit ( 1 ) ; case 0 : ( void ) fprintf ( stderr , " \n " , term_type ) ; exit ( 1 ) ; default : break ; } AL = tgetstr ( " " , & bp ) ; ALN = tgetstr ( " " , & bp ) ; AM = tgetflag ( " " ) ; BC = tgetstr ( " " , & bp ) ; BS = tgetflag ( " " ) ; CD = tgetstr ( " " , & bp ) ; CE = tgetstr ( " " , & bp ) ; CL = tgetstr ( " " , & bp ) ; CM = tgetstr ( " " , & bp ) ; CR = tgetstr ( " " , & bp ) ; CS = tgetstr ( " " , & bp ) ; DA = tgetflag ( " " ) ; DB = tgetflag ( " " ) ; DC = tgetstr ( " " , & bp ) ; DL = tgetstr ( " " , & bp ) ; DLN = tgetstr ( " " , & bp ) ; DM = tgetstr ( " " , & bp ) ; DO = tgetstr ( " " , & bp ) ; ED = tgetstr ( " " , & bp ) ; HC = tgetflag ( " " ) ; HO = tgetstr ( " " , & bp ) ; IS = tgetstr ( " " , & bp ) ; KD = tgetstr ( " " , & bp ) ; KE = tgetstr ( " " , & bp ) ; KS = tgetstr ( " " , & bp ) ; KU = tgetstr ( " " , & bp ) ; LE = tgetstr ( " " , & bp ) ; LL = tgetstr ( " " , & bp ) ; MR = tgetstr ( " " , & bp ) ; ME = tgetstr ( " " , & bp ) ; OS = tgetflag ( " " ) ; PCstr = tgetstr ( " " , & bp ) ; SE = tgetstr ( " " , & bp ) ; SF = tgetstr ( " " , & bp ) ; SO = tgetstr ( " " , & bp ) ; SR = tgetstr ( " " , & bp ) ; TE = tgetstr ( " " , & bp ) ; TI = tgetstr ( " " , & bp ) ; UP = tgetstr ( " " , & bp ) ; VE = tgetstr ( " " , & bp ) ; VS = tgetstr ( " " , & bp ) ; XN = tgetstr ( " " , & bp ) ; PC = PCstr ? PCstr [ 0 ] : 0 ; if ( ! BC && ! LE && ! BS ) { ( void ) fputs ( " \n " , stderr ) ; exit ( 1 ) ; } if ( ! BC ) BC = LE ? LE : " \b " ; if ( ! CR ) CR = " \r " ; #ifdef __EMX__ int sz [ 2 ] ; _scrsize ( sz ) ; CO = sz [ 0 ] ; LI = sz [ 1 ] ; #endif const char * tmp = getenv ( " " ) ; if ( tmp ) LI = atoi ( tmp ) ; tmp = getenv ( " " ) ; if ( tmp ) CO = atoi ( tmp ) ; #ifdef TIOCGWINSZ struct winsize win ; if ( ioctl ( 2 , TIOCGWINSZ , ( char * ) & win ) == 0 ) { if ( LI == 0 && win . ws_row > 0 ) LI = win . ws_row ; if ( CO == 0 && win . ws_col > 0 ) CO = win . ws_col ; } #endif if ( CO == 0 ) CO = tgetnum ( " " ) ; if ( LI == 0 ) LI = tgetnum ( " " ) ; if ( LI == -1 || CO == -1 || HC || ! CM || ! CE ) { ( void ) fputs ( " \n " , stderr ) ; exit ( 1 ) ; } if ( LI < 5 ) { ( void ) fputs ( " \n " , stderr ) ; exit ( 1 ) ; } }
termcap - reads termcap file setting all the terminal capabilities
which we\'ll use.
termcap - reads termcap file setting all the terminal capabilities which we \ ' ll use .
/* if (!DO) DO = SF ? SF : "\n"; */