📄 eedisp.c
字号:
idone: if(i < ocol) /* if still have text to right, */ { t_move(y,i); /* move there */ t_docleol(); /* and clear old stuff. */ }done: s->sl_line = s->sl_nlin; /* Replace old image by new */ s->sl_col = s->sl_ncol; s->sl_nlin = sci; s->sl_flg &= ~SL_MOD;#if FX_SOWIND /* Copy standout mode to current */ if(newso) s->sl_flg |= SL_CSO; else s->sl_flg &= ~SL_CSO;#endif}#if FX_SOWINDfillset(str,cnt,c)char *str;int cnt;int c;{ register int n; register char *cp; if((n = cnt) <= 0) return; cp = str; do{ *cp++ = c; } while(--n);}#endiffillsp(str,cnt)char *str;int cnt;{ register int n; register char *cp; if((n = cnt) <= 0) return; cp = str; do{ *cp++ = SP; } while(--n);}inspc(cp0, cpl, cnt)char *cp0, *cpl;int cnt;{ register char *cp, *cp2; register n; if((n = cnt) <= 0) return; cp = cpl; /* ptr to last+1 char in string */ cp2 = cp+n; /* ptr to loc+1 to move to */ n = cp - cp0; /* # chars to move */ do *--cp2 = *--cp; while(--n); n = cnt; /* Now fill gap with spaces */ do *cp++ = SP; while(--n);}/* FIX_LINE - Fixes up new screen image for a single line. Does not * do any actual terminal I/O, and does not change the old screen * image. Assumes that previous line (if any is furnished) has * already been properly set up. */int sctreol = 0; /* Ugly crock for talking to sctrin() */ /* 0 = no EOL seen, 1 = EOL seen, -1 = EOF seen */fix_line(slp, olds)struct scr_line *slp;struct scr_line *olds;{ register struct scr_line *s; register int col, scrw; char *cp; int ch; col = 0; scrw = scr_wid; cp = slp->sl_nlin; if((s = olds) && (col = s->sl_cont)) { if(--col) strncpy(cp, (s->sl_flg&SL_MOD) ? &s->sl_nlin[scrw] : &s->sl_line[scrw], col); cp += col; } scrw--; /* Note now using scr_wd0 !! */ s = slp; s->sl_boff = e_dot(); col = sctrin(cp, scrw, col); if (col < scrw || sctreol) /* Does line need continuation mark? */ s->sl_cont = 0; /* No, say no cont chars */ else { /* Yes, find # cols of overflow. If not 0, must be > 0 */ /* and char is a biggie. Make room for continuation chars */ if(col -= scrw) inspc(&s->sl_nlin[scrw],&s->sl_nlin[scrw+col], 1); s->sl_cont = col+1; /* # cont chars, plus 1 */ s->sl_nlin[scrw] = CI_CLINE; /* Display "contin" mark */ col = scrw+1; } s->sl_ncol = col; s->sl_len = e_dot() - s->sl_boff; s->sl_flg |= (SL_MOD|SL_EOL); /* Say new, and assume line has EOL */ if(sctreol <= 0) /* unless it doesn't really */ s->sl_flg &= ~SL_EOL; /* in which case turn off flag */ return;}/* SCTRIN - auxiliary for FIX_LINE. * lim - # cols chars are allowed to use * ccol - current column (0 = bol) * Returns when see EOL or EOF, or * when all columns have been filled up. Retval-ccol = # overflow. * Note that any overflow is indivisible (i.e. a char with a * multi-col representation is responsible for the overflow). * So, overflow = 0 means next char would be in 1st non-ex column * and overflow > 0 means last char read has extra columns, but * it did start within bounds. */sctrin(to, lim, ccol)char *to;int lim;int ccol;{ register SBBUF *sb; register col, cnt; sb = (SBBUF *) cur_buf; col = ccol; sctreol = 0; /* No EOL or EOF seen */ do { cnt = sb_getc(sb); if(cnt == EOF) { --sctreol; /* Say EOF seen! */ return(col); }#if FX_EOLMODE if(cnt == CR) /* Possible EOL? */ { if(eolcrlf(sb)) { if((cnt = sb_getc(sb)) == LF) /* Real EOL? */ { sctreol++; return col; /* Yes, return */ } /* Stray CR, back up & fall thru */ if(cnt != EOF) sb_backc(sb); cnt = CR; /* Show stray CR */ } } else if (cnt == LF) { if(!eolcrlf(sb)) /* Real EOL? */ { sctreol++; return col; /* Yes, return */ } /* If EOL mode is CRLF then hitting a LF ** can only happen for stray LFs (the ** previous check for CR takes care of ** CRLFs, and we never start scanning ** from the middle of a CRLF. ** Drop thru to show stray LF. */ }#else if(cnt == LF) { sctreol++; /* Say EOL seen */ return col; }#endif /*_FX_EOLMODE*/ cnt = sctr(cnt, to, col); to += cnt; col += cnt; } while(col < lim); /* If we're stopping because last char put us precisely at the ** end of the line, make a further check to see whether an EOL ** is next. If so, we can include that in the line since it ** doesn't need any more columns for representation! */ if (col == lim) /* If stopping exactly at edge of screen */ switch (sb_getc(sb)) /* Check out next char */ { case EOF: --sctreol; /* Yes, note EOF seen */ break; /* and can return immed */#if FX_EOLMODE case CR: /* Possible EOL? */ if(eolcrlf(sb)) { if((cnt = sb_getc(sb)) == LF) /* Real EOL? */ { sctreol++; /* Yes, set flag */ break; /* and return */ } /* Stray CR, back up & fall thru */ if(cnt != EOF) /* Back up char that */ sb_backc(sb); /* came after the CR */ sb_rgetc(sb); /* Then back over CR */ break; } sb_backc(sb); break; case LF: if(!eolcrlf(sb)) /* Real EOL? */ { sctreol++; /* Yes, set flag */ break; /* and return */ } /* If EOL mode is CRLF then hitting a LF ** can only happen for stray LFs (the ** previous check for CR takes care of ** CRLFs, and we never start scanning ** from the middle of a CRLF. ** Drop thru into default to back up over LF. */#else case LF: sctreol++; /* Say EOL seen */ break; /* and return */#endif /*-FX_EOLMODE*/ default: sb_backc(sb); /* Back up over random char */ break; } return(col);}/* SCTR - Screen Char TRanslation routine.** This routine is completely responsible for the way a buffer char is** displayed on the screen. Given a char and the current column position,** it stores the representation using the given pointer and returns** the number of chars (columns) used by the representation.** Normal printing chars (plus space) are simply themselves.** TAB is a variable number of spaces depending on the column pos.** (we use standard tabstops of 8)** All control chars are uparrow followed by a printing char.** e.g. ctrl-A = ^A** This includes ESC which is ^[.** DEL is shown as ^?.** Chars with the 8th bit set have the prefix CI_META (currently ~) and** the rest of the representation is as above (except for TAB).** Chars with the 9th bit set have the prefix CI_TOP (currently |) and** the rest of the representation is as above (except for TAB).** This only exists for systems with 9-bit chars such as TOPS-20.*/static intsctr(ch, to, ccol)int ch; /* Buffer char to translate */char *to; /* Place to deposit translation in */int ccol; /* Current column position */{ register char *cp; register c, n; c = ch; if(037 < c && c < 0177) /* Most common case */ { *to = c; return(1); } cp = to; if(c == TAB) /* Next most common case */ { n = 010 - (ccol&07); /* Tab stops are every 8 cols */ ccol = n; /* Save value */ do *cp++ = SP; while (--n); return(ccol); } ccol = 1; /* Re-use var */#if TOPS20 if(c&0400) /* 9th bit set? */ { *cp++ = CI_TOP; ccol++; }#endif /*TOPS20*/ if(c&0200) { *cp++ = CI_META; ccol++; } if((c &= 0177) <= 037 || c == 0177) { *cp++ = CI_CNTRL; c ^= 0100; /* Transform cntrl char */ ccol++; } *cp = c; return(ccol);}/* INSLIN(line, N, wind) - Insert lines * DELLIN(line, N, wind) - Delete lines * Both routines insert/delete N lines at "line" in window "wind" * and update the screen image accordingly. */inslin (line, n, win)int line; /* line number to insert BEFORE */int n; /* number of lines to insert */struct window *win; /* window we are in */{ register int i; register int bot; register char **savp; char *savscr[MAXHT]; bot = win -> w_ht + win -> w_pos; t_curpos (line, 0); t_inslin (n, bot); /* do the insertion on the screen */ savp = &savscr[0]; for (i = 1; i <= n; i++) /* free lines that fall off-screen */ *savp++ = scr[bot - i]->sl_line; for (i = bot - 1; i >= line + n; i--) /* move down lines */ { scr[i]->sl_line = scr[i - n]->sl_line; /* below the insertion */ scr[i]->sl_col = scr[i - n]->sl_col; } savp = &savscr[0]; for (i = line + n - 1; i >= line; i--) /* blank lines where inserted */ { scr[i]->sl_line = *savp++; scr[i]->sl_col = 0; } for(i = line; i < bot; ++i) scr[i]->sl_flg |= SL_MOD;}dellin (line, n, win)int line; /* first line to be deleted */int n; /* number of lines to be deleted */struct window *win; /* window we are in */{ register int i; register int bot; register char **savp; char *savscr[MAXHT]; bot = win -> w_ht + win -> w_pos; t_curpos (line, 0); t_dellin (n, bot); /* do the deletion on the screen */ savp = &savscr[0]; for (i = line; i < line + n; i++) /* free the deleted lines */ *savp++ = scr[i]->sl_line; for (i = line; i < bot - n; i++) /* move lines up to fill */ { scr[i]->sl_line = scr[i + n]->sl_line; /* deleted spaces */ scr[i]->sl_col = scr[i + n]->sl_col; } savp = &savscr[0]; for (i = bot - n; i < bot; i++) /* blank lines at bottom */ { scr[i]->sl_line = *savp++; scr[i]->sl_col = 0; } for(i = line; i < bot; ++i) scr[i]->sl_flg |= SL_MOD;}/* T_ Terminal functions - these are similar to the terminal-dependent * routines in EETERM (which they call) but rely on some knowledge of * the screen image in order to do their job cleverly. */#if FX_SOWIND/* T_DOSTANDOUT(on) - Turn standout mode on or off, cleverly.** Returns previous state.*/static int curso = 0; /* Current state (initially off) */intt_dostandout(on)int on;{ int oldso; if ((oldso = curso) != on) /* If desired state doesn't match, */ { t_standout(on); /* invoke new state. */ curso = on; } return oldso;}#endift_move(y,x)register int y,x;{ register int d; if(y != curs_lin) /* No vertical smarts yet */ { t_curpos(y, x); return; } if((d = (x - curs_col)) >= 0) /* Find diff in column position */ { if(d == 0) return; /* If none, nothing to do! */ /* Moving right. If distance is less than abs-move cost, * do clever right-move by copying screen image */ if(d < tvc_pos)#if FX_SOWIND /* Ensure not in standout mode */ if((scr[y]->sl_flg&(SL_CSO|SL_NSO))==0)#endif { tputn(&scr[y]->sl_line[curs_col], d); curs_col = x; return; } } /* Moving to left, try to do clever left-move by backspacing * instead of using abs move. */ else if((d = -d)*tvc_bs < tvc_pos) { do { t_backspace(); } while(--d); return; } /* No luck with cleverness, just move. */ t_curpos(y, x);}t_docleol(){ register struct scr_line *s; register int cnt, ocol; if(trm_flags&TF_CLEOL) t_cleol(); /* Winning */ else /* Losing */ { s = scr[curs_lin]; if((cnt = s->sl_col - curs_col) > 0) {#if FX_SOWIND int oldso = t_dostandout(0);#endif ocol = curs_col; do { tput(SP); curs_col++; } while(--cnt);#if FX_SOWIND t_dostandout(oldso);#endif t_move(curs_lin, ocol); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -