📄 screen.c
字号:
if (*slp != -1) { *slp += count; MIN_IT(*slp, r->TermWin.ncol); } if (r->selection.op && r->h->current_screen == r->selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER(r->selection.beg, r->screen.cur)) { if (r->selection.end.row != r->screen.cur.row || (r->selection.end.col + count >= r->TermWin.ncol)) CLEAR_SELECTION(r); else { /* shift selection */ r->selection.beg.col += count; r->selection.mark.col += count; /* XXX: yes? */ r->selection.end.col += count; } } rxvt_blank_line(&(stp[r->screen.cur.col]), &(srp[r->screen.cur.col]), (unsigned int)count, r->h->rstyle); break; case ERASE: r->screen.cur.col += count; /* don't worry if > r->TermWin.ncol */ rxvt_selection_check(r, 1); r->screen.cur.col -= count; rxvt_blank_line(&(stp[r->screen.cur.col]), &(srp[r->screen.cur.col]), (unsigned int)count, r->h->rstyle); break; case DELETE: tr = srp[r->TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); for (col = r->screen.cur.col; (col + count) < r->TermWin.ncol; col++) { stp[col] = stp[col + count]; srp[col] = srp[col + count]; } rxvt_blank_line(&(stp[r->TermWin.ncol - count]), &(srp[r->TermWin.ncol - count]), (unsigned int)count, tr); if (*slp == -1) /* break line continuation */ *slp = r->TermWin.ncol; *slp -= count; MAX_IT(*slp, 0); if (r->selection.op && r->h->current_screen == r->selection.screen && ROWCOL_IN_ROW_AT_OR_AFTER(r->selection.beg, r->screen.cur)) { if (r->selection.end.row != r->screen.cur.row || (r->screen.cur.col >= r->selection.beg.col - count) || r->selection.end.col >= r->TermWin.ncol) CLEAR_SELECTION(r); else { /* shift selection */ r->selection.beg.col -= count; r->selection.mark.col -= count; /* XXX: yes? */ r->selection.end.col -= count; } } break; }#if 0 if (IS_MULTI2(srp[0])) { srp[0] &= ~RS_multiMask; stp[0] = ' '; } if (IS_MULTI1(srp[r->TermWin.ncol - 1])) { srp[r->TermWin.ncol - 1] &= ~RS_multiMask; stp[r->TermWin.ncol - 1] = ' '; }#endif}/* ------------------------------------------------------------------------- *//* * Set the scrolling region * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r *//* EXTPROTO */voidrxvt_scr_scroll_region(rxvt_t *r, int top, int bot){ MAX_IT(top, 0); MIN_IT(bot, r->TermWin.nrow - 1); if (top > bot) return; r->screen.tscroll = top; r->screen.bscroll = bot; rxvt_scr_gotorc(r, 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 */voidrxvt_scr_cursor_visible(rxvt_t *r, int mode){ r->h->want_refresh = 1; if (mode) r->screen.flags |= Screen_VisibleCursor; else r->screen.flags &= ~Screen_VisibleCursor;}/* ------------------------------------------------------------------------- *//* * Set/unset automatic wrapping * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l *//* EXTPROTO */voidrxvt_scr_autowrap(rxvt_t *r, int mode){ if (mode) r->screen.flags |= Screen_Autowrap; else r->screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);}/* ------------------------------------------------------------------------- *//* * 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 */voidrxvt_scr_relative_origin(rxvt_t *r, int mode){ if (mode) r->screen.flags |= Screen_Relative; else r->screen.flags &= ~Screen_Relative; rxvt_scr_gotorc(r, 0, 0, 0);}/* ------------------------------------------------------------------------- *//* * Set insert/replace mode * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l *//* EXTPROTO */voidrxvt_scr_insert_mode(rxvt_t *r, int mode){ if (mode) r->screen.flags |= Screen_Insert; else r->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 */voidrxvt_scr_set_tab(rxvt_t *r, int mode){ if (mode < 0) MEMSET(r->tabs, 0, r->TermWin.ncol * sizeof(char)); else if (r->screen.cur.col < r->TermWin.ncol) r->tabs[r->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 */voidrxvt_scr_rvideo_mode(rxvt_t *r, int mode){ XGCValues gcvalue; if (r->h->rvideo != mode) { r->h->rvideo = mode; SWAP_IT(r->PixColors[Color_fg], r->PixColors[Color_bg], Pixel);#if defined(XPM_BACKGROUND) if (r->h->bgPixmap.pixmap == None)#endif#if defined(TRANSPARENT) if (!(r->Options & Opt_transparent) || r->h->am_transparent == 0)#endif XSetWindowBackground(r->Xdisplay, r->TermWin.vt, r->PixColors[Color_bg]); gcvalue.foreground = r->PixColors[Color_fg]; gcvalue.background = r->PixColors[Color_bg]; XChangeGC(r->Xdisplay, r->TermWin.gc, GCBackground | GCForeground, &gcvalue); rxvt_scr_clear(r); rxvt_scr_touch(r, True); }}/* ------------------------------------------------------------------------- *//* * Report current cursor position * XTERM_SEQ: Report position: ESC [ 6 n *//* EXTPROTO */voidrxvt_scr_report_position(rxvt_t *r){ rxvt_tt_printf(r, "\033[%d;%dR", r->screen.cur.row + 1, r->screen.cur.col + 1);}/* ------------------------------------------------------------------------- * * FONTS * * ------------------------------------------------------------------------- *//* * Set font style *//* INTPROTO */voidrxvt_set_font_style(rxvt_t *r){ r->h->rstyle &= ~RS_fontMask; switch (r->h->charsets[r->screen.charset]) { case '0': /* DEC Special Character & Line Drawing Set */ r->h->rstyle |= RS_acsFont; break; case 'A': /* United Kingdom (UK) */ r->h->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 */voidrxvt_scr_charset_choose(rxvt_t *r, int set){ r->screen.charset = set; rxvt_set_font_style(r);}/* ------------------------------------------------------------------------- *//* * 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 */voidrxvt_scr_charset_set(rxvt_t *r, int set, unsigned int ch){#ifdef MULTICHAR_SET r->h->multi_byte = !!(set < 0); set = abs(set);#endif r->h->charsets[set] = (unsigned char)ch; rxvt_set_font_style(r);}/* ------------------------------------------------------------------------- * * MULTIPLE-CHARACTER FONT SET MANIPULATION FUNCTIONS * * ------------------------------------------------------------------------- */#ifdef MULTICHAR_SET/* EXTPROTO */voidrxvt_euc2jis(unsigned char *str, int len){ int i; for (i = 0; i < len; i++) str[i] &= 0x7F;}/* ------------------------------------------------------------------------- *//* INTPROTO */voidrxvt_sjis2jis(unsigned char *str, int len){ 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 */voidrxvt_decodedummy(unsigned char *str __attribute__((unused)), int len __attribute__((unused))){}/* EXTPROTO */voidrxvt_set_multichar_encoding(rxvt_t *r, const char *str){ KNOWN_ENCODINGS *a; if (str && *str) { for (a = (KNOWN_ENCODINGS *)known_encodings; a->name; a++) { if (STRCASECMP(str, a->name) == 0) { r->encoding_method = a->method; r->h->multichar_decode = a->func; break; } } }}#endif /* MULTICHAR_SET *//* ------------------------------------------------------------------------- * * GRAPHICS COLOURS * * ------------------------------------------------------------------------- */#ifdef RXVT_GRAPHICS/* EXTPROTO */intrxvt_scr_get_fgcolor(rxvt_t *r){ return GET_FGCOLOR(r->h->rstyle);}/* ------------------------------------------------------------------------- *//* EXTPROTO */intrxvt_scr_get_bgcolor(rxvt_t *r){ return GET_BGCOLOR(r->h->rstyle);}#endif/* ------------------------------------------------------------------------- * * MAJOR SCREEN MANIPULATION * * ------------------------------------------------------------------------- *//* * Refresh an area */enum { PART_BEG = 0, PART_END, RC_COUNT};/* EXTPROTO */voidrxvt_scr_expose(rxvt_t *r, int x, int y, int width, int height, Bool refresh){ int i; row_col_t rc[RC_COUNT]; if (r->drawn_text == NULL) /* sanity check */ return;#ifdef DEBUG_STRICT x = max(x, (int)r->TermWin.int_bwidth); x = min(x, (int)r->TermWin.width); y = max(y, (int)r->TermWin.int_bwidth); y = min(y, (int)r->TermWin.height);#endif/* round down */ rc[PART_BEG].col = Pixel2Col(x); rc[PART_BEG].row = Pixel2Row(y);/* round up */ rc[PART_END].col = Pixel2Width(x + width + r->TermWin.fwidth - 1); rc[PART_END].row = Pixel2Row(y + height + r->TermWin.fheight - 1);/* sanity checks */ for (i = PART_BEG; i < RC_COUNT; i++) { MIN_IT(rc[i].col, r->TermWin.ncol - 1); MIN_IT(rc[i].row, r->TermWin.nrow - 1); } D_SCREEN((stderr, "rxvt_scr_expose(x:%d, y:%d, w:%d, h:%d) area (c:%d,r:%d)-(c:%d,r:%d)", x, y, width, height, rc[PART_BEG].col, rc[PART_BEG].row, rc[PART_END].col, rc[PART_END].row)); for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) MEMSET(&(r->drawn_text[i][rc[PART_BEG].col]), 0, rc[PART_END].col - rc[PART_BEG].col + 1); if (refresh) rxvt_scr_refresh(r, SLOW_REFRESH | REFRESH_BOUNDS);}/* ------------------------------------------------------------------------- *//* * Refresh the entire screen *//* EXTPROTO */voidrxvt_scr_touch(rxvt_t *r, Bool refresh){ rxvt_scr_expose(r, 0, 0, r->TermWin.width, r->TermWin.height, refresh);}/* ------------------------------------------------------------------------- *//* * Move the display so that the line represented by scrollbar value Y is at * the top of the screen *//* EXTPROTO */intrxvt_scr_move_to(rxvt_t *r, int y, int len){ long p = 0; u_int16_t oldviewstart;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -