📄 eeterm.c
字号:
case TN_COHIBM: /* If this exists, TN_H19 will too */#endif /*TX_COHIBM*/#if TX_H19 case TN_H19: do tputz("\033N"); while(--i); break;#endif /*TX_H19*/#if TX_DM2500 case TN_DM2500: tput(020); /* Enter I/D mode */ do if(trm_ospeed == 13) /* 9600? */ tputz("\010\177"); /* BS and DEL */ else tput(010); while(--i); tput(030); /* Exit I/D mode */ break;#endif /*TX_DM2500*/#if TX_OM8025 case TN_OM8025: do tputz("\033P"); while (--i); break;#endif /*TX_OM8025*/#if TX_TVI925 case TN_TVI925: do { tputz("\033W"); } while(--i);#endif /*TX_TVI925*/ }}#if FX_SOWIND/* T_STANDOUT(n) - Enter or leave standout mode. * n - 0 to return to normal display mode, * 1 to enter standout display mode. * This is usually reverse video but may be something else. * * Only valid if trm_flags has TF_SO set. */t_standout(on)int on;{ switch(tv_type) {#if TX_TERMCAP case TN_TERMCAP: putpad(on ? TC_so : TC_se); break;#endif /*TX_TERMCAP*/#if TX_COHIBM case TN_COHIBM: /* Note TN_H19 will exist too */#endif /*TX_COHIBM*/#if TX_H19 case TN_H19: tputz(on ? "\033p" : "\033q"); break;#endif /*TX_H19*/ }}#endif /*FX_SOWIND*//* TPADN(n) - Output N pad chars. */static voidtpadn(n)int n;{ register int i, pad; if((i = n) > 0) { pad = tv_padc; do { tput(pad); } while(--i); }}/* TPAD(msec) - Output padding for given # of milliseconds. */static voidtpad(n)int n;{ register int i, i2; i = n; while(i > 0) { if((i2 = 320) < i) /* So can use integers */ i2 = i; i -= i2; i2 *= 100; while((i2 -= tv_cspeed) > 0) tput(tv_padc); }}#if TX_TERMCAP/* * Print the string str, interpreting padding. */int tput(); /* Our output function */static voidputpad(str)char *str;{ if(str) tputs(str, 1, tput); /* Invoke TERMCAP function */}static voidputnpad(str,n)char *str;int n;{ if(str) tputs(str, n, tput);}static voidputpar(str, par, n) /* Wish we had tparm() */char *str;int par,n;{ putnpad(tgoto(str, 0, par), n);}#endif /*TX_TERMCAP*//* * Read in the stuff from termcap upon startup. */#if TX_TERMCAPstatic int tstrlen(), tstrlp();#ifndef TCAPSLEN#define TCAPSLEN 1024 /* Default size of buffer for TERMCAP strings */#endif /*-TCAPSLEN*/static intgetcap(stype)char *stype;{ register char *t; register int i; int buflen; char *tcbuf, *tcbptr; /* Pointers into termcap buffer */ char tmpstr[4]; char tmpbuf[TCAPSLEN]; /* Allocate from stack */ char *malloc(); char *realloc(); /* First see if can find the terminal type. */ if((tgetent(tmpbuf, stype)) != 1) return(0); /* Found it! Set up a string buffer to save the caps. */ if(!(tcbuf = malloc(TCAPSLEN))) /* Get permanent buffer */ t_fatal(" - cannot allocate termcap buffer"); tcbptr = tcbuf; /* Now gobble all the string caps that ELLE wants to know about. */ tmpstr[3] = '\0'; i = NTCAPS; do { tmpstr[0] = tcap[i].tcicod1; /* Make str of the code */ tmpstr[1] = tcap[i].tcicod2; tcap[i].tccap = tgetstr(tmpstr, &tcbptr); /* Get cap */ } while(--i); buflen = tcbptr - tcbuf; /* String buffer done, finalize */ if(buflen >= TCAPSLEN) t_fatal("description too big!"); realloc(tcbuf, buflen); /* Free up unused part of buffer */ /* (this better not move it!!!) */ /* Now get the number/flag stuff that ELLE needs. */ tc_am = tgetflag("am"); /* auto wrap */ if (tgetflag("xn")) tc_am = 0; /* auto wrap at 81st char, nice! */ tc_km = (tgetflag("km") /* TTY has meta key */ || tgetflag("MT")); /* Alternate version of "km"?? */ scr_ht = tgetnum("li"); /* Set screen height (# lines) */ scr_wid = tgetnum("co"); /* Set screen width (# cols) */ ts_winsize(); /* Now initialize the stupid external vars that TERMCAP rtns want. */ if(TC_pc) PC = *TC_pc; /* Pad char */ BC = TC_bc; /* Backspace str (if no BS) */ UP = TC_up; /* Cursor up */ ospeed = trm_ospeed; /* Put output speed here */ /* Basic data extracted, now mull over it and set the remaining * ELLE variables */#if FX_SOWIND if(tgetnum("sg") <= 0) /* If no magic cookie problems */ { if (TC_so && TC_se) /* And have standout caps, */ trm_flags |= TF_SO; /* Say has standout cap */ }#endif if (!(TC_cm && TC_cl)) t_fatal("lacks cursor addressing or clear screen."); tvc_pos = tstrlen(TC_cm); /* Find cost of abs move */ if(BC) /* Find cost of backspace */ tvc_bs = tstrlen(BC); /* Find costs for doing I/D char operations */ if ((TC_im||TC_ic) && (TC_dm||TC_dc)) { trm_flags |= TF_IDCHR; tvc_ci = tstrlen(TC_im)+tstrlen(TC_ei); tvc_cin = tstrlen(TC_ic)+1+tstrlen(TC_ip); if(TC_IC) /* If have multi-IC, use it */ { tvc_ci += tstrlp(TC_IC, 1); tvc_cin = 1; } tvc_cd = tstrlen(TC_dm)+tstrlen(TC_ed); tvc_cdn = tstrlen(TC_dc); if(TC_DC) /* If have multi-DC, use it */ { tvc_cd += tstrlp(TC_DC, 1); tvc_cdn = 0; } } /* Find costs for doing I/D line operations */ if ((TC_ia || TC_al) && (TC_id || TC_dl)) { trm_flags |= TF_IDLIN; tvc_li = 0; /* Usual case */ tvc_lin = tstrlen(TC_al); if(TC_AL) /* If have multi-IL, use it */ { tvc_li = tstrlp(TC_AL, 1); tvc_lin = tstrlp(TC_AL, 2) - tvc_lin; } else if(TC_ia) { tvc_li = tstrlen(TC_im)+tstrlen(TC_ei); tvc_lin = tstrlen(TC_ia); } tvc_ld = 0; /* Usual case */ tvc_ldn = tstrlen(TC_dl); if(TC_DL) /* If have multi-DL, use it */ { tvc_ld = tstrlp(TC_DL, 1); tvc_ldn = tstrlp(TC_DL, 2) - tvc_ld; } else if(TC_id) { tvc_ld = tstrlen(TC_dm)+tstrlen(TC_ed); tvc_ldn = tstrlen(TC_id); } } if (tc_am) { scr_wid--; /* For now, avoid invoking wrap. */#if 0 trm_flags |= AUTOWRAP; /* */#endif } if (TC_ce) trm_flags |= TF_CLEOL; /* Term has CLEOL? */ if (tc_km) trm_flags |= TF_METAKEY; /* Term has meta key? */ return(1);}/* Pair of routines which conspire in order to find # chars actually output * by a particular termcap string. */static int _tslen; /* Stored count */static void _tslinc(ch) { _tslen++; }static inttstrlen(str)char *str;{ _tslen = 0; if(str && str[0]) tputs(str, 1, _tslinc); /* Mult padding by just 1 */ return(_tslen);}static inttstrlp(str, par) /* Same but with parameter */char *str;int par;{#if 0 if(str) { char *cp = tgoto(str, 0, par); int i = strlen(cp); while(--i >= 0) printf(" %o", *cp++); printf("\n"); }#endif return !str ? 0 : tstrlen(tgoto(str, 0, par));}#endif /*TX_TERMCAP*//* Direct-Video terminal output routine * Currently only COHERENT has this capability. */#if COHERENT#include <sgtty.h>struct vidctl { int v_position; /* Position in video memory */ int v_count; /* Number of characters to transfer */ char *v_buffer; /* Character buffer to read/write */};/* * Attribute masks for TIOVPUTB - attributes occupy odd addresses * in video memory. */#define VNORM 0x07 /* Ordinary Video */#define VINTE 0x08 /* Intense video */#define VBLIN 0x80 /* Blinking video */#define VREVE 0x70 /* Reverse video */#define VUNDE 0x01 /* Underline video (mono board) *//* T_DIRECT(line, col, string, len) - Do direct-video output of string. * Puts the string ("len" chars in length) on the screen starting at * the X,Y character position given by col, line. * This routine is only called if terminal has the "TF_DIRVID" flag set. */t_direct(lin, col, str, len)int lin, col;register char *str;register int len;{ register char *cp; char vbuf[MAXLINE*2]; struct vidctl v; if(len <= 0) return; tbufls(); /* Ensure normal output is forced out */ v.v_position = (lin*80 + col)*2; v.v_count = len*2; v.v_buffer = cp = vbuf; do { *cp++ = *str++; *cp++ = VNORM; } while(--len); ioctl(1, TIOVPUTB, &v);}#endif /*COHERENT*//* * Terminal Output buffering routines */static char tbuf[TOBFSIZ]; /* Output buffer */static int tbufcnt = 0; /* # chars of room left in buffer */static char *tbufp = 0; /* Pointer to deposit in buffer */tput(ch)int ch;{ if(--tbufcnt < 0) tbufls(); *tbufp++ = ch;}tputz(str)char *str;{ register int c; register char *cp, *tp; cp = str; tp = tbufp; while(c = *cp++) { if(--tbufcnt < 0) { tbufp = tp; tbufls(); tp = tbufp; } *tp++ = c; } tbufp = tp;}tputn(str,cnt)char *str;int cnt;{ register int c; register char *cp, *tp; cp = str; tp = tbufp; if((c = cnt) > 0) do { if(--tbufcnt < 0) { tbufp = tp; tbufls(); tp = tbufp; } *tp++ = *cp++; } while(--c); tbufp = tp;}tbufls(){ register int cnt; if(tbufp && (cnt = tbufp - tbuf) > 0) /* # chars written */ write(1, tbuf, cnt); /* Out they go */ tbufp = tbuf; tbufcnt = TOBFSIZ-1; /* Allow for usual expected decrement */}/* * Terminal Input buffering routines */int tibfmsk = -1; /* Mask AND'ed with input chars (external) */static char tibuf[TIBFSIZ]; /* TTY input buffer */static char *tibfp; /* Pointer to read from buffer */static int tibfcnt = 0; /* # chars left to be read from buffer */tgetc(){#if SUN register int c; extern int sun_winfd, sun_rdevf; if(sun_winfd) { if(!sun_rdevf) return(sun_input(1)&tibfmsk); sun_rdevf = 0; /* Check mouse too, but only once! */ c = sun_input(0); if(c != -1) c &= tibfmsk; return(c); }#endif /*SUN*/ while(--tibfcnt < 0) tibfcnt = read(0,(tibfp = tibuf),TIBFSIZ); return((*tibfp++)&tibfmsk);}tinwait(){ return(tibfcnt > 0 || ts_inp());}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -