ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/screen.C
(Generate patch)

Comparing rxvt-unicode/src/screen.C (file contents):
Revision 1.433 by sf-exg, Thu Jan 31 08:07:14 2013 UTC vs.
Revision 1.460 by sf-exg, Thu May 13 19:40:20 2021 UTC

2 * File: screen.C 2 * File: screen.C
3 *---------------------------------------------------------------------------* 3 *---------------------------------------------------------------------------*
4 * 4 *
5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com> 5 * Copyright (c) 1997-2001 Geoff Wing <gcw@pobox.com>
6 * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de> 6 * Copyright (c) 2003-2007 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version. 12 * (at your option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
94 * SCREEN `COMMON' ROUTINES * 95 * SCREEN `COMMON' ROUTINES *
95 * ------------------------------------------------------------------------- */ 96 * ------------------------------------------------------------------------- */
96 97
97/* Fill part/all of a line with blanks. */ 98/* Fill part/all of a line with blanks. */
98void 99void
99rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const NOTHROW 100rxvt_term::scr_blank_line (line_t &l, unsigned int col, unsigned int width, rend_t efs) const noexcept
100{ 101{
101 if (!l.valid ()) 102 if (!l.valid ())
102 { 103 {
103 l.alloc (); 104 l.alloc ();
104 col = 0; 105 col = 0;
121} 122}
122 123
123/* ------------------------------------------------------------------------- */ 124/* ------------------------------------------------------------------------- */
124/* Fill a full line with blanks - make sure it is allocated first */ 125/* Fill a full line with blanks - make sure it is allocated first */
125void 126void
126rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const NOTHROW 127rxvt_term::scr_blank_screen_mem (line_t &l, rend_t efs) const noexcept
127{ 128{
128 scr_blank_line (l, 0, ncol, efs); 129 scr_blank_line (l, 0, ncol, efs);
129 130
130 l.l = 0; 131 l.l = 0;
131 l.f = 0; 132 l.f = 0;
132} 133}
133 134
134// nuke a single wide character at the given column 135// nuke a single wide character at the given column
135void 136void
136rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW 137rxvt_term::scr_kill_char (line_t &l, int col) const noexcept
137{ 138{
138 // find begin 139 // find begin
139 while (col > 0 && l.t[col] == NOCHAR) 140 while (col > 0 && l.t[col] == NOCHAR)
140 col--; 141 col--;
141 142
165/* ------------------------------------------------------------------------- * 166/* ------------------------------------------------------------------------- *
166 * SCREEN INITIALISATION * 167 * SCREEN INITIALISATION *
167 * ------------------------------------------------------------------------- */ 168 * ------------------------------------------------------------------------- */
168 169
169void 170void
170rxvt_term::scr_alloc () NOTHROW 171rxvt_term::scr_alloc () noexcept
171{ 172{
172 int tsize = sizeof (text_t) * ncol; 173 int tsize = sizeof (text_t) * ncol;
173 int rsize = sizeof (rend_t) * ncol; 174 int rsize = sizeof (rend_t) * ncol;
174 175
175 // we assume that rend_t size is a sufficient alignment 176 // we assume that rend_t size is a sufficient alignment
254 255
255 scr_alloc (); 256 scr_alloc ();
256 257
257 if (!prev_row_buf) 258 if (!prev_row_buf)
258 { 259 {
259 /*
260 * first time called (or after scr_release) so just malloc everything: don't rely on realloc
261 */
262 top_row = 0; 260 top_row = 0;
263 term_start = 0; 261 term_start = 0;
264 262
265 memset (charsets, 'B', sizeof (charsets)); 263 memset (charsets, 'B', sizeof (charsets));
266 rstyle = DEFAULT_RSTYLE; 264 rstyle = DEFAULT_RSTYLE;
291 { 289 {
292 /* 290 /*
293 * add or delete rows as appropriate 291 * add or delete rows as appropriate
294 */ 292 */
295 293
294 int common_col = min (prev_ncol, ncol);
295
296 for (int row = min (nrow, prev_nrow); row--; ) 296 for (int row = min (nrow, prev_nrow); row--; )
297 { 297 {
298 copy_line (drawn_buf [row], prev_drawn_buf [row]); 298 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
299 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col);
300 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col);
301
299 copy_line (swap_buf [row], prev_swap_buf [row]); 302 copy_line (swap_buf [row], prev_swap_buf [row]);
300 } 303 }
301 304
302 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 305 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
303 int pend = MOD (term_start + top_row , prev_total_rows); 306 int pend = MOD (term_start + top_row , prev_total_rows);
438 441
439 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 442 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
440} 443}
441 444
442void ecb_cold 445void ecb_cold
443rxvt_term::scr_release () NOTHROW 446rxvt_term::scr_release () noexcept
444{ 447{
445 chunk_free (chunk, chunk_size); 448 chunk_free (chunk, chunk_size);
446 chunk = 0; 449 chunk = 0;
447 row_buf = 0; 450 row_buf = 0;
448 451
467 scr_clear (true); 470 scr_clear (true);
468 scr_refresh (); 471 scr_refresh ();
469} 472}
470 473
471void ecb_cold 474void ecb_cold
472rxvt_term::scr_soft_reset () NOTHROW 475rxvt_term::scr_soft_reset () noexcept
473{ 476{
474 /* only affects modes, nothing drastic such as clearing the screen */ 477 /* only affects modes, nothing drastic such as clearing the screen */
475#if ENABLE_OVERLAY 478#if ENABLE_OVERLAY
476 scr_overlay_off (); 479 scr_overlay_off ();
477#endif 480#endif
491 * Save and Restore cursor 494 * Save and Restore cursor
492 * XTERM_SEQ: Save cursor : ESC 7 495 * XTERM_SEQ: Save cursor : ESC 7
493 * XTERM_SEQ: Restore cursor: ESC 8 496 * XTERM_SEQ: Restore cursor: ESC 8
494 */ 497 */
495void 498void
496rxvt_term::scr_cursor (cursor_mode mode) NOTHROW 499rxvt_term::scr_cursor (cursor_mode mode) noexcept
497{ 500{
498 screen_t *s; 501 screen_t *s;
499 502
500#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) 503#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
501 if (current_screen == SECONDARY) 504 if (current_screen == SECONDARY)
532 assert (s->cur.row >= 0); 535 assert (s->cur.row >= 0);
533 assert (s->cur.col >= 0); 536 assert (s->cur.col >= 0);
534} 537}
535 538
536void 539void
537rxvt_term::scr_swap_screen () NOTHROW 540rxvt_term::scr_swap_screen () noexcept
538{ 541{
539 if (!option (Opt_secondaryScreen)) 542 if (!option (Opt_secondaryScreen))
540 return; 543 return;
541 544
542 for (int i = prev_nrow; i--; ) 545 for (int i = prev_nrow; i--; )
590 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 593 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
591} 594}
592 595
593// clear WrapNext indicator, solidifying position on next line 596// clear WrapNext indicator, solidifying position on next line
594void 597void
595rxvt_term::scr_do_wrap () NOTHROW 598rxvt_term::scr_do_wrap () noexcept
596{ 599{
597 if (!(screen.flags & Screen_WrapNext)) 600 if (!(screen.flags & Screen_WrapNext))
598 return; 601 return;
599 602
600 screen.flags &= ~Screen_WrapNext; 603 screen.flags &= ~Screen_WrapNext;
610/* ------------------------------------------------------------------------- */ 613/* ------------------------------------------------------------------------- */
611/* 614/*
612 * Change the colour for following text 615 * Change the colour for following text
613 */ 616 */
614void 617void
615rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW 618rxvt_term::scr_color (unsigned int color, int fgbg) noexcept
616{ 619{
617 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 620 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR24))
618 color = fgbg; 621 color = fgbg;
619 622
620 if (fgbg == Color_fg) 623 if (fgbg == Color_fg)
621 rstyle = SET_FGCOLOR (rstyle, color); 624 rstyle = SET_FGCOLOR (rstyle, color);
622 else 625 else
626/* ------------------------------------------------------------------------- */ 629/* ------------------------------------------------------------------------- */
627/* 630/*
628 * Change the rendition style for following text 631 * Change the rendition style for following text
629 */ 632 */
630void 633void
631rxvt_term::scr_rendition (int set, int style) NOTHROW 634rxvt_term::scr_rendition (int set, int style) noexcept
632{ 635{
633 if (set) 636 if (set)
634 rstyle |= style; 637 rstyle |= style;
635 else if (style == ~RS_None) 638 else if (style == ~RS_None)
636 rstyle = DEFAULT_RSTYLE; 639 rstyle = DEFAULT_RSTYLE;
643 * Scroll text between <row1> and <row2> inclusive, by <count> lines 646 * Scroll text between <row1> and <row2> inclusive, by <count> lines
644 * count positive ==> scroll up 647 * count positive ==> scroll up
645 * count negative ==> scroll down 648 * count negative ==> scroll down
646 */ 649 */
647int ecb_hot 650int ecb_hot
648rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW 651rxvt_term::scr_scroll_text (int row1, int row2, int count) noexcept
649{ 652{
650 if (count == 0 || (row1 > row2)) 653 if (count == 0 || (row1 > row2))
651 return 0; 654 return 0;
652 655
653 want_refresh = 1; 656 want_refresh = 1;
713 716
714 // finally move the view window, if desired 717 // finally move the view window, if desired
715 if (option (Opt_scrollWithBuffer) 718 if (option (Opt_scrollWithBuffer)
716 && view_start != 0 719 && view_start != 0
717 && view_start != -saveLines) 720 && view_start != -saveLines)
718 scr_page (UP, count); 721 scr_page (count);
719 722
720 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 723 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
721 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); 724 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END));
722 } 725 }
723 else 726 else
787/* ------------------------------------------------------------------------- */ 790/* ------------------------------------------------------------------------- */
788/* 791/*
789 * Add text given in <str> of length <len> to screen struct 792 * Add text given in <str> of length <len> to screen struct
790 */ 793 */
791void ecb_hot 794void ecb_hot
792rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW 795rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) noexcept
793{ 796{
794 if (len <= 0) /* sanity */ 797 if (len <= 0) /* sanity */
795 return; 798 return;
796 799
797 bool checksel; 800 bool checksel;
1009 } 1012 }
1010 else if (screen.cur.row > 0 1013 else if (screen.cur.row > 0
1011 && ROW(screen.cur.row - 1).is_longer ()) 1014 && ROW(screen.cur.row - 1).is_longer ())
1012 { 1015 {
1013 linep = &ROW(screen.cur.row - 1); 1016 linep = &ROW(screen.cur.row - 1);
1014 tp = line->t + ncol - 1; 1017 tp = linep->t + ncol - 1;
1015 rp = line->r + ncol - 1; 1018 rp = linep->r + ncol - 1;
1016 } 1019 }
1017 else 1020 else
1018 continue; 1021 continue;
1019 1022
1020 linep->touch (); 1023 linep->touch ();
1043/* 1046/*
1044 * Process Backspace. Move back the cursor back a position, wrap if have to 1047 * Process Backspace. Move back the cursor back a position, wrap if have to
1045 * XTERM_SEQ: CTRL-H 1048 * XTERM_SEQ: CTRL-H
1046 */ 1049 */
1047void 1050void
1048rxvt_term::scr_backspace () NOTHROW 1051rxvt_term::scr_backspace () noexcept
1049{ 1052{
1050 if (screen.cur.col == 0) 1053 if (screen.cur.col == 0)
1051 { 1054 {
1052 if (screen.cur.row > 0) 1055 if (screen.cur.row > 0)
1053 { 1056 {
1070 * Process Horizontal Tab 1073 * Process Horizontal Tab
1071 * count: +ve = forward; -ve = backwards 1074 * count: +ve = forward; -ve = backwards
1072 * XTERM_SEQ: CTRL-I 1075 * XTERM_SEQ: CTRL-I
1073 */ 1076 */
1074void 1077void
1075rxvt_term::scr_tab (int count, bool ht) NOTHROW 1078rxvt_term::scr_tab (int count, bool ht) noexcept
1076{ 1079{
1077 int i, x; 1080 int i, x;
1078 1081
1079 want_refresh = 1; 1082 want_refresh = 1;
1080 i = x = screen.cur.col; 1083 i = x = screen.cur.col;
1147 * Move cursor left in row. If we're at the left boundary, shift everything 1150 * Move cursor left in row. If we're at the left boundary, shift everything
1148 * in that row right. Clear left column. 1151 * in that row right. Clear left column.
1149 */ 1152 */
1150#if !ENABLE_MINIMAL 1153#if !ENABLE_MINIMAL
1151void ecb_cold 1154void ecb_cold
1152rxvt_term::scr_backindex () NOTHROW 1155rxvt_term::scr_backindex () noexcept
1153{ 1156{
1154 if (screen.cur.col > 0) 1157 if (screen.cur.col > 0)
1155 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1158 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1156 else 1159 else
1157 scr_insdel_chars (1, INSERT); 1160 scr_insdel_chars (1, INSERT);
1164 * Move cursor right in row. If we're at the right boundary, shift everything 1167 * Move cursor right in row. If we're at the right boundary, shift everything
1165 * in that row left. Clear right column. 1168 * in that row left. Clear right column.
1166 */ 1169 */
1167#if !ENABLE_MINIMAL 1170#if !ENABLE_MINIMAL
1168void ecb_cold 1171void ecb_cold
1169rxvt_term::scr_forwardindex () NOTHROW 1172rxvt_term::scr_forwardindex () noexcept
1170{ 1173{
1171 if (screen.cur.col < ncol - 1) 1174 if (screen.cur.col < ncol - 1)
1172 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1175 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1173 else 1176 else
1174 { 1177 {
1187/* ------------------------------------------------------------------------- */ 1190/* ------------------------------------------------------------------------- */
1188/* 1191/*
1189 * Goto Row/Column 1192 * Goto Row/Column
1190 */ 1193 */
1191void 1194void
1192rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW 1195rxvt_term::scr_gotorc (int row, int col, int relative) noexcept
1193{ 1196{
1194 want_refresh = 1; 1197 want_refresh = 1;
1195 ZERO_SCROLLBACK (); 1198 ZERO_SCROLLBACK ();
1196 1199
1197 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1200 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1236/* ------------------------------------------------------------------------- */ 1239/* ------------------------------------------------------------------------- */
1237/* 1240/*
1238 * direction should be UP or DN 1241 * direction should be UP or DN
1239 */ 1242 */
1240void 1243void
1241rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1244rxvt_term::scr_index (enum page_dirn direction) noexcept
1242{ 1245{
1243 int dirn;
1244
1245 want_refresh = 1; 1246 want_refresh = 1;
1246 ZERO_SCROLLBACK (); 1247 ZERO_SCROLLBACK ();
1247 1248
1248 dirn = ((direction == UP) ? 1 : -1);
1249
1250 screen.flags &= ~Screen_WrapNext; 1249 screen.flags &= ~Screen_WrapNext;
1251 1250
1252 if ((screen.cur.row == screen.bscroll && direction == UP) 1251 if ((screen.cur.row == screen.bscroll && direction == UP)
1253 || (screen.cur.row == screen.tscroll && direction == DN)) 1252 || (screen.cur.row == screen.tscroll && direction == DN))
1254 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1253 scr_scroll_text (screen.tscroll, screen.bscroll, direction);
1255 else 1254 else
1256 screen.cur.row += dirn; 1255 screen.cur.row += direction;
1257 1256
1258 clamp_it (screen.cur.row, 0, nrow - 1); 1257 clamp_it (screen.cur.row, 0, nrow - 1);
1259 selection_check (0); 1258 selection_check (0);
1260} 1259}
1261 1260
1266 * XTERM_SEQ: Clear line to left : ESC [ 1 K 1265 * XTERM_SEQ: Clear line to left : ESC [ 1 K
1267 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1266 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1268 * extension: clear to right unless wrapped: ESC [ 3 K 1267 * extension: clear to right unless wrapped: ESC [ 3 K
1269 */ 1268 */
1270void 1269void
1271rxvt_term::scr_erase_line (int mode) NOTHROW 1270rxvt_term::scr_erase_line (int mode) noexcept
1272{ 1271{
1273 unsigned int col, num; 1272 unsigned int col, num;
1274 1273
1275 want_refresh = 1; 1274 want_refresh = 1;
1276 ZERO_SCROLLBACK (); 1275 ZERO_SCROLLBACK ();
1330 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1329 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1331 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1330 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1332 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1331 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1333 */ 1332 */
1334void 1333void
1335rxvt_term::scr_erase_screen (int mode) NOTHROW 1334rxvt_term::scr_erase_screen (int mode) noexcept
1336{ 1335{
1337 int num; 1336 int num;
1338 int32_t row; 1337 int32_t row;
1339 rend_t ren; 1338 rend_t ren;
1340 XGCValues gcvalue; 1339 XGCValues gcvalue;
1410 } 1409 }
1411} 1410}
1412 1411
1413#if !ENABLE_MINIMAL 1412#if !ENABLE_MINIMAL
1414void 1413void
1415rxvt_term::scr_erase_savelines () NOTHROW 1414rxvt_term::scr_erase_savelines () noexcept
1416{ 1415{
1417 want_refresh = 1; 1416 want_refresh = 1;
1418 ZERO_SCROLLBACK (); 1417 ZERO_SCROLLBACK ();
1419 1418
1420 top_row = 0; 1419 top_row = 0;
1425/* 1424/*
1426 * Fill the screen with `E's 1425 * Fill the screen with `E's
1427 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1426 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1428 */ 1427 */
1429void ecb_cold 1428void ecb_cold
1430rxvt_term::scr_E () NOTHROW 1429rxvt_term::scr_E () noexcept
1431{ 1430{
1432 rend_t fs; 1431 rend_t fs;
1433 1432
1434 want_refresh = 1; 1433 want_refresh = 1;
1435 ZERO_SCROLLBACK (); 1434 ZERO_SCROLLBACK ();
1460/* ------------------------------------------------------------------------- */ 1459/* ------------------------------------------------------------------------- */
1461/* 1460/*
1462 * Insert/Delete <count> lines 1461 * Insert/Delete <count> lines
1463 */ 1462 */
1464void 1463void
1465rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW 1464rxvt_term::scr_insdel_lines (int count, int insdel) noexcept
1466{ 1465{
1467 int end; 1466 int end;
1468 1467
1469 ZERO_SCROLLBACK (); 1468 ZERO_SCROLLBACK ();
1470 1469
1490/* ------------------------------------------------------------------------- */ 1489/* ------------------------------------------------------------------------- */
1491/* 1490/*
1492 * Insert/Delete <count> characters from the current position 1491 * Insert/Delete <count> characters from the current position
1493 */ 1492 */
1494void 1493void
1495rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1494rxvt_term::scr_insdel_chars (int count, int insdel) noexcept
1496{ 1495{
1497 want_refresh = 1; 1496 want_refresh = 1;
1498 ZERO_SCROLLBACK (); 1497 ZERO_SCROLLBACK ();
1499 1498
1500 if (count <= 0) 1499 if (count <= 0)
1599/* 1598/*
1600 * Set the scrolling region 1599 * Set the scrolling region
1601 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1600 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1602 */ 1601 */
1603void ecb_cold 1602void ecb_cold
1604rxvt_term::scr_scroll_region (int top, int bot) NOTHROW 1603rxvt_term::scr_scroll_region (int top, int bot) noexcept
1605{ 1604{
1606 max_it (top, 0); 1605 max_it (top, 0);
1607 min_it (bot, nrow - 1); 1606 min_it (bot, nrow - 1);
1608 1607
1609 if (top > bot) 1608 if (top > bot)
1619 * Make the cursor visible/invisible 1618 * Make the cursor visible/invisible
1620 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h 1619 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h
1621 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l 1620 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l
1622 */ 1621 */
1623void ecb_cold 1622void ecb_cold
1624rxvt_term::scr_cursor_visible (int mode) NOTHROW 1623rxvt_term::scr_cursor_visible (int mode) noexcept
1625{ 1624{
1626 want_refresh = 1; 1625 want_refresh = 1;
1627 1626
1628 if (mode) 1627 if (mode)
1629 screen.flags |= Screen_VisibleCursor; 1628 screen.flags |= Screen_VisibleCursor;
1636 * Set/unset automatic wrapping 1635 * Set/unset automatic wrapping
1637 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h 1636 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h
1638 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l 1637 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l
1639 */ 1638 */
1640void ecb_cold 1639void ecb_cold
1641rxvt_term::scr_autowrap (int mode) NOTHROW 1640rxvt_term::scr_autowrap (int mode) noexcept
1642{ 1641{
1643 if (mode) 1642 if (mode)
1644 screen.flags |= Screen_Autowrap; 1643 screen.flags |= Screen_Autowrap;
1645 else 1644 else
1646 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); 1645 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
1655 * and the cursor cannot be moved outside. 1654 * and the cursor cannot be moved outside.
1656 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h 1655 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h
1657 * XTERM_SEQ: Set Relative: ESC [ ? 6 l 1656 * XTERM_SEQ: Set Relative: ESC [ ? 6 l
1658 */ 1657 */
1659void ecb_cold 1658void ecb_cold
1660rxvt_term::scr_relative_origin (int mode) NOTHROW 1659rxvt_term::scr_relative_origin (int mode) noexcept
1661{ 1660{
1662 if (mode) 1661 if (mode)
1663 screen.flags |= Screen_Relative; 1662 screen.flags |= Screen_Relative;
1664 else 1663 else
1665 screen.flags &= ~Screen_Relative; 1664 screen.flags &= ~Screen_Relative;
1672 * Set insert/replace mode 1671 * Set insert/replace mode
1673 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h 1672 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h
1674 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l 1673 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l
1675 */ 1674 */
1676void ecb_cold 1675void ecb_cold
1677rxvt_term::scr_insert_mode (int mode) NOTHROW 1676rxvt_term::scr_insert_mode (int mode) noexcept
1678{ 1677{
1679 if (mode) 1678 if (mode)
1680 screen.flags |= Screen_Insert; 1679 screen.flags |= Screen_Insert;
1681 else 1680 else
1682 screen.flags &= ~Screen_Insert; 1681 screen.flags &= ~Screen_Insert;
1688 * XTERM_SEQ: Set tab at current column : ESC H 1687 * XTERM_SEQ: Set tab at current column : ESC H
1689 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g 1688 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g
1690 * XTERM_SEQ: Clear all tabs : ESC [ 3 g 1689 * XTERM_SEQ: Clear all tabs : ESC [ 3 g
1691 */ 1690 */
1692void ecb_cold 1691void ecb_cold
1693rxvt_term::scr_set_tab (int mode) NOTHROW 1692rxvt_term::scr_set_tab (int mode) noexcept
1694{ 1693{
1695 if (mode < 0) 1694 if (mode < 0)
1696 memset (tabs, 0, ncol); 1695 memset (tabs, 0, ncol);
1697 else if (screen.cur.col < ncol) 1696 else if (screen.cur.col < ncol)
1698 tabs [screen.cur.col] = !!mode; 1697 tabs [screen.cur.col] = !!mode;
1703 * Set reverse/normal video 1702 * Set reverse/normal video
1704 * XTERM_SEQ: Reverse video: ESC [ ? 5 h 1703 * XTERM_SEQ: Reverse video: ESC [ ? 5 h
1705 * XTERM_SEQ: Normal video : ESC [ ? 5 l 1704 * XTERM_SEQ: Normal video : ESC [ ? 5 l
1706 */ 1705 */
1707void 1706void
1708rxvt_term::scr_rvideo_mode (bool on) NOTHROW 1707rxvt_term::scr_rvideo_mode (bool on) noexcept
1709{ 1708{
1710 rvideo_mode = on; 1709 rvideo_mode = on;
1711 1710
1712#ifndef NO_BELL 1711#ifndef NO_BELL
1713 on ^= rvideo_bell; 1712 on ^= rvideo_bell;
1715 1714
1716 if (rvideo_state != on) 1715 if (rvideo_state != on)
1717 { 1716 {
1718 rvideo_state = on; 1717 rvideo_state = on;
1719 1718
1719#if OFF_FOCUS_FADING
1720 if (rs[Rs_fade])
1721 {
1722 ::swap (pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]);
1723 ::swap (pix_colors_unfocused[Color_fg], pix_colors_unfocused[Color_bg]);
1724 }
1725 else
1726#endif
1720 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1727 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1721#ifdef HAVE_IMG 1728#ifdef HAVE_IMG
1722 if (bg_img == 0) 1729 if (bg_img == 0)
1723#endif 1730#endif
1724 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 1731 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1737/* 1744/*
1738 * Report current cursor position 1745 * Report current cursor position
1739 * XTERM_SEQ: Report position: ESC [ 6 n 1746 * XTERM_SEQ: Report position: ESC [ 6 n
1740 */ 1747 */
1741void ecb_cold 1748void ecb_cold
1742rxvt_term::scr_report_position () NOTHROW 1749rxvt_term::scr_report_position () noexcept
1743{ 1750{
1744 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); 1751 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
1745} 1752}
1746 1753
1747/* ------------------------------------------------------------------------- * 1754/* ------------------------------------------------------------------------- *
1750 1757
1751/* 1758/*
1752 * Set font style 1759 * Set font style
1753 */ 1760 */
1754void ecb_cold 1761void ecb_cold
1755rxvt_term::set_font_style () NOTHROW 1762rxvt_term::set_font_style () noexcept
1756{ 1763{
1757#if 0 1764#if 0
1758 switch (charsets [screen.charset]) 1765 switch (charsets [screen.charset])
1759 { 1766 {
1760 case '0': /* DEC Special Character & Line Drawing Set */ 1767 case '0': /* DEC Special Character & Line Drawing Set */
1782 * XTERM_SEQ: Invoke G1 character set: CTRL-N 1789 * XTERM_SEQ: Invoke G1 character set: CTRL-N
1783 * XTERM_SEQ: Invoke G2 character set: ESC N 1790 * XTERM_SEQ: Invoke G2 character set: ESC N
1784 * XTERM_SEQ: Invoke G3 character set: ESC O 1791 * XTERM_SEQ: Invoke G3 character set: ESC O
1785 */ 1792 */
1786void ecb_cold 1793void ecb_cold
1787rxvt_term::scr_charset_choose (int set) NOTHROW 1794rxvt_term::scr_charset_choose (int set) noexcept
1788{ 1795{
1789 screen.charset = set; 1796 screen.charset = set;
1790 set_font_style (); 1797 set_font_style ();
1791} 1798}
1792 1799
1798 * XTERM_SEQ: Set G2 character set: ESC * <C> 1805 * XTERM_SEQ: Set G2 character set: ESC * <C>
1799 * XTERM_SEQ: Set G3 character set: ESC + <C> 1806 * XTERM_SEQ: Set G3 character set: ESC + <C>
1800 * See set_font_style for possible values for <C> 1807 * See set_font_style for possible values for <C>
1801 */ 1808 */
1802void 1809void
1803rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW 1810rxvt_term::scr_charset_set (int set, unsigned int ch) noexcept
1804{ 1811{
1805 charsets[set] = (unsigned char)ch; 1812 charsets[set] = (unsigned char)ch;
1806 set_font_style (); 1813 set_font_style ();
1807} 1814}
1808 1815
1813 1820
1814/* 1821/*
1815 * refresh matching text. 1822 * refresh matching text.
1816 */ 1823 */
1817bool ecb_cold 1824bool ecb_cold
1818rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW 1825rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) noexcept
1819{ 1826{
1820 bool found = false; 1827 bool found = false;
1821 1828
1822 for (int i = 0; i < nrow; i++) 1829 for (int i = 0; i < nrow; i++)
1823 { 1830 {
1842 PART_END, 1849 PART_END,
1843 RC_COUNT 1850 RC_COUNT
1844}; 1851};
1845 1852
1846void ecb_hot 1853void ecb_hot
1847rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW 1854rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) noexcept
1848{ 1855{
1849 int i; 1856 int i;
1850 row_col_t rc[RC_COUNT]; 1857 row_col_t rc[RC_COUNT];
1851 1858
1852 if (!drawn_buf) /* sanity check */ 1859 if (!drawn_buf) /* sanity check */
1886/* ------------------------------------------------------------------------- */ 1893/* ------------------------------------------------------------------------- */
1887/* 1894/*
1888 * Refresh the entire screen 1895 * Refresh the entire screen
1889 */ 1896 */
1890void 1897void
1891rxvt_term::scr_touch (bool refresh) NOTHROW 1898rxvt_term::scr_touch (bool refresh) noexcept
1892{ 1899{
1893 scr_expose (0, 0, vt_width, vt_height, refresh); 1900 scr_expose (0, 0, vt_width, vt_height, refresh);
1894} 1901}
1895 1902
1896/* ------------------------------------------------------------------------- */ 1903/* ------------------------------------------------------------------------- */
1897/* 1904/*
1898 * Move the display so that the line represented by scrollbar value Y is at 1905 * Move the display so that the line represented by scrollbar value Y is at
1899 * the top of the screen 1906 * the top of the screen
1900 */ 1907 */
1901void 1908void
1902rxvt_term::scr_move_to (int y, int len) NOTHROW 1909rxvt_term::scr_move_to (int y, int len) noexcept
1903{ 1910{
1904 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1911 // lerp (y, 0, len, top_row, nrow - 1)
1912 scr_changeview (top_row + (nrow - 1 - top_row) * y / len);
1905} 1913}
1906 1914
1907/* ------------------------------------------------------------------------- */ 1915/* ------------------------------------------------------------------------- */
1908/* 1916/*
1909 * Page the screen up/down nlines 1917 * Page the screen up/down nlines
1910 * direction should be UP or DN 1918 * direction should be UP or DN
1911 */ 1919 */
1912bool 1920bool
1913rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1921rxvt_term::scr_page (int nlines) noexcept
1914{ 1922{
1915 int new_view_start =
1916 direction == UP ? view_start - nlines
1917 : view_start + nlines;
1918
1919 return scr_changeview (new_view_start); 1923 return scr_changeview (view_start - nlines);
1920} 1924}
1921 1925
1922bool 1926bool
1923rxvt_term::scr_changeview (int new_view_start) NOTHROW 1927rxvt_term::scr_changeview (int new_view_start) noexcept
1924{ 1928{
1925 clamp_it (new_view_start, top_row, 0); 1929 clamp_it (new_view_start, top_row, 0);
1926 1930
1927 if (new_view_start == view_start) 1931 if (new_view_start == view_start)
1928 return false; 1932 return false;
1946} 1950}
1947#endif 1951#endif
1948 1952
1949/* ------------------------------------------------------------------------- */ 1953/* ------------------------------------------------------------------------- */
1950void 1954void
1951rxvt_term::scr_bell () NOTHROW 1955rxvt_term::scr_bell () noexcept
1952{ 1956{
1953#ifndef NO_BELL 1957#ifndef NO_BELL
1954 1958
1955# ifndef NO_MAPALERT 1959# ifndef NO_MAPALERT
1956# ifdef MAPALERT_OPTION 1960# ifdef MAPALERT_OPTION
1978#endif 1982#endif
1979} 1983}
1980 1984
1981/* ------------------------------------------------------------------------- */ 1985/* ------------------------------------------------------------------------- */
1982void ecb_cold 1986void ecb_cold
1983rxvt_term::scr_printscreen (int fullhist) NOTHROW 1987rxvt_term::scr_printscreen (int fullhist) noexcept
1984{ 1988{
1985#ifdef PRINTPIPE 1989#ifdef PRINTPIPE
1986 int nrows, row_start; 1990 int nrows, row_start;
1987 FILE *fd = popen_printer (); 1991 FILE *fd = popen_printer ();
1988 1992
2037 * Refresh the screen 2041 * Refresh the screen
2038 * drawn_text/drawn_rend contain the screen information before the update. 2042 * drawn_text/drawn_rend contain the screen information before the update.
2039 * screen.text/screen.rend contain what the screen will change to. 2043 * screen.text/screen.rend contain what the screen will change to.
2040 */ 2044 */
2041void ecb_hot 2045void ecb_hot
2042rxvt_term::scr_refresh () NOTHROW 2046rxvt_term::scr_refresh () noexcept
2043{ 2047{
2044 int16_t col, row, /* column/row we're processing */ 2048 int16_t col, row, /* column/row we're processing */
2045 ocrow; /* old cursor row */ 2049 ocrow; /* old cursor row */
2046 int i; /* tmp */ 2050 int i; /* tmp */
2047 rend_t ccol1, /* Cursor colour */ 2051 rend_t ccol1, /* Cursor colour */
2048 ccol2; /* Cursor colour2 */ 2052 ccol2; /* Cursor colour2 */
2049 rend_t cur_rend; 2053 rend_t cur_rend;
2050 int cur_col; 2054 int cur_col;
2055 int cursorwidth;
2051 2056
2052 want_refresh = 0; /* screen is current */ 2057 want_refresh = 0; /* screen is current */
2053 2058
2054 if (refresh_type == NO_REFRESH || !mapped) 2059 if (refresh_type == NO_REFRESH || !mapped)
2055 return; 2060 return;
2080 2085
2081 /* 2086 /*
2082 * C: set the cursor character (s) 2087 * C: set the cursor character (s)
2083 */ 2088 */
2084 { 2089 {
2085 bool setoldcursor;
2086
2087#ifdef CURSOR_BLINK 2090#ifdef CURSOR_BLINK
2088 if (hidden_cursor) 2091 if (hidden_cursor)
2089 showcursor = 0; 2092 showcursor = 0;
2090#endif 2093#endif
2091 2094
2093 { 2096 {
2094 int col = screen.cur.col; 2097 int col = screen.cur.col;
2095 2098
2096 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2099 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2097 col--; 2100 col--;
2101
2102 cursorwidth = 1;
2103 while (col + cursorwidth < ncol
2104 && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR)
2105 cursorwidth++;
2098 2106
2099 cur_rend = ROW(screen.cur.row).r[col]; 2107 cur_rend = ROW(screen.cur.row).r[col];
2100 cur_col = col; 2108 cur_col = col;
2101 2109
2102#ifndef NO_CURSORCOLOR 2110#ifndef NO_CURSORCOLOR
2119 ccol2 = bgcolor_of (rstyle); 2127 ccol2 = bgcolor_of (rstyle);
2120#else 2128#else
2121 ccol2 = Color_bg; 2129 ccol2 = Color_bg;
2122#endif 2130#endif
2123 2131
2124 if (focus) 2132 if (focus && cursor_type == 0)
2125 { 2133 {
2126 rend_t rend = cur_rend; 2134 rend_t rend = cur_rend;
2127 2135
2128 if (option (Opt_cursorUnderline))
2129 rend ^= RS_Uline;
2130 else
2131 {
2132 rend ^= RS_RVid; 2136 rend ^= RS_RVid;
2133 rend = SET_FGCOLOR (rend, ccol1); 2137 rend = SET_FGCOLOR (rend, ccol1);
2134 rend = SET_BGCOLOR (rend, ccol2); 2138 rend = SET_BGCOLOR (rend, ccol2);
2135 }
2136 2139
2137 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend); 2140 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2138 } 2141 }
2139 } 2142 }
2140 2143
2141 /* make sure no outline cursor is left around */ 2144 /* make sure no outline cursor is left around */
2142 setoldcursor = 0; 2145 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2143 if (ocrow != -1) 2146 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2147
2148 // save the current cursor coordinates if the cursor is visible
2149 // and either the window is unfocused or the cursor style is
2150 // underline or vertical bar, so as to clear the outline cursor in
2151 // the next refresh if the cursor moves or becomes invisible
2152 if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow)
2144 { 2153 {
2145 if (screen.cur.row - view_start != ocrow 2154 oldcursor.row = screen.cur.row - view_start;
2146 || screen.cur.col != oldcursor.col) 2155 oldcursor.col = screen.cur.col;
2147 {
2148 if (ocrow < nrow
2149 && oldcursor.col < ncol)
2150 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2151
2152 if (focus || !showcursor)
2153 oldcursor.row = -1;
2154 else
2155 setoldcursor = 1;
2156 }
2157 } 2156 }
2158 else if (!focus) 2157 else
2159 setoldcursor = 1;
2160
2161 if (setoldcursor)
2162 {
2163 if (screen.cur.row - view_start >= nrow)
2164 oldcursor.row = -1; 2158 oldcursor.row = -1;
2165 else
2166 {
2167 oldcursor.row = screen.cur.row - view_start;
2168 oldcursor.col = screen.cur.col;
2169 }
2170 }
2171 } 2159 }
2172 2160
2173#ifndef NO_SLOW_LINK_SUPPORT 2161#ifndef NO_SLOW_LINK_SUPPORT
2174 /* 2162 /*
2175 * D: CopyArea pass - very useful for slower links 2163 * D: CopyArea pass - very useful for slower links
2256 int ypixel = (int)Row2Pixel (row); 2244 int ypixel = (int)Row2Pixel (row);
2257 2245
2258 for (col = 0; col < ncol; col++) 2246 for (col = 0; col < ncol; col++)
2259 { 2247 {
2260 /* compare new text with old - if exactly the same then continue */ 2248 /* compare new text with old - if exactly the same then continue */
2261 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2249 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2262 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2263 || (stp[col] == ' ' /* space w/ no background change */
2264 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2265 continue; 2250 continue;
2266 2251
2267 // redraw one or more characters 2252 // redraw one or more characters
2268 2253
2269 // seek to the beginning of wide characters 2254 // seek to the beginning of wide characters
2441 else 2426 else
2442 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2427 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2443 2428
2444 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) 2429 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
2445 { 2430 {
2431 if (showcursor && focus && row == screen.cur.row
2432 && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth))
2433 XSetForeground (dpy, gc, pix_colors[ccol1]);
2434 else
2446#if ENABLE_FRILLS 2435#if ENABLE_FRILLS
2447 if (ISSET_PIXCOLOR (Color_underline)) 2436 if (ISSET_PIXCOLOR (Color_underline))
2448 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2437 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2449 else 2438 else
2450#endif 2439#endif
2461 * G: cleanup cursor and display outline cursor if necessary 2450 * G: cleanup cursor and display outline cursor if necessary
2462 */ 2451 */
2463 if (showcursor) 2452 if (showcursor)
2464 { 2453 {
2465 if (focus) 2454 if (focus)
2455 {
2456 if (cursor_type == 0)
2466 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend); 2457 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2458 else if (oldcursor.row >= 0)
2459 {
2460 XSetForeground (dpy, gc, pix_colors[ccol1]);
2461 if (cursor_type == 1)
2462 XFillRectangle (dpy, vt, gc,
2463 Col2Pixel (cur_col),
2464 Row2Pixel (oldcursor.row + 1) - 2,
2465 Width2Pixel (1),
2466 2);
2467 else
2468 XFillRectangle (dpy, vt, gc,
2469 Col2Pixel (cur_col),
2470 Row2Pixel (oldcursor.row),
2471 2,
2472 Height2Pixel (1));
2473 }
2474 }
2467 else if (oldcursor.row >= 0) 2475 else if (oldcursor.row >= 0)
2468 { 2476 {
2469 int cursorwidth = 1;
2470 int col = oldcursor.col;
2471
2472 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2473 col--;
2474
2475 while (col + cursorwidth < ncol
2476 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2477 cursorwidth++;
2478
2479#ifndef NO_CURSORCOLOR
2480 if (ISSET_PIXCOLOR (Color_cursor))
2481 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2482 else
2483#endif
2484 XSetForeground (dpy, gc, pix_colors[ccol1]); 2477 XSetForeground (dpy, gc, pix_colors[ccol1]);
2485 2478
2486 XDrawRectangle (dpy, vt, gc, 2479 XDrawRectangle (dpy, vt, gc,
2487 Col2Pixel (col), 2480 Col2Pixel (cur_col),
2488 Row2Pixel (oldcursor.row), 2481 Row2Pixel (oldcursor.row),
2489 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2482 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2490 (unsigned int) (Height2Pixel (1) - 1)); 2483 (unsigned int) (Height2Pixel (1) - 1));
2491 } 2484 }
2492 } 2485 }
2505 num_scr = 0; 2498 num_scr = 0;
2506 num_scr_allow = 1; 2499 num_scr_allow = 1;
2507} 2500}
2508 2501
2509void ecb_cold 2502void ecb_cold
2510rxvt_term::scr_remap_chars (line_t &l) NOTHROW 2503rxvt_term::scr_remap_chars (line_t &l) noexcept
2511{ 2504{
2512 if (!l.valid ()) 2505 if (!l.valid ())
2513 return; 2506 return;
2514 2507
2515 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant 2508 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2517 for (int i = ncol; i--; ) 2510 for (int i = ncol; i--; )
2518 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2511 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2519} 2512}
2520 2513
2521void ecb_cold 2514void ecb_cold
2522rxvt_term::scr_remap_chars () NOTHROW 2515rxvt_term::scr_remap_chars () noexcept
2523{ 2516{
2524 for (int i = total_rows; i--; ) 2517 for (int i = total_rows; i--; )
2525 scr_remap_chars (row_buf [i]); 2518 scr_remap_chars (row_buf [i]);
2526 2519
2527 for (int i = nrow; i--; ) 2520 for (int i = nrow; i--; )
2530 scr_remap_chars (swap_buf [i]); 2523 scr_remap_chars (swap_buf [i]);
2531 } 2524 }
2532} 2525}
2533 2526
2534void ecb_cold 2527void ecb_cold
2535rxvt_term::scr_recolour (bool refresh) NOTHROW 2528rxvt_term::scr_recolor (bool refresh) noexcept
2536{ 2529{
2537 bool transparent = false; 2530 bool transparent = false;
2538 2531
2539#ifdef HAVE_IMG 2532#ifdef HAVE_IMG
2540 if (bg_img != 0) 2533 if (bg_img != 0)
2561 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2554 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2562 } 2555 }
2563 2556
2564 XClearWindow (dpy, parent); 2557 XClearWindow (dpy, parent);
2565 2558
2566 if (scrollBar.win) 2559 if (scrollBar.state && scrollBar.win)
2567 { 2560 {
2568 if (transparent) 2561 if (transparent)
2569 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2562 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2570 else 2563 else
2571 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]); 2564 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2581 want_refresh = 1; 2574 want_refresh = 1;
2582} 2575}
2583 2576
2584/* ------------------------------------------------------------------------- */ 2577/* ------------------------------------------------------------------------- */
2585void 2578void
2586rxvt_term::scr_clear (bool really) NOTHROW 2579rxvt_term::scr_clear (bool really) noexcept
2587{ 2580{
2588 if (!mapped) 2581 if (!mapped)
2589 return; 2582 return;
2590 2583
2591 num_scr_allow = 0; 2584 num_scr_allow = 0;
2594 if (really) 2587 if (really)
2595 XClearWindow (dpy, vt); 2588 XClearWindow (dpy, vt);
2596} 2589}
2597 2590
2598void 2591void
2599rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW 2592rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) noexcept
2600{ 2593{
2601 int view_end = view_start + nrow; 2594 int view_end = view_start + nrow;
2602 int row, col; 2595 int row, col;
2603 2596
2604 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) 2597 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++)
2616 srp[col] ^= rstyle2; 2609 srp[col] ^= rstyle2;
2617 } 2610 }
2618} 2611}
2619 2612
2620void 2613void
2621rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW 2614rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) noexcept
2622{ 2615{
2623 int view_end = view_start + nrow; 2616 int view_end = view_start + nrow;
2624 int row, col; 2617 int row, col;
2625 2618
2626 if (beg_row >= view_start) 2619 if (beg_row >= view_start)
2643 srp[col] ^= rstyle; 2636 srp[col] ^= rstyle;
2644} 2637}
2645 2638
2646/* ------------------------------------------------------------------------- */ 2639/* ------------------------------------------------------------------------- */
2647void ecb_hot 2640void ecb_hot
2648rxvt_term::scr_reverse_selection () NOTHROW 2641rxvt_term::scr_reverse_selection () noexcept
2649{ 2642{
2650 if (selection.op 2643 if (selection.op
2651 && current_screen == selection.screen 2644 && current_screen == selection.screen
2652 && selection.end.row >= view_start) 2645 && selection.end.row >= view_start)
2653 { 2646 {
2669 * Dump the whole scrollback and screen to the passed filedescriptor. The 2662 * Dump the whole scrollback and screen to the passed filedescriptor. The
2670 * invoking routine must close the fd. 2663 * invoking routine must close the fd.
2671 */ 2664 */
2672#if 0 2665#if 0
2673void 2666void
2674rxvt_term::scr_dump (int fd) NOTHROW 2667rxvt_term::scr_dump (int fd) noexcept
2675{ 2668{
2676 // if this method is needed, it can be implemented by factoring the 2669 // if this method is needed, it can be implemented by factoring the
2677 // relevant code in scr_printscreen 2670 // relevant code in scr_printscreen
2678} 2671}
2679#endif 2672#endif
2680 2673
2681/* ------------------------------------------------------------------------- * 2674/* ------------------------------------------------------------------------- *
2682 * CHARACTER SELECTION * 2675 * CHARACTER SELECTION *
2683 * ------------------------------------------------------------------------- */ 2676 * ------------------------------------------------------------------------- */
2684void 2677void
2685rxvt_term::selection_check (int check_more) NOTHROW 2678rxvt_term::selection_check (int check_more) noexcept
2686{ 2679{
2687 if (!selection.op) 2680 if (!selection.op)
2688 return; 2681 return;
2689 2682
2690 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) 2683 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow)
2695 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 2688 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
2696 && ROWCOL_IS_BEFORE (screen.cur, selection.end))) 2689 && ROWCOL_IS_BEFORE (screen.cur, selection.end)))
2697 CLEAR_ALL_SELECTION (); 2690 CLEAR_ALL_SELECTION ();
2698} 2691}
2699 2692
2693void
2694rxvt_term::selection_changed () noexcept
2695{
2696 line_t &r1 = ROW (selection.beg.row);
2697 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2698 ++selection.beg.col;
2699
2700 line_t &r2 = ROW (selection.end.row);
2701 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2702 ++selection.end.col;
2703
2704 want_refresh = 1;
2705}
2706
2700/* ------------------------------------------------------------------------- */ 2707/* ------------------------------------------------------------------------- */
2701/* 2708/*
2702 * Paste a selection direct to the command fd 2709 * Paste a selection direct to the command fd
2703 */ 2710 */
2704void 2711void
2705rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW 2712rxvt_term::tt_paste (char *data, unsigned int len) noexcept
2706{ 2713{
2707 /* convert normal newline chars into common keyboard Return key sequence */ 2714 /* convert normal newline chars into common keyboard Return key sequence */
2708 for (unsigned int i = 0; i < len; i++) 2715 for (unsigned int i = 0; i < len; i++)
2709 if (data[i] == C0_LF) 2716 if (data[i] == C0_LF)
2710 data[i] = C0_CR; 2717 data[i] = C0_CR;
2717 if (priv_modes & PrivMode_BracketPaste) 2724 if (priv_modes & PrivMode_BracketPaste)
2718 tt_printf ("\x1b[201~"); 2725 tt_printf ("\x1b[201~");
2719} 2726}
2720 2727
2721void 2728void
2722rxvt_term::paste (char *data, unsigned int len) NOTHROW 2729rxvt_term::paste (char *data, unsigned int len) noexcept
2723{ 2730{
2724 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END))) 2731 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END)))
2725 return; 2732 return;
2726 2733
2727 tt_paste (data, len); 2734 tt_paste (data, len);
2733 * if the requested selection has no owner or is empty CUT_BUFFER0 is used 2740 * if the requested selection has no owner or is empty CUT_BUFFER0 is used
2734 * as fallback 2741 * as fallback
2735 * EXT: button 2 release 2742 * EXT: button 2 release
2736 */ 2743 */
2737void 2744void
2738rxvt_term::selection_request (Time tm, int selnum) NOTHROW 2745rxvt_term::selection_request (Time tm, int selnum) noexcept
2739{ 2746{
2740 if (!selection_req) 2747 if (!selection_req)
2741 { 2748 {
2742 selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); 2749 selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this);
2743 selection_req->run (); 2750 selection_req->run ();
2748/* 2755/*
2749 * Clear all selected text 2756 * Clear all selected text
2750 * EXT: SelectionClear 2757 * EXT: SelectionClear
2751 */ 2758 */
2752void 2759void
2753rxvt_term::selection_clear (bool clipboard) NOTHROW 2760rxvt_term::selection_clear (bool clipboard) noexcept
2754{ 2761{
2755 if (!clipboard) 2762 if (!clipboard)
2756 { 2763 {
2757 want_refresh = 1; 2764 want_refresh = 1;
2758 free (selection.text); 2765 free (selection.text);
2900 2907
2901 selection_grab (tm); 2908 selection_grab (tm);
2902} 2909}
2903 2910
2904bool 2911bool
2905rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW 2912rxvt_term::selection_grab (Time tm, bool clipboard) noexcept
2906{ 2913{
2907 Atom sel; 2914 Atom sel;
2908 2915
2909 if (!clipboard) 2916 if (!clipboard)
2910 { 2917 {
2944/* 2951/*
2945 * Mark or select text based upon number of clicks: 1, 2, or 3 2952 * Mark or select text based upon number of clicks: 1, 2, or 3
2946 * EXT: button 1 press 2953 * EXT: button 1 press
2947 */ 2954 */
2948void ecb_cold 2955void ecb_cold
2949rxvt_term::selection_click (int clicks, int x, int y) NOTHROW 2956rxvt_term::selection_click (int clicks, int x, int y) noexcept
2950{ 2957{
2951 clicks = ((clicks - 1) % 3) + 1; 2958 clicks = ((clicks - 1) % 3) + 1;
2952 selection.clicks = clicks; /* save clicks so extend will work */ 2959 selection.clicks = clicks; /* save clicks so extend will work */
2953 2960
2954 if (clicks == 2 && !selection.rect 2961 if (clicks == 2 && !selection.rect
2973/* ------------------------------------------------------------------------- */ 2980/* ------------------------------------------------------------------------- */
2974/* 2981/*
2975 * Mark a selection at the specified col/row 2982 * Mark a selection at the specified col/row
2976 */ 2983 */
2977void ecb_cold 2984void ecb_cold
2978rxvt_term::selection_start_colrow (int col, int row) NOTHROW 2985rxvt_term::selection_start_colrow (int col, int row) noexcept
2979{ 2986{
2980 want_refresh = 1; 2987 want_refresh = 1;
2981 2988
2982 selection.mark.row = row + view_start; 2989 selection.mark.row = row + view_start;
2983 selection.mark.col = col; 2990 selection.mark.col = col;
3005 * Word select: select text for 2 clicks 3012 * Word select: select text for 2 clicks
3006 * We now only find out the boundary in one direction 3013 * We now only find out the boundary in one direction
3007 */ 3014 */
3008 3015
3009/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ 3016/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
3010#define DELIMIT_TEXT(x) \ 3017#define DELIMIT_TEXT(x) \
3011 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) 3018 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x)))
3012#define DELIMIT_REND(x) 1 3019#define DELIMIT_REND(x) 1
3013 3020
3014void ecb_cold 3021void ecb_cold
3015rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW 3022rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) noexcept
3016{ 3023{
3017 int col, row, dirnadd, tcol, trow, w1, w2; 3024 int col, row, dirnadd, tcol, trow, w1, w2;
3018 row_col_t bound; 3025 row_col_t bound;
3019 text_t *stp; 3026 text_t *stp;
3020 rend_t *srp; 3027 rend_t *srp;
3094 * flag == 0 ==> button 1 3101 * flag == 0 ==> button 1
3095 * flag == 1 ==> button 3 press 3102 * flag == 1 ==> button 3 press
3096 * flag == 2 ==> button 3 motion 3103 * flag == 2 ==> button 3 motion
3097 */ 3104 */
3098void ecb_cold 3105void ecb_cold
3099rxvt_term::selection_extend (int x, int y, int flag) NOTHROW 3106rxvt_term::selection_extend (int x, int y, int flag) noexcept
3100{ 3107{
3101 int col = clamp (Pixel2Col (x), 0, ncol); 3108 int col = clamp (Pixel2Col (x), 0, ncol);
3102 int row = clamp (Pixel2Row (y), 0, nrow - 1); 3109 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3103 3110
3104 /* 3111 /*
3130/* ------------------------------------------------------------------------- */ 3137/* ------------------------------------------------------------------------- */
3131/* 3138/*
3132 * Extend the selection to the specified col/row 3139 * Extend the selection to the specified col/row
3133 */ 3140 */
3134void ecb_cold 3141void ecb_cold
3135rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW 3142rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) noexcept
3136{ 3143{
3137 row_col_t pos; 3144 row_col_t pos;
3138 enum { 3145 enum {
3139 LEFT, RIGHT 3146 LEFT, RIGHT
3140 } closeto = RIGHT; 3147 } closeto = RIGHT;
3141
3142 want_refresh = 1;
3143 3148
3144 switch (selection.op) 3149 switch (selection.op)
3145 { 3150 {
3146 case SELECTION_INIT: 3151 case SELECTION_INIT:
3147 CLEAR_SELECTION (); 3152 CLEAR_SELECTION ();
3327 3332
3328#if !ENABLE_MINIMAL 3333#if !ENABLE_MINIMAL
3329 if (selection.rect && selection.beg.col > selection.end.col) 3334 if (selection.rect && selection.beg.col > selection.end.col)
3330 ::swap (selection.beg.col, selection.end.col); 3335 ::swap (selection.beg.col, selection.end.col);
3331#endif 3336#endif
3337
3338 selection_changed ();
3332} 3339}
3333 3340
3334#if !ENABLE_MINIMAL 3341#if !ENABLE_MINIMAL
3335void ecb_cold 3342void ecb_cold
3336rxvt_term::selection_remove_trailing_spaces () NOTHROW 3343rxvt_term::selection_remove_trailing_spaces () noexcept
3337{ 3344{
3338 int32_t end_col, end_row; 3345 int32_t end_col, end_row;
3339 text_t *stp; 3346 text_t *stp;
3340 3347
3341 end_col = selection.end.col; 3348 end_col = selection.end.col;
3379/* 3386/*
3380 * Double click on button 3 when already selected 3387 * Double click on button 3 when already selected
3381 * EXT: button 3 double click 3388 * EXT: button 3 double click
3382 */ 3389 */
3383void ecb_cold 3390void ecb_cold
3384rxvt_term::selection_rotate (int x, int y) NOTHROW 3391rxvt_term::selection_rotate (int x, int y) noexcept
3385{ 3392{
3386 selection.clicks = selection.clicks % 3 + 1; 3393 selection.clicks = selection.clicks % 3 + 1;
3387 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); 3394 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1);
3388} 3395}
3389 3396
3391/* 3398/*
3392 * Respond to a request for our current selection 3399 * Respond to a request for our current selection
3393 * EXT: SelectionRequest 3400 * EXT: SelectionRequest
3394 */ 3401 */
3395void ecb_cold 3402void ecb_cold
3396rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW 3403rxvt_term::selection_send (const XSelectionRequestEvent &rq) noexcept
3397{ 3404{
3398 Atom property = rq.property == None ? rq.target : rq.property; 3405 Atom property = rq.property == None ? rq.target : rq.property;
3399 XSelectionEvent ev; 3406 XSelectionEvent ev;
3400 3407
3401 ev.type = SelectionNotify; 3408 ev.type = SelectionNotify;
3493 cl = selection.clip_text; 3500 cl = selection.clip_text;
3494 selectlen = selection.clip_len; 3501 selectlen = selection.clip_len;
3495 } 3502 }
3496 else 3503 else
3497 { 3504 {
3498 cl = L""; 3505 cl = (wchar_t *)L"";
3499 selectlen = 0; 3506 selectlen = 0;
3500 } 3507 }
3501 3508
3502#if !ENABLE_MINIMAL 3509#if !ENABLE_MINIMAL
3503 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 3510 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
3535} 3542}
3536 3543
3537/* ------------------------------------------------------------------------- */ 3544/* ------------------------------------------------------------------------- */
3538#if USE_XIM 3545#if USE_XIM
3539void ecb_cold 3546void ecb_cold
3540rxvt_term::im_set_position (XPoint &pos) NOTHROW 3547rxvt_term::im_set_position (XPoint &pos) noexcept
3541{ 3548{
3542 XWindowAttributes xwa; 3549 XWindowAttributes xwa;
3543 3550
3544 XGetWindowAttributes (dpy, vt, &xwa); 3551 XGetWindowAttributes (dpy, vt, &xwa);
3545 3552
3548} 3555}
3549#endif 3556#endif
3550 3557
3551#if ENABLE_OVERLAY 3558#if ENABLE_OVERLAY
3552void 3559void
3553rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW 3560rxvt_term::scr_overlay_new (int x, int y, int w, int h) noexcept
3554{ 3561{
3555 if (nrow < 1 || ncol < 1) 3562 if (nrow < 1 || ncol < 1)
3556 return; 3563 return;
3557 3564
3558 want_refresh = 1; 3565 want_refresh = 1;
3603 *rp = r; 3610 *rp = r;
3604 } 3611 }
3605} 3612}
3606 3613
3607void 3614void
3608rxvt_term::scr_overlay_off () NOTHROW 3615rxvt_term::scr_overlay_off () noexcept
3609{ 3616{
3610 if (!ov.text) 3617 if (!ov.text)
3611 return; 3618 return;
3612 3619
3613 want_refresh = 1; 3620 want_refresh = 1;
3621 delete [] ov.text; ov.text = 0; 3628 delete [] ov.text; ov.text = 0;
3622 delete [] ov.rend; ov.rend = 0; 3629 delete [] ov.rend; ov.rend = 0;
3623} 3630}
3624 3631
3625void 3632void
3626rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3633rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) noexcept
3627{ 3634{
3628 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2) 3635 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3629 return; 3636 return;
3630 3637
3631 x++, y++; 3638 x++, y++;
3633 ov.text[y][x] = text; 3640 ov.text[y][x] = text;
3634 ov.rend[y][x] = rend; 3641 ov.rend[y][x] = rend;
3635} 3642}
3636 3643
3637void 3644void
3638rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3645rxvt_term::scr_overlay_set (int x, int y, const char *s) noexcept
3639{ 3646{
3640 while (*s) 3647 while (*s)
3641 scr_overlay_set (x++, y, *s++); 3648 scr_overlay_set (x++, y, *s++);
3642} 3649}
3643 3650
3644void 3651void
3645rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW 3652rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) noexcept
3646{ 3653{
3647 while (*s) 3654 while (*s)
3648 { 3655 {
3649 text_t t = *s++; 3656 text_t t = *s++;
3650 int width = WCWIDTH (t); 3657 int width = WCWIDTH (t);
3656 } 3663 }
3657 } 3664 }
3658} 3665}
3659 3666
3660void 3667void
3661rxvt_term::scr_swap_overlay () NOTHROW 3668rxvt_term::scr_swap_overlay () noexcept
3662{ 3669{
3663 if (!ov.text) 3670 if (!ov.text)
3664 return; 3671 return;
3665 3672
3666 // hide cursor if it is within the overlay area 3673 // hide cursor if it is within the overlay area

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines