--- rxvt-unicode/src/screen.C 2012/06/29 14:01:53 1.423 +++ rxvt-unicode/src/screen.C 2022/08/04 18:28:44 1.465 @@ -4,10 +4,11 @@ * * Copyright (c) 1997-2001 Geoff Wing * Copyright (c) 2003-2007 Marc Lehmann + * Copyright (c) 2015 Emanuele Giaquinta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -96,7 +97,7 @@ /* Fill part/all of a line with blanks. */ void -rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW +rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const noexcept { if (!l.valid ()) { @@ -108,7 +109,7 @@ l.touch (); efs &= ~RS_baseattrMask; // remove italic etc. fontstyles - efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); + efs = SET_FONT (efs, FONTSET (efs)->find_space_font ()); text_t *et = l.t + col; rend_t *er = l.r + col; @@ -123,7 +124,7 @@ /* ------------------------------------------------------------------------- */ /* Fill a full line with blanks - make sure it is allocated first */ void -rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW +rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const noexcept { scr_blank_line (l, 0, ncol, efs); @@ -133,14 +134,14 @@ // nuke a single wide character at the given column void -rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW +rxvt_term::scr_kill_char (line_t &l, int col) const noexcept { // find begin while (col > 0 && l.t[col] == NOCHAR) col--; rend_t rend = l.r[col] & ~RS_baseattrMask; - rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); + rend = SET_FONT (rend, FONTSET (rend)->find_space_font ()); l.touch (); @@ -152,12 +153,22 @@ } while (col < ncol && l.t[col] == NOCHAR); } +// set the rendition of a single wide character beginning at the given column +void +rxvt_term::scr_set_char_rend (line_t &l, int col, rend_t rend) +{ + do { + l.r[col] = rend; + col++; + } while (col < ncol && l.t[col] == NOCHAR); +} + /* ------------------------------------------------------------------------- * * SCREEN INITIALISATION * * ------------------------------------------------------------------------- */ void -rxvt_term::scr_alloc () NOTHROW +rxvt_term::scr_alloc () noexcept { int tsize = sizeof (text_t) * ncol; int rsize = sizeof (rend_t) * ncol; @@ -190,6 +201,16 @@ row_buf = swap_buf + nrow; } +void +rxvt_term::copy_line (line_t &dst, line_t &src) +{ + scr_blank_screen_mem (dst, DEFAULT_RSTYLE); + dst.l = min (src.l, ncol); + memcpy (dst.t, src.t, sizeof (text_t) * dst.l); + memcpy (dst.r, src.r, sizeof (rend_t) * dst.l); + dst.f = src.f; +} + void ecb_cold rxvt_term::scr_reset () { @@ -232,15 +253,10 @@ line_t *prev_swap_buf = swap_buf; line_t *prev_row_buf = row_buf; - int common_col = min (prev_ncol, ncol); - scr_alloc (); if (!prev_row_buf) { - /* - * first time called (or after scr_release) so just malloc everything: don't rely on realloc - */ top_row = 0; term_start = 0; @@ -275,22 +291,24 @@ * add or delete rows as appropriate */ + int common_col = min (prev_ncol, ncol); + + // resize swap_buf, blank drawn_buf for (int row = min (nrow, prev_nrow); row--; ) { scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); - scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); - memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); - memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); - memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); + + copy_line (swap_buf [row], prev_swap_buf [row]); } int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row int pend = MOD (term_start + top_row , prev_total_rows); int q = total_rows; // rewrapped row - if (top_row) +#if ENABLE_FRILLS + if ((rewrap_always || top_row) && !rewrap_never) { // Re-wrap lines. This is rather ugly, possibly because I am too dumb // to come up with a lean and mean algorithm. @@ -316,12 +334,12 @@ int qlines = max (0, (llen - 1) / ncol) + 1; + q -= qlines; + // drop partial lines completely - if (q < qlines) + if (q < 0) break; - q -= qlines; - int lofs = 0; line_t *qline; @@ -372,38 +390,34 @@ } while (p != pend && q > 0); - term_start = total_rows - nrow; - top_row = q - term_start; - // make sure all terminal lines exist while (top_row > 0) scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); } else +#endif { - // if no scrollback exists (yet), wing, instead of wrap - - for (int row = min (nrow, prev_nrow); row--; ) + // wing, instead of wrap + do { - line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; - line_t &dst = row_buf [row]; - - scr_blank_screen_mem (dst, DEFAULT_RSTYLE); + p = MOD (p - 1, prev_total_rows); + q--; - memcpy (dst.t, src.t, sizeof (text_t) * common_col); - memcpy (dst.r, src.r, sizeof (rend_t) * common_col); + copy_line (row_buf [q], prev_row_buf [p]); } + while (p != pend); - for (int row = prev_nrow; row < nrow; row++) - scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE); - - term_start = 0; + screen.cur.row += nrow - prev_nrow; } + term_start = total_rows - nrow; + top_row = q - term_start; + clamp_it (screen.cur.row, 0, nrow - 1); clamp_it (screen.cur.col, 0, ncol - 1); } + // ensure drawn_buf, swap_buf and terminal rows are all initialized for (int row = nrow; row--; ) { if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); @@ -430,7 +444,7 @@ } void ecb_cold -rxvt_term::scr_release () NOTHROW +rxvt_term::scr_release () noexcept { chunk_free (chunk, chunk_size); chunk = 0; @@ -459,7 +473,7 @@ } void ecb_cold -rxvt_term::scr_soft_reset () NOTHROW +rxvt_term::scr_soft_reset () noexcept { /* only affects modes, nothing drastic such as clearing the screen */ #if ENABLE_OVERLAY @@ -483,7 +497,7 @@ * XTERM_SEQ: Restore cursor: ESC 8 */ void -rxvt_term::scr_cursor (cursor_mode mode) NOTHROW +rxvt_term::scr_cursor (cursor_mode mode) noexcept { screen_t *s; @@ -524,7 +538,7 @@ } void -rxvt_term::scr_swap_screen () NOTHROW +rxvt_term::scr_swap_screen () noexcept { if (!option (Opt_secondaryScreen)) return; @@ -582,7 +596,7 @@ // clear WrapNext indicator, solidifying position on next line void -rxvt_term::scr_do_wrap () NOTHROW +rxvt_term::scr_do_wrap () noexcept { if (!(screen.flags & Screen_WrapNext)) return; @@ -602,9 +616,9 @@ * Change the colour for following text */ void -rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW +rxvt_term::scr_color (unsigned int color, int fgbg) noexcept { - if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) + if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR24)) color = fgbg; if (fgbg == Color_fg) @@ -618,7 +632,7 @@ * Change the rendition style for following text */ void -rxvt_term::scr_rendition (int set, int style) NOTHROW +rxvt_term::scr_rendition (int set, int style) noexcept { if (set) rstyle |= style; @@ -635,7 +649,7 @@ * count negative ==> scroll down */ int ecb_hot -rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW +rxvt_term::scr_scroll_text (int row1, int row2, int count) noexcept { if (count == 0 || (row1 > row2)) return 0; @@ -705,7 +719,7 @@ if (option (Opt_scrollWithBuffer) && view_start != 0 && view_start != -saveLines) - scr_page (UP, count); + scr_page (count); if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); @@ -779,7 +793,7 @@ * Add text given in of length to screen struct */ void ecb_hot -rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW +rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) noexcept { if (len <= 0) /* sanity */ return; @@ -1001,8 +1015,8 @@ && ROW(screen.cur.row - 1).is_longer ()) { linep = &ROW(screen.cur.row - 1); - tp = line->t + ncol - 1; - rp = line->r + ncol - 1; + tp = linep->t + ncol - 1; + rp = linep->r + ncol - 1; } else continue; @@ -1035,7 +1049,7 @@ * XTERM_SEQ: CTRL-H */ void -rxvt_term::scr_backspace () NOTHROW +rxvt_term::scr_backspace () noexcept { if (screen.cur.col == 0) { @@ -1062,7 +1076,7 @@ * XTERM_SEQ: CTRL-I */ void -rxvt_term::scr_tab (int count, bool ht) NOTHROW +rxvt_term::scr_tab (int count, bool ht) noexcept { int i, x; @@ -1139,7 +1153,7 @@ */ #if !ENABLE_MINIMAL void ecb_cold -rxvt_term::scr_backindex () NOTHROW +rxvt_term::scr_backindex () noexcept { if (screen.cur.col > 0) scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); @@ -1156,7 +1170,7 @@ */ #if !ENABLE_MINIMAL void ecb_cold -rxvt_term::scr_forwardindex () NOTHROW +rxvt_term::scr_forwardindex () noexcept { if (screen.cur.col < ncol - 1) scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); @@ -1179,7 +1193,7 @@ * Goto Row/Column */ void -rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW +rxvt_term::scr_gotorc (int row, int col, int relative) noexcept { want_refresh = 1; ZERO_SCROLLBACK (); @@ -1228,22 +1242,18 @@ * direction should be UP or DN */ void -rxvt_term::scr_index (enum page_dirn direction) NOTHROW +rxvt_term::scr_index (enum page_dirn direction) noexcept { - int dirn; - want_refresh = 1; ZERO_SCROLLBACK (); - dirn = ((direction == UP) ? 1 : -1); - screen.flags &= ~Screen_WrapNext; if ((screen.cur.row == screen.bscroll && direction == UP) || (screen.cur.row == screen.tscroll && direction == DN)) - scr_scroll_text (screen.tscroll, screen.bscroll, dirn); + scr_scroll_text (screen.tscroll, screen.bscroll, direction); else - screen.cur.row += dirn; + screen.cur.row += direction; clamp_it (screen.cur.row, 0, nrow - 1); selection_check (0); @@ -1258,7 +1268,7 @@ * extension: clear to right unless wrapped: ESC [ 3 K */ void -rxvt_term::scr_erase_line (int mode) NOTHROW +rxvt_term::scr_erase_line (int mode) noexcept { unsigned int col, num; @@ -1322,7 +1332,7 @@ * XTERM_SEQ: Clear whole screen : ESC [ 2 J */ void -rxvt_term::scr_erase_screen (int mode) NOTHROW +rxvt_term::scr_erase_screen (int mode) noexcept { int num; int32_t row; @@ -1402,7 +1412,7 @@ #if !ENABLE_MINIMAL void -rxvt_term::scr_erase_savelines () NOTHROW +rxvt_term::scr_erase_savelines () noexcept { want_refresh = 1; ZERO_SCROLLBACK (); @@ -1417,7 +1427,7 @@ * XTERM_SEQ: Screen Alignment Test: ESC # 8 */ void ecb_cold -rxvt_term::scr_E () NOTHROW +rxvt_term::scr_E () noexcept { rend_t fs; @@ -1452,7 +1462,7 @@ * Insert/Delete lines */ void -rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW +rxvt_term::scr_insdel_lines (int count, int insdel) noexcept { int end; @@ -1482,7 +1492,7 @@ * Insert/Delete characters from the current position */ void -rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW +rxvt_term::scr_insdel_chars (int count, int insdel) noexcept { want_refresh = 1; ZERO_SCROLLBACK (); @@ -1591,7 +1601,7 @@ * XTERM_SEQ: Set region - inclusive: ESC [ ; r */ void ecb_cold -rxvt_term::scr_scroll_region (int top, int bot) NOTHROW +rxvt_term::scr_scroll_region (int top, int bot) noexcept { max_it (top, 0); min_it (bot, nrow - 1); @@ -1611,7 +1621,7 @@ * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l */ void ecb_cold -rxvt_term::scr_cursor_visible (int mode) NOTHROW +rxvt_term::scr_cursor_visible (int mode) noexcept { want_refresh = 1; @@ -1628,7 +1638,7 @@ * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l */ void ecb_cold -rxvt_term::scr_autowrap (int mode) NOTHROW +rxvt_term::scr_autowrap (int mode) noexcept { if (mode) screen.flags |= Screen_Autowrap; @@ -1647,7 +1657,7 @@ * XTERM_SEQ: Set Relative: ESC [ ? 6 l */ void ecb_cold -rxvt_term::scr_relative_origin (int mode) NOTHROW +rxvt_term::scr_relative_origin (int mode) noexcept { if (mode) screen.flags |= Screen_Relative; @@ -1664,7 +1674,7 @@ * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l */ void ecb_cold -rxvt_term::scr_insert_mode (int mode) NOTHROW +rxvt_term::scr_insert_mode (int mode) noexcept { if (mode) screen.flags |= Screen_Insert; @@ -1680,7 +1690,7 @@ * XTERM_SEQ: Clear all tabs : ESC [ 3 g */ void ecb_cold -rxvt_term::scr_set_tab (int mode) NOTHROW +rxvt_term::scr_set_tab (int mode) noexcept { if (mode < 0) memset (tabs, 0, ncol); @@ -1695,7 +1705,7 @@ * XTERM_SEQ: Normal video : ESC [ ? 5 l */ void -rxvt_term::scr_rvideo_mode (bool on) NOTHROW +rxvt_term::scr_rvideo_mode (bool on) noexcept { rvideo_mode = on; @@ -1707,8 +1717,16 @@ { rvideo_state = on; +#if OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + ::swap (pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]); + ::swap (pix_colors_unfocused[Color_fg], pix_colors_unfocused[Color_bg]); + } + else +#endif ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG if (bg_img == 0) #endif XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); @@ -1729,7 +1747,7 @@ * XTERM_SEQ: Report position: ESC [ 6 n */ void ecb_cold -rxvt_term::scr_report_position () NOTHROW +rxvt_term::scr_report_position () noexcept { tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); } @@ -1742,7 +1760,7 @@ * Set font style */ void ecb_cold -rxvt_term::set_font_style () NOTHROW +rxvt_term::set_font_style () noexcept { #if 0 switch (charsets [screen.charset]) @@ -1774,7 +1792,7 @@ * XTERM_SEQ: Invoke G3 character set: ESC O */ void ecb_cold -rxvt_term::scr_charset_choose (int set) NOTHROW +rxvt_term::scr_charset_choose (int set) noexcept { screen.charset = set; set_font_style (); @@ -1790,7 +1808,7 @@ * See set_font_style for possible values for */ void -rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW +rxvt_term::scr_charset_set (int set, unsigned int ch) noexcept { charsets[set] = (unsigned char)ch; set_font_style (); @@ -1805,7 +1823,7 @@ * refresh matching text. */ bool ecb_cold -rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW +rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) noexcept { bool found = false; @@ -1834,7 +1852,7 @@ }; void ecb_hot -rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW +rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) noexcept { int i; row_col_t rc[RC_COUNT]; @@ -1878,7 +1896,7 @@ * Refresh the entire screen */ void -rxvt_term::scr_touch (bool refresh) NOTHROW +rxvt_term::scr_touch (bool refresh) noexcept { scr_expose (0, 0, vt_width, vt_height, refresh); } @@ -1889,9 +1907,10 @@ * the top of the screen */ void -rxvt_term::scr_move_to (int y, int len) NOTHROW +rxvt_term::scr_move_to (int y, int len) noexcept { - scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); + // lerp (y, 0, len, top_row, nrow - 1) + scr_changeview (top_row + (nrow - 1 - top_row) * y / len); } /* ------------------------------------------------------------------------- */ @@ -1900,17 +1919,13 @@ * direction should be UP or DN */ bool -rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW +rxvt_term::scr_page (int nlines) noexcept { - int new_view_start = - direction == UP ? view_start - nlines - : view_start + nlines; - - return scr_changeview (new_view_start); + return scr_changeview (view_start - nlines); } bool -rxvt_term::scr_changeview (int new_view_start) NOTHROW +rxvt_term::scr_changeview (int new_view_start) noexcept { clamp_it (new_view_start, top_row, 0); @@ -1938,7 +1953,7 @@ /* ------------------------------------------------------------------------- */ void -rxvt_term::scr_bell () NOTHROW +rxvt_term::scr_bell () noexcept { #ifndef NO_BELL @@ -1970,7 +1985,7 @@ /* ------------------------------------------------------------------------- */ void ecb_cold -rxvt_term::scr_printscreen (int fullhist) NOTHROW +rxvt_term::scr_printscreen (int fullhist) noexcept { #ifdef PRINTPIPE int nrows, row_start; @@ -2029,17 +2044,16 @@ * screen.text/screen.rend contain what the screen will change to. */ void ecb_hot -rxvt_term::scr_refresh () NOTHROW +rxvt_term::scr_refresh () noexcept { int16_t col, row, /* column/row we're processing */ ocrow; /* old cursor row */ int i; /* tmp */ -#ifndef NO_CURSORCOLOR - rend_t cc1; /* store colours at cursor position (s) */ -#endif - rend_t *crp; // cursor rendition pointer rend_t ccol1, /* Cursor colour */ ccol2; /* Cursor colour2 */ + rend_t cur_rend; + int cur_col; + int cursorwidth; want_refresh = 0; /* screen is current */ @@ -2053,7 +2067,7 @@ unsigned int old_screen_flags = screen.flags; bool have_bg = 0; -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG have_bg = bg_img != 0; #endif ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ @@ -2074,8 +2088,6 @@ * C: set the cursor character (s) */ { - bool setoldcursor; - #ifdef CURSOR_BLINK if (hidden_cursor) showcursor = 0; @@ -2088,10 +2100,15 @@ while (col && ROW(screen.cur.row).t[col] == NOCHAR) col--; - crp = &ROW(screen.cur.row).r[col]; + cursorwidth = 1; + while (col + cursorwidth < ncol + && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR) + cursorwidth++; + + cur_rend = ROW(screen.cur.row).r[col]; + cur_col = col; #ifndef NO_CURSORCOLOR - cc1 = *crp & (RS_fgMask | RS_bgMask); if (ISSET_PIXCOLOR (Color_cursor)) ccol1 = Color_cursor; else @@ -2113,49 +2130,33 @@ ccol2 = Color_bg; #endif - if (focus) + if (focus && cursor_type == 0) { - if (option (Opt_cursorUnderline)) - *crp ^= RS_Uline; - else - { - *crp ^= RS_RVid; - *crp = SET_FGCOLOR (*crp, ccol1); - *crp = SET_BGCOLOR (*crp, ccol2); - } - } - } + rend_t rend = cur_rend; - /* make sure no outline cursor is left around */ - setoldcursor = 0; - if (ocrow != -1) - { - if (screen.cur.row - view_start != ocrow - || screen.cur.col != oldcursor.col) - { - if (ocrow < nrow - && oldcursor.col < ncol) - drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); + rend ^= RS_RVid; + rend = SET_FGCOLOR (rend, ccol1); + rend = SET_BGCOLOR (rend, ccol2); - if (focus || !showcursor) - oldcursor.row = -1; - else - setoldcursor = 1; + scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); } } - else if (!focus) - setoldcursor = 1; - if (setoldcursor) + /* make sure no outline cursor is left around */ + if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol) + drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline); + + // save the current cursor coordinates if the cursor is visible + // and either the window is unfocused or the cursor style is + // underline or vertical bar, so as to clear the outline cursor in + // the next refresh if the cursor moves or becomes invisible + if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow) { - if (screen.cur.row - view_start >= nrow) - oldcursor.row = -1; - else - { - oldcursor.row = screen.cur.row - view_start; - oldcursor.col = screen.cur.col; - } + oldcursor.row = screen.cur.row - view_start; + oldcursor.col = screen.cur.col; } + else + oldcursor.row = -1; } #ifndef NO_SLOW_LINK_SUPPORT @@ -2246,10 +2247,7 @@ for (col = 0; col < ncol; col++) { /* compare new text with old - if exactly the same then continue */ - if (stp[col] == dtp[col] /* Must match characters to skip. */ - && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ - || (stp[col] == ' ' /* space w/ no background change */ - && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) + if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col])) continue; // redraw one or more characters @@ -2431,6 +2429,10 @@ if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) { + if (showcursor && focus && row == screen.cur.row + && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth)) + XSetForeground (dpy, gc, pix_colors[ccol1]); + else #if ENABLE_FRILLS if (ISSET_PIXCOLOR (Color_underline)) XSetForeground (dpy, gc, pix_colors[Color_underline]); @@ -2452,37 +2454,31 @@ { if (focus) { - if (option (Opt_cursorUnderline)) - *crp ^= RS_Uline; - else - { - *crp ^= RS_RVid; -#ifndef NO_CURSORCOLOR - *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; -#endif + if (cursor_type == 0) + scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); + else if (oldcursor.row >= 0) + { + XSetForeground (dpy, gc, pix_colors[ccol1]); + if (cursor_type == 1) + XFillRectangle (dpy, vt, gc, + Col2Pixel (cur_col), + Row2Pixel (oldcursor.row + 1) - 2, + Width2Pixel (1), + 2); + else + XFillRectangle (dpy, vt, gc, + Col2Pixel (cur_col), + Row2Pixel (oldcursor.row), + 2, + Height2Pixel (1)); } } else if (oldcursor.row >= 0) { - int cursorwidth = 1; - int col = oldcursor.col; - - while (col && ROW(screen.cur.row).t[col] == NOCHAR) - col--; - - while (col + cursorwidth < ncol - && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) - cursorwidth++; - -#ifndef NO_CURSORCOLOR - if (ISSET_PIXCOLOR (Color_cursor)) - XSetForeground (dpy, gc, pix_colors[Color_cursor]); - else -#endif - XSetForeground (dpy, gc, pix_colors[ccol1]); + XSetForeground (dpy, gc, pix_colors[ccol1]); XDrawRectangle (dpy, vt, gc, - Col2Pixel (col), + Col2Pixel (cur_col), Row2Pixel (oldcursor.row), (unsigned int) (Width2Pixel (cursorwidth) - 1), (unsigned int) (Height2Pixel (1) - 1)); @@ -2505,7 +2501,7 @@ } void ecb_cold -rxvt_term::scr_remap_chars (line_t &l) NOTHROW +rxvt_term::scr_remap_chars (line_t &l) noexcept { if (!l.valid ()) return; @@ -2517,7 +2513,7 @@ } void ecb_cold -rxvt_term::scr_remap_chars () NOTHROW +rxvt_term::scr_remap_chars () noexcept { for (int i = total_rows; i--; ) scr_remap_chars (row_buf [i]); @@ -2530,11 +2526,11 @@ } void ecb_cold -rxvt_term::scr_recolour (bool refresh) NOTHROW +rxvt_term::scr_recolor (bool refresh) noexcept { bool transparent = false; -#ifdef HAVE_BG_PIXMAP +#ifdef HAVE_IMG if (bg_img != 0) { # if ENABLE_TRANSPARENCY @@ -2561,12 +2557,12 @@ XClearWindow (dpy, parent); - if (scrollBar.win) + if (scrollBar.state && scrollBar.win) { if (transparent) XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); else - XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); + XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); } @@ -2581,7 +2577,7 @@ /* ------------------------------------------------------------------------- */ void -rxvt_term::scr_clear (bool really) NOTHROW +rxvt_term::scr_clear (bool really) noexcept { if (!mapped) return; @@ -2594,7 +2590,7 @@ } void -rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW +rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) noexcept { int view_end = view_start + nrow; int row, col; @@ -2616,7 +2612,7 @@ } void -rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW +rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) noexcept { int view_end = view_start + nrow; int row, col; @@ -2643,7 +2639,7 @@ /* ------------------------------------------------------------------------- */ void ecb_hot -rxvt_term::scr_reverse_selection () NOTHROW +rxvt_term::scr_reverse_selection () noexcept { if (selection.op && current_screen == selection.screen @@ -2669,7 +2665,7 @@ */ #if 0 void -rxvt_term::scr_dump (int fd) NOTHROW +rxvt_term::scr_dump (int fd) noexcept { // if this method is needed, it can be implemented by factoring the // relevant code in scr_printscreen @@ -2680,7 +2676,7 @@ * CHARACTER SELECTION * * ------------------------------------------------------------------------- */ void -rxvt_term::selection_check (int check_more) NOTHROW +rxvt_term::selection_check (int check_more) noexcept { if (!selection.op) return; @@ -2695,29 +2691,47 @@ CLEAR_ALL_SELECTION (); } +void +rxvt_term::selection_changed () noexcept +{ + line_t &r1 = ROW (selection.beg.row); + while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR) + ++selection.beg.col; + + line_t &r2 = ROW (selection.end.row); + while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR) + ++selection.end.col; + + want_refresh = 1; +} + /* ------------------------------------------------------------------------- */ /* * Paste a selection direct to the command fd */ void -rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW +rxvt_term::tt_paste (char *data, unsigned int len) noexcept { /* convert normal newline chars into common keyboard Return key sequence */ for (unsigned int i = 0; i < len; i++) if (data[i] == C0_LF) data[i] = C0_CR; - if (priv_modes & PrivMode_BracketPaste) + #if ENABLE_FRILLS + if ((priv_modes & PrivMode_BracketPaste) && !option (Opt_disablePasteBrackets)) tt_printf ("\x1b[200~"); + #endif tt_write (data, len); - if (priv_modes & PrivMode_BracketPaste) + #if ENABLE_FRILLS + if ((priv_modes & PrivMode_BracketPaste) && !option (Opt_disablePasteBrackets)) tt_printf ("\x1b[201~"); + #endif } void -rxvt_term::paste (char *data, unsigned int len) NOTHROW +rxvt_term::paste (char *data, unsigned int len) noexcept { if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END))) return; @@ -2733,7 +2747,7 @@ * EXT: button 2 release */ void -rxvt_term::selection_request (Time tm, int selnum) NOTHROW +rxvt_term::selection_request (Time tm, int selnum) noexcept { if (!selection_req) { @@ -2748,7 +2762,7 @@ * EXT: SelectionClear */ void -rxvt_term::selection_clear (bool clipboard) NOTHROW +rxvt_term::selection_clear (bool clipboard) noexcept { if (!clipboard) { @@ -2843,7 +2857,7 @@ #if ENABLE_COMBINING else if (IS_COMPOSE (*t)) { - int len = rxvt_composite.expand (*t, 0); + int len = rxvt_composite.expand (*t); extra -= (len - 1); @@ -2900,7 +2914,7 @@ } bool -rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW +rxvt_term::selection_grab (Time tm, bool clipboard) noexcept { Atom sel; @@ -2944,7 +2958,7 @@ * EXT: button 1 press */ void ecb_cold -rxvt_term::selection_click (int clicks, int x, int y) NOTHROW +rxvt_term::selection_click (int clicks, int x, int y) noexcept { clicks = ((clicks - 1) % 3) + 1; selection.clicks = clicks; /* save clicks so extend will work */ @@ -2973,7 +2987,7 @@ * Mark a selection at the specified col/row */ void ecb_cold -rxvt_term::selection_start_colrow (int col, int row) NOTHROW +rxvt_term::selection_start_colrow (int col, int row) noexcept { want_refresh = 1; @@ -3005,12 +3019,12 @@ */ /* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ -#define DELIMIT_TEXT(x) \ +#define DELIMIT_TEXT(x) \ (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) #define DELIMIT_REND(x) 1 void ecb_cold -rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW +rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) noexcept { int col, row, dirnadd, tcol, trow, w1, w2; row_col_t bound; @@ -3094,7 +3108,7 @@ * flag == 2 ==> button 3 motion */ void ecb_cold -rxvt_term::selection_extend (int x, int y, int flag) NOTHROW +rxvt_term::selection_extend (int x, int y, int flag) noexcept { int col = clamp (Pixel2Col (x), 0, ncol); int row = clamp (Pixel2Row (y), 0, nrow - 1); @@ -3130,15 +3144,13 @@ * Extend the selection to the specified col/row */ void ecb_cold -rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW +rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) noexcept { row_col_t pos; enum { LEFT, RIGHT } closeto = RIGHT; - want_refresh = 1; - switch (selection.op) { case SELECTION_INIT: @@ -3327,11 +3339,13 @@ if (selection.rect && selection.beg.col > selection.end.col) ::swap (selection.beg.col, selection.end.col); #endif + + selection_changed (); } #if !ENABLE_MINIMAL void ecb_cold -rxvt_term::selection_remove_trailing_spaces () NOTHROW +rxvt_term::selection_remove_trailing_spaces () noexcept { int32_t end_col, end_row; text_t *stp; @@ -3379,7 +3393,7 @@ * EXT: button 3 double click */ void ecb_cold -rxvt_term::selection_rotate (int x, int y) NOTHROW +rxvt_term::selection_rotate (int x, int y) noexcept { selection.clicks = selection.clicks % 3 + 1; selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); @@ -3391,7 +3405,7 @@ * EXT: SelectionRequest */ void ecb_cold -rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW +rxvt_term::selection_send (const XSelectionRequestEvent &rq) noexcept { Atom property = rq.property == None ? rq.target : rq.property; XSelectionEvent ev; @@ -3493,7 +3507,7 @@ } else { - cl = L""; + cl = (wchar_t *)L""; selectlen = 0; } @@ -3535,7 +3549,7 @@ /* ------------------------------------------------------------------------- */ #if USE_XIM void ecb_cold -rxvt_term::im_set_position (XPoint &pos) NOTHROW +rxvt_term::im_set_position (XPoint &pos) noexcept { XWindowAttributes xwa; @@ -3548,7 +3562,7 @@ #if ENABLE_OVERLAY void -rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW +rxvt_term::scr_overlay_new (int x, int y, int w, int h) noexcept { if (nrow < 1 || ncol < 1) return; @@ -3603,7 +3617,7 @@ } void -rxvt_term::scr_overlay_off () NOTHROW +rxvt_term::scr_overlay_off () noexcept { if (!ov.text) return; @@ -3621,7 +3635,7 @@ } void -rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW +rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) noexcept { if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2) return; @@ -3633,14 +3647,14 @@ } void -rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW +rxvt_term::scr_overlay_set (int x, int y, const char *s) noexcept { while (*s) scr_overlay_set (x++, y, *s++); } void -rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW +rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) noexcept { while (*s) { @@ -3656,7 +3670,7 @@ } void -rxvt_term::scr_swap_overlay () NOTHROW +rxvt_term::scr_swap_overlay () noexcept { if (!ov.text) return;