📄 term.c
字号:
curY++; /* ESC S moves to next line where the TS_standout_mode was */ curX = 0; } else cmgoto (curY, 0); /* reposition to kill standout marker */ } clear_end_of_line_raw (first_unused_hpos); reassert_line_highlight (new_highlight, curY);}/* Move to absolute position, specified origin 0 */move_cursor (row, col){ col += chars_wasted[row] & 077; if (move_cursor_hook) { (*move_cursor_hook) (row, col); return; } if (curY == row && curX == col) return; if (!TF_standout_motion) background_highlight (); if (!TF_insmode_motion) turn_off_insert (); cmgoto (row, col);}/* Similar but don't take any account of the wasted characters. */raw_move_cursor (row, col){ if (raw_move_cursor_hook) { (*raw_move_cursor_hook) (row, col); return; } if (curY == row && curX == col) return; if (!TF_standout_motion) background_highlight (); if (!TF_insmode_motion) turn_off_insert (); cmgoto (row, col);}/* Erase operations *//* clear from cursor to end of screen */clear_to_end (){ register int i; if (clear_to_end_hook) { (*clear_to_end_hook) (); return; } if (TS_clr_to_bottom) { background_highlight (); OUTPUT (TS_clr_to_bottom); bzero (chars_wasted + curY, screen_height - curY); } else { for (i = curY; i < screen_height; i++) { move_cursor (i, 0); clear_end_of_line_raw (screen_width); } }}/* Clear entire screen */clear_screen (){ if (clear_screen_hook) { (*clear_screen_hook) (); return; } if (TS_clr_screen) { background_highlight (); OUTPUT (TS_clr_screen); bzero (chars_wasted, screen_height); cmat (0, 0); } else { move_cursor (0, 0); clear_to_end (); }}/* Clear to end of line, but do not clear any standout marker. Assumes that the cursor is positioned at a character of real text, which implies it cannot be before a standout marker unless the marker has zero width. Note that the cursor may be moved. */clear_end_of_line (first_unused_hpos) int first_unused_hpos;{ if (TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0) output_chars (" ", 1); clear_end_of_line_raw (first_unused_hpos);}/* Clear from cursor to end of line. Assume that the line is already clear starting at column first_unused_hpos. If the cursor is at a standout marker, erase the marker. Note that the cursor may be moved, on terminals lacking a `ce' string. */clear_end_of_line_raw (first_unused_hpos) int first_unused_hpos;{ register int i; first_unused_hpos += chars_wasted[curY] & 077; if (clear_end_of_line_hook) { (*clear_end_of_line_hook) (first_unused_hpos); return; } if (curX >= first_unused_hpos) return; /* Notice if we are erasing a magic cookie */ if (curX == 0) chars_wasted[curY] = 0; background_highlight (); if (TS_clr_line) { OUTPUT1 (TS_clr_line); } else { /* have to do it the hard way */ turn_off_insert (); for (i = curX; i < first_unused_hpos; i++) { if (termscript) fputc (' ', termscript); putchar (' '); } cmplus (first_unused_hpos - curX); }}output_chars (string, len) register char *string; int len;{ register char *p; register int n; register char *buf; register int c; char *first_check; if (output_chars_hook) { (*output_chars_hook) (string, len); return; } highlight_if_desired (); turn_off_insert (); /* Don't dare write in last column of bottom line, if AutoWrap, since that would scroll the whole screen on some terminals. */ if (AutoWrap && curY + 1 == screen_height && curX + len - (chars_wasted[curY] & 077) == screen_width) len --; cmplus (len); first_check = string; if (RPov > len && !TF_underscore && !TF_hazeltine) { fwrite (string, 1, len, stdout); if (ferror (stdout)) clearerr (stdout); if (termscript) fwrite (string, 1, len, termscript); } else while (--len >= 0) { c = *string; if (RPov + 1 < len && string >= first_check) { int repeat_count; p = string + 1; /* Now, len is number of chars left starting at p */ while (*p++ == c); p--; repeat_count = p - string; if (repeat_count > RPov) { buf = tparam (TS_repeat, 0, 0, *string, repeat_count); tputs (buf, repeat_count, cmputc); free (buf); string = p; len -= repeat_count - 1; continue; } else /* If all N identical chars are too few, don't even consider the last N-1, the last N-2,... */ first_check = p; } if (c == '_' && TF_underscore) { if (termscript) fputc (' ', termscript); putchar (' '); OUTPUT (Left); } if (TF_hazeltine && c == '~') c = '`'; if (termscript) fputc (c, termscript); putchar (c); string++; }}/* If start is zero, insert blanks instead of a string at start */insert_chars (start, len) register char *start; int len;{ register char *buf; register int c; if (insert_chars_hook) { (*insert_chars_hook) (start, len); return; } highlight_if_desired (); if (TS_ins_multi_chars) { buf = tparam (TS_ins_multi_chars, 0, 0, len); OUTPUT1 (buf); free (buf); if (start) output_chars (start, len); return; } turn_on_insert (); cmplus (len); if (!TF_underscore && !TF_hazeltine && start && TS_pad_inserted_char == 0 && TS_ins_char == 0) { fwrite (start, 1, len, stdout); if (termscript) fwrite (start, 1, len, termscript); } else while (--len >= 0) { OUTPUT1_IF (TS_ins_char); if (!start) c = ' '; else { c = *start++; if (TF_hazeltine && c == '~') c = '`'; } if (termscript) fputc (c, termscript); putchar (c); OUTPUT1_IF (TS_pad_inserted_char); }}delete_chars (n) register int n;{ char *buf; register int i; if (delete_chars_hook) { (*delete_chars_hook) (n); return; } if (delete_in_insert_mode) { turn_on_insert (); } else { turn_off_insert (); OUTPUT_IF (TS_delete_mode); } if (TS_del_multi_chars) { buf = tparam (TS_del_multi_chars, 0, 0, n); OUTPUT1 (buf); free (buf); } else for (i = 0; i < n; i++) OUTPUT1 (TS_del_char); if (!delete_in_insert_mode) OUTPUT_IF (TS_end_delete_mode);}/* Insert N lines at vpos VPOS. If N is negative, delete -N lines. */ins_del_lines (vpos, n) int vpos, n;{ char *multi = n > 0 ? TS_ins_multi_lines : TS_del_multi_lines; char *single = n > 0 ? TS_ins_line : TS_del_line; char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll; register int i = n > 0 ? n : -n; register char *buf; if (ins_del_lines_hook) { (*ins_del_lines_hook) (vpos, n); return; } /* If the lines below the insertion are being pushed into the end of the window, this is the same as clearing; and we know the lines are already clear, since the matching deletion has already been done. So can ignore this. */ /* If the lines below the deletion are blank lines coming out of the end of the window, don't bother, as there will be a matching inslines later that will flush them. */ if (scroll_region_ok && vpos + i >= specified_window) return; if (!memory_below_screen && vpos + i >= screen_height) return; if (multi) { raw_move_cursor (vpos, 0); background_highlight (); buf = tparam (multi, 0, 0, i); OUTPUT (buf); free (buf); } else if (single) { raw_move_cursor (vpos, 0); background_highlight (); while (--i >= 0) OUTPUT (single); if (TF_teleray) curX = 0; } else { set_scroll_region (vpos, specified_window); if (n < 0) raw_move_cursor (specified_window - 1, 0); else raw_move_cursor (vpos, 0); background_highlight (); while (--i >= 0) OUTPUTL (scroll, specified_window - vpos); set_scroll_region (0, specified_window); } if (TN_standout_width >= 0) { register lower_limit = scroll_region_ok ? specified_window : screen_height; if (n < 0) { bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos], lower_limit - vpos + n); bzero (&chars_wasted[lower_limit + n], - n); } else { bcopy (&chars_wasted[vpos], ©buf[vpos], lower_limit - vpos - n); bcopy (©buf[vpos], &chars_wasted[vpos + n], lower_limit - vpos - n); bzero (&chars_wasted[vpos], n); } } if (!scroll_region_ok && memory_below_screen && n < 0) { move_cursor (screen_height + n, 0); clear_to_end (); }}extern int cost; /* In cm.c */extern evalcost ();/* Compute cost of sending "str", in characters, not counting any line-dependent padding. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -