rxvtlib_screen.c
来自「具有IDE功能的编辑器」· C语言 代码 · 共 2,128 行 · 第 1/5 页
C
2,128 行
/* EXTPROTO */void rxvtlib_scr_E (rxvtlib *o){ int i, j; text_t *t; rend_t *r, fs; o->want_refresh = 1; ZERO_SCROLLBACK; RESET_CHSTAT; CHECK_SELECTION (3); fs = o->rstyle; for (i = o->TermWin.saveLines; i < o->TermWin.nrow + o->TermWin.saveLines; i++) { t = o->screen.text[i]; r = o->screen.rend[i]; for (j = 0; j < o->TermWin.ncol; j++) { *t++ = 'E'; *r++ = fs; } o->screen.tlen[i] = o->TermWin.ncol; /* make the `E's selectable */ }}/* ------------------------------------------------------------------------- *//* * Insert/Delete <count> lines *//* EXTPROTO */void rxvtlib_scr_insdel_lines (rxvtlib *o, int count, int insdel){ int end; ZERO_SCROLLBACK; RESET_CHSTAT; if (rxvtlib_Gr_Displayed (o)) rxvtlib_Gr_scroll (o, 0); CHECK_SELECTION (1); if (o->screen.cur.row > o->screen.bscroll) return; end = o->screen.bscroll - o->screen.cur.row + 1; if (count > end) { if (insdel == DELETE) return; else if (insdel == INSERT) count = end; } if (o->screen.flags & Screen_WrapNext) o->screen.flags &= ~Screen_WrapNext; rxvtlib_scroll_text (o, o->screen.cur.row, o->screen.bscroll, insdel * count, 0);/* fill the inserted or new lines with rstyle. TODO: correct for delete? */ if (insdel == DELETE) end = o->screen.bscroll + o->TermWin.saveLines; else if (insdel == INSERT) end = o->screen.cur.row + count - 1 + o->TermWin.saveLines; for (; count--;) { rxvtlib_blank_screen_mem (o, o->screen.text, o->screen.rend, end, o->rstyle); o->screen.tlen[end--] = 0; }}/* ------------------------------------------------------------------------- *//* * Insert/Delete <count> characters from the current position *//* EXTPROTO */void rxvtlib_scr_insdel_chars (rxvtlib *o, int count, int insdel){ int col, row; rend_t tr; o->want_refresh = 1; ZERO_SCROLLBACK;#if 0 RESET_CHSTAT;#endif if (rxvtlib_Gr_Displayed (o)) rxvtlib_Gr_scroll (o, 0); if (count <= 0) return; CHECK_SELECTION (1); MIN_IT (count, (o->TermWin.ncol - o->screen.cur.col)); row = o->screen.cur.row + o->TermWin.saveLines; o->screen.flags &= ~Screen_WrapNext; switch (insdel) { case INSERT: for (col = o->TermWin.ncol - 1; (col - count) >= o->screen.cur.col; col--) { o->screen.text[row][col] = o->screen.text[row][col - count]; o->screen.rend[row][col] = o->screen.rend[row][col - count]; } if (o->screen.tlen[row] != -1) { o->screen.tlen[row] += count; MIN_IT (o->screen.tlen[row], o->TermWin.ncol); } if (o->selection.op && o->current_screen == o->selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER (o->selection.beg, o->screen.cur)) { if (o->selection.end.row != o->screen.cur.row || (o->selection.end.col + count >= o->TermWin.ncol)) CLEAR_SELECTION; else { /* shift selection */ o->selection.beg.col += count; o->selection.mark.col += count; /* XXX: yes? */ o->selection.end.col += count; } } blank_line (&(o->screen.text[row][o->screen.cur.col]), &(o->screen.rend[row][o->screen.cur.col]), count, o->rstyle); break; case ERASE: o->screen.cur.col += count; /* don't worry if > TermWin.ncol */ CHECK_SELECTION (1); o->screen.cur.col -= count; blank_line (&(o->screen.text[row][o->screen.cur.col]), &(o->screen.rend[row][o->screen.cur.col]), count, o->rstyle); break; case DELETE: tr = o->screen.rend[row][o->TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); for (col = o->screen.cur.col; (col + count) < o->TermWin.ncol; col++) { o->screen.text[row][col] = o->screen.text[row][col + count]; o->screen.rend[row][col] = o->screen.rend[row][col + count]; } blank_line (&(o->screen.text[row][o->TermWin.ncol - count]), &(o->screen.rend[row][o->TermWin.ncol - count]), count, tr); if (o->screen.tlen[row] == -1) /* break line continuation */ o->screen.tlen[row] = o->TermWin.ncol; o->screen.tlen[row] -= count; MAX_IT (o->screen.tlen[row], 0); if (o->selection.op && o->current_screen == o->selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER (o->selection.beg, o->screen.cur)) { if (o->selection.end.row != o->screen.cur.row || (o->screen.cur.col >= o->selection.beg.col - count) || o->selection.end.col >= o->TermWin.ncol) CLEAR_SELECTION; else { /* shift selection */ o->selection.beg.col -= count; o->selection.mark.col -= count; /* XXX: yes? */ o->selection.end.col -= count; } } break; }#if 0 if ((o->screen.rend[row][0] & RS_multiMask) == RS_multi2) { o->screen.rend[row][0] &= ~RS_multiMask; o->screen.text[row][0] = ' '; } if ((o->screen.rend[row][o->TermWin.ncol - 1] & RS_multiMask) == RS_multi1) { o->screen.rend[row][o->TermWin.ncol - 1] &= ~RS_multiMask; o->screen.text[row][o->TermWin.ncol - 1] = ' '; }#endif}/* ------------------------------------------------------------------------- *//* * Set the scrolling region * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r *//* EXTPROTO */void rxvtlib_scr_scroll_region (rxvtlib *o, int top, int bot){ MAX_IT (top, 0); MIN_IT (bot, o->TermWin.nrow - 1); if (top > bot) return; o->screen.tscroll = top; o->screen.bscroll = bot; rxvtlib_scr_gotorc (o, 0, 0, 0);}/* ------------------------------------------------------------------------- *//* * Make the cursor visible/invisible * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l *//* EXTPROTO */void rxvtlib_scr_cursor_visible (rxvtlib *o, int mode){ o->want_refresh = 1; if (mode) o->screen.flags |= Screen_VisibleCursor; else o->screen.flags &= ~Screen_VisibleCursor;}/* ------------------------------------------------------------------------- *//* * Set/unset automatic wrapping * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l *//* EXTPROTO */void rxvtlib_scr_autowrap (rxvtlib *o, int mode){ if (mode) o->screen.flags |= Screen_Autowrap; else o->screen.flags &= ~Screen_Autowrap;}/* ------------------------------------------------------------------------- *//* * Set/unset margin origin mode * Absolute mode: line numbers are counted relative to top margin of screen * and the cursor can be moved outside the scrolling region. * Relative mode: line numbers are relative to top margin of scrolling region * and the cursor cannot be moved outside. * XTERM_SEQ: Set Absolute: ESC [ ? 6 h * XTERM_SEQ: Set Relative: ESC [ ? 6 l *//* EXTPROTO */void rxvtlib_scr_relative_origin (rxvtlib *o, int mode){ if (mode) o->screen.flags |= Screen_Relative; else o->screen.flags &= ~Screen_Relative; rxvtlib_scr_gotorc (o, 0, 0, 0);}/* ------------------------------------------------------------------------- *//* * Set insert/replace mode * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l *//* EXTPROTO */void rxvtlib_scr_insert_mode (rxvtlib *o, int mode){ if (mode) o->screen.flags |= Screen_Insert; else o->screen.flags &= ~Screen_Insert;}/* ------------------------------------------------------------------------- *//* * Set/Unset tabs * XTERM_SEQ: Set tab at current column : ESC H * XTERM_SEQ: Clear tab at current column: ESC [ 0 g * XTERM_SEQ: Clear all tabs : ESC [ 3 g *//* EXTPROTO */void rxvtlib_scr_set_tab (rxvtlib *o, int mode){ if (mode < 0) MEMSET (o->tabs, 0, o->TermWin.ncol * sizeof (char)); else if (o->screen.cur.col < o->TermWin.ncol) o->tabs[o->screen.cur.col] = (mode ? 1 : 0);}/* ------------------------------------------------------------------------- *//* * Set reverse/normal video * XTERM_SEQ: Reverse video: ESC [ ? 5 h * XTERM_SEQ: Normal video : ESC [ ? 5 l *//* EXTPROTO */void rxvtlib_scr_rvideo_mode (rxvtlib *o, int mode){ int i, j; rend_t *r; if (o->rvideo != mode) { o->rvideo = mode; o->rstyle ^= RS_RVid; for (i = 0; i < o->TermWin.nrow; i++) { r = o->screen.rend[o->TermWin.saveLines + i]; for (j = 0; j < o->TermWin.ncol; j++) *r++ ^= RS_RVid; } rxvtlib_scr_refresh (o, SLOW_REFRESH); }}/* ------------------------------------------------------------------------- *//* * Report current cursor position * XTERM_SEQ: Report position: ESC [ 6 n *//* EXTPROTO */void rxvtlib_scr_report_position (rxvtlib *o){ rxvtlib_tt_printf (o, "\033[%d;%dR", o->screen.cur.row + 1, o->screen.cur.col + 1);}/* ------------------------------------------------------------------------- * * FONTS * * ------------------------------------------------------------------------- *//* * Set font style *//* INTPROTO */void rxvtlib_set_font_style (rxvtlib *o){ o->rstyle &= ~RS_fontMask; switch (o->charsets[o->screen.charset]) { case '0': /* DEC Special Character & Line Drawing Set */ o->rstyle |= RS_acsFont; break; case 'A': /* United Kingdom (UK) */ o->rstyle |= RS_ukFont; break; case 'B': /* United States (USASCII) */ break; case '<': /* Multinational character set */ break; case '5': /* Finnish character set */ break; case 'C': /* Finnish character set */ break; case 'K': /* German character set */ break; }}/* ------------------------------------------------------------------------- *//* * Choose a font * XTERM_SEQ: Invoke G0 character set: CTRL-O * XTERM_SEQ: Invoke G1 character set: CTRL-N * XTERM_SEQ: Invoke G2 character set: ESC N * XTERM_SEQ: Invoke G3 character set: ESC O *//* EXTPROTO */void rxvtlib_scr_charset_choose (rxvtlib *o, int set){ o->screen.charset = set; rxvtlib_set_font_style (o);}/* ------------------------------------------------------------------------- *//* * Set a font * XTERM_SEQ: Set G0 character set: ESC ( <C> * XTERM_SEQ: Set G1 character set: ESC ) <C> * XTERM_SEQ: Set G2 character set: ESC * <C> * XTERM_SEQ: Set G3 character set: ESC + <C> * See set_font_style for possible values for <C> *//* EXTPROTO */void rxvtlib_scr_charset_set (rxvtlib *o, int set, unsigned int ch){#ifdef MULTICHAR_SET o->multi_byte = (set < 0); set = abs (set);#endif o->charsets[set] = (unsigned char)ch; rxvtlib_set_font_style (o);}/* ------------------------------------------------------------------------- * * MULTIPLE-CHARACTER FONT SET MANIPULATION FUNCTIONS * * ------------------------------------------------------------------------- */#ifdef MULTICHAR_SET/* INTPROTO */void eucj2jis (unsigned char *str, int len){ register int i; for (i = 0; i < len; i++) str[i] &= 0x7F;}/* ------------------------------------------------------------------------- *//* INTPROTO */void sjis2jis (unsigned char *str, int len){ register int i; unsigned char *high, *low; for (i = 0; i < len; i += 2, str += 2) { high = str; low = str + 1; (*high) -= (*high > 0x9F ? 0xB1 : 0x71); *high = (*high) * 2 + 1; if (*low > 0x9E) { *low -= 0x7E; (*high)++; } else { if (*low > 0x7E) (*low)--; *low -= 0x1F; } }}/* INTPROTO */void big5dummy (unsigned char *str, int len){}/* INTPROTO */void gb2jis (unsigned char *str, int len){ register int i; for (i = 0; i < len; i++) str[i] &= 0x7F;}/* EXTPROTO */void rxvtlib_set_multichar_encoding (rxvtlib *o, const char *str){ if (str && *str) { if (!strcasecmp (str, "sjis")) { o->encoding_method = SJIS; /* Kanji SJIS */ o->multichar_decode = sjis2jis; } else if (!strcasecmp (str, "eucj")) { o->encoding_method = EUCJ; /* Kanji EUCJ */ o->multichar_decode = eucj2jis;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?