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.415 by root, Mon May 28 14:25:16 2012 UTC vs.
Revision 1.465 by root, Thu Aug 4 18:28:44 2022 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
27#include "../config.h" /* NECESSARY */ 28#include "../config.h" /* NECESSARY */
28#include "rxvt.h" /* NECESSARY */ 29#include "rxvt.h" /* NECESSARY */
29#include "rxvtperl.h" /* NECESSARY */ 30#include "rxvtperl.h" /* NECESSARY */
30 31
31#include <inttypes.h> 32#include <inttypes.h>
32
33#include "salloc.C" // HACK, should be a separate compile!
34 33
35static inline void 34static inline void
36fill_text (text_t *start, text_t value, int len) 35fill_text (text_t *start, text_t value, int len)
37{ 36{
38 while (len--) 37 while (len--)
96 * SCREEN `COMMON' ROUTINES * 95 * SCREEN `COMMON' ROUTINES *
97 * ------------------------------------------------------------------------- */ 96 * ------------------------------------------------------------------------- */
98 97
99/* Fill part/all of a line with blanks. */ 98/* Fill part/all of a line with blanks. */
100void 99void
101rxvt_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
102{ 101{
103 if (!l.valid ()) 102 if (!l.valid ())
104 { 103 {
105 l.alloc (); 104 l.alloc ();
106 col = 0; 105 col = 0;
108 } 107 }
109 108
110 l.touch (); 109 l.touch ();
111 110
112 efs &= ~RS_baseattrMask; // remove italic etc. fontstyles 111 efs &= ~RS_baseattrMask; // remove italic etc. fontstyles
113 efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); 112 efs = SET_FONT (efs, FONTSET (efs)->find_space_font ());
114 113
115 text_t *et = l.t + col; 114 text_t *et = l.t + col;
116 rend_t *er = l.r + col; 115 rend_t *er = l.r + col;
117 116
118 while (width--) 117 while (width--)
123} 122}
124 123
125/* ------------------------------------------------------------------------- */ 124/* ------------------------------------------------------------------------- */
126/* 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 */
127void 126void
128rxvt_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
129{ 128{
130 scr_blank_line (l, 0, ncol, efs); 129 scr_blank_line (l, 0, ncol, efs);
131 130
132 l.l = 0; 131 l.l = 0;
133 l.f = 0; 132 l.f = 0;
134} 133}
135 134
136// nuke a single wide character at the given column 135// nuke a single wide character at the given column
137void 136void
138rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW 137rxvt_term::scr_kill_char (line_t &l, int col) const noexcept
139{ 138{
140 // find begin 139 // find begin
141 while (col > 0 && l.t[col] == NOCHAR) 140 while (col > 0 && l.t[col] == NOCHAR)
142 col--; 141 col--;
143 142
144 rend_t rend = l.r[col] & ~RS_baseattrMask; 143 rend_t rend = l.r[col] & ~RS_baseattrMask;
145 rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); 144 rend = SET_FONT (rend, FONTSET (rend)->find_space_font ());
146 145
147 l.touch (); 146 l.touch ();
148 147
149 // found start, nuke 148 // found start, nuke
150 do { 149 do {
152 l.r[col] = rend; 151 l.r[col] = rend;
153 col++; 152 col++;
154 } while (col < ncol && l.t[col] == NOCHAR); 153 } while (col < ncol && l.t[col] == NOCHAR);
155} 154}
156 155
156// set the rendition of a single wide character beginning at the given column
157void
158rxvt_term::scr_set_char_rend (line_t &l, int col, rend_t rend)
159{
160 do {
161 l.r[col] = rend;
162 col++;
163 } while (col < ncol && l.t[col] == NOCHAR);
164}
165
157/* ------------------------------------------------------------------------- * 166/* ------------------------------------------------------------------------- *
158 * SCREEN INITIALISATION * 167 * SCREEN INITIALISATION *
159 * ------------------------------------------------------------------------- */ 168 * ------------------------------------------------------------------------- */
160 169
161void 170void
162rxvt_term::scr_alloc () 171rxvt_term::scr_alloc () noexcept
163{ 172{
164 int tsize = sizeof (text_t) * ncol; 173 int tsize = sizeof (text_t) * ncol;
165 int rsize = sizeof (rend_t) * ncol; 174 int rsize = sizeof (rend_t) * ncol;
166 175
167 // we assume that rend_t size is a sufficient alignment 176 // we assume that rend_t size is a sufficient alignment
168 // factor for tetx_t and line_t values, and we only 177 // factor for text_t and line_t values, and we only
169 // need to adjust tsize. 178 // need to adjust tsize.
170 tsize = (tsize + sizeof (rend_t) - 1); 179 tsize = (tsize + sizeof (rend_t) - 1);
171 tsize -= tsize % sizeof (rend_t); 180 tsize -= tsize % sizeof (rend_t);
172 181
173 int all_rows = total_rows + nrow + nrow; 182 int all_rows = total_rows + nrow + nrow;
174 183
175 chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows; 184 chunk_size = (sizeof (line_t) + rsize + tsize) * all_rows;
176 chunk = rxvt_malloc (chunk_size); 185 chunk = chunk_alloc (chunk_size, 0);
177 186
178 char *base = (char *)chunk + sizeof (line_t) * all_rows; 187 char *base = (char *)chunk + sizeof (line_t) * all_rows;
179 188
180 for (int row = 0; row < all_rows; ++row) 189 for (int row = 0; row < all_rows; ++row)
181 { 190 {
191 swap_buf = drawn_buf + nrow; 200 swap_buf = drawn_buf + nrow;
192 row_buf = swap_buf + nrow; 201 row_buf = swap_buf + nrow;
193} 202}
194 203
195void 204void
205rxvt_term::copy_line (line_t &dst, line_t &src)
206{
207 scr_blank_screen_mem (dst, DEFAULT_RSTYLE);
208 dst.l = min (src.l, ncol);
209 memcpy (dst.t, src.t, sizeof (text_t) * dst.l);
210 memcpy (dst.r, src.r, sizeof (rend_t) * dst.l);
211 dst.f = src.f;
212}
213
214void ecb_cold
196rxvt_term::scr_reset () 215rxvt_term::scr_reset ()
197{ 216{
198#if ENABLE_OVERLAY 217#if ENABLE_OVERLAY
199 scr_overlay_off (); 218 scr_overlay_off ();
200#endif 219#endif
227 246
228 screen.tscroll = 0; 247 screen.tscroll = 0;
229 screen.bscroll = nrow - 1; 248 screen.bscroll = nrow - 1;
230 249
231 void *prev_chunk = chunk; 250 void *prev_chunk = chunk;
251 size_t prev_chunk_size = chunk_size;
232 line_t *prev_drawn_buf = drawn_buf; 252 line_t *prev_drawn_buf = drawn_buf;
233 line_t *prev_swap_buf = swap_buf; 253 line_t *prev_swap_buf = swap_buf;
234 line_t *prev_row_buf = row_buf; 254 line_t *prev_row_buf = row_buf;
235 255
236 int common_col = min (prev_ncol, ncol);
237
238 scr_alloc (); 256 scr_alloc ();
239 257
240 if (!prev_row_buf) 258 if (!prev_row_buf)
241 { 259 {
242 /*
243 * first time called so just malloc everything: don't rely on realloc
244 */
245 top_row = 0; 260 top_row = 0;
246 term_start = 0; 261 term_start = 0;
247 262
248 memset (charsets, 'B', sizeof (charsets)); 263 memset (charsets, 'B', sizeof (charsets));
249 rstyle = DEFAULT_RSTYLE; 264 rstyle = DEFAULT_RSTYLE;
274 { 289 {
275 /* 290 /*
276 * add or delete rows as appropriate 291 * add or delete rows as appropriate
277 */ 292 */
278 293
294 int common_col = min (prev_ncol, ncol);
295
296 // resize swap_buf, blank drawn_buf
279 for (int row = min (nrow, prev_nrow); row--; ) 297 for (int row = min (nrow, prev_nrow); row--; )
280 { 298 {
281 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); 299 scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
282 scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
283
284 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col); 300 memcpy (drawn_buf [row].t, prev_drawn_buf [row].t, sizeof (text_t) * common_col);
285 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col); 301 memcpy (drawn_buf [row].r, prev_drawn_buf [row].r, sizeof (rend_t) * common_col);
286 memcpy (swap_buf [row].t, prev_swap_buf [row].t, sizeof (text_t) * common_col); 302
287 memcpy (swap_buf [row].r, prev_swap_buf [row].r, sizeof (rend_t) * common_col); 303 copy_line (swap_buf [row], prev_swap_buf [row]);
288 } 304 }
289 305
290 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row 306 int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row
291 int pend = MOD (term_start + top_row , prev_total_rows); 307 int pend = MOD (term_start + top_row , prev_total_rows);
292 int q = total_rows; // rewrapped row 308 int q = total_rows; // rewrapped row
293 309
294 if (top_row) 310#if ENABLE_FRILLS
311 if ((rewrap_always || top_row) && !rewrap_never)
295 { 312 {
296 // Re-wrap lines. This is rather ugly, possibly because I am too dumb 313 // Re-wrap lines. This is rather ugly, possibly because I am too dumb
297 // to come up with a lean and mean algorithm. 314 // to come up with a lean and mean algorithm.
298 // TODO: maybe optimise when width didn't change 315 // TODO: maybe optimise when width didn't change
299 316
315 llen += prev_ncol; 332 llen += prev_ncol;
316 } 333 }
317 334
318 int qlines = max (0, (llen - 1) / ncol) + 1; 335 int qlines = max (0, (llen - 1) / ncol) + 1;
319 336
337 q -= qlines;
338
320 // drop partial lines completely 339 // drop partial lines completely
321 if (q < qlines) 340 if (q < 0)
322 break; 341 break;
323
324 q -= qlines;
325 342
326 int lofs = 0; 343 int lofs = 0;
327 line_t *qline; 344 line_t *qline;
328 345
329 // re-assemble the full line by destination lines 346 // re-assemble the full line by destination lines
371 qline->is_longer (0); 388 qline->is_longer (0);
372 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE); 389 scr_blank_line (*qline, qline->l, ncol - qline->l, DEFAULT_RSTYLE);
373 } 390 }
374 while (p != pend && q > 0); 391 while (p != pend && q > 0);
375 392
376 term_start = total_rows - nrow;
377 top_row = q - term_start;
378
379 // make sure all terminal lines exist 393 // make sure all terminal lines exist
380 while (top_row > 0) 394 while (top_row > 0)
381 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); 395 scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE);
382 } 396 }
383 else 397 else
398#endif
399 {
400 // wing, instead of wrap
384 { 401 do
385 // if no scrollback exists (yet), wing, instead of wrap
386
387 for (int row = min (nrow, prev_nrow); row--; )
388 { 402 {
389 line_t &src = prev_row_buf [MOD (term_start + row, prev_total_rows)]; 403 p = MOD (p - 1, prev_total_rows);
390 line_t &dst = row_buf [row]; 404 q--;
391 405
392 scr_blank_screen_mem (dst, DEFAULT_RSTYLE); 406 copy_line (row_buf [q], prev_row_buf [p]);
393
394 memcpy (dst.t, src.t, sizeof (text_t) * common_col);
395 memcpy (dst.r, src.r, sizeof (rend_t) * common_col);
396 } 407 }
408 while (p != pend);
397 409
398 for (int row = prev_nrow; row < nrow; row++) 410 screen.cur.row += nrow - prev_nrow;
399 scr_blank_screen_mem (row_buf [row], DEFAULT_RSTYLE);
400
401 term_start = 0;
402 } 411 }
412
413 term_start = total_rows - nrow;
414 top_row = q - term_start;
403 415
404 clamp_it (screen.cur.row, 0, nrow - 1); 416 clamp_it (screen.cur.row, 0, nrow - 1);
405 clamp_it (screen.cur.col, 0, ncol - 1); 417 clamp_it (screen.cur.col, 0, ncol - 1);
406 } 418 }
407 419
420 // ensure drawn_buf, swap_buf and terminal rows are all initialized
408 for (int row = nrow; row--; ) 421 for (int row = nrow; row--; )
409 { 422 {
410 if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE); 423 if (!ROW (row).valid ()) scr_blank_screen_mem (ROW (row), DEFAULT_RSTYLE);
411 if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE); 424 if (!swap_buf [row].valid ()) scr_blank_screen_mem (swap_buf [row], DEFAULT_RSTYLE);
412 if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE); 425 if (!drawn_buf [row].valid ()) scr_blank_screen_mem (drawn_buf [row], DEFAULT_RSTYLE);
413 } 426 }
414 427
415 free (prev_chunk); 428 chunk_free (prev_chunk, prev_chunk_size);
416 429
417 free (tabs); 430 free (tabs);
418 tabs = (char *)rxvt_malloc (ncol); 431 tabs = (char *)rxvt_malloc (ncol);
419 432
420 for (int col = ncol; col--; ) 433 for (int col = ncol; col--; )
428 tt_winch (); 441 tt_winch ();
429 442
430 HOOK_INVOKE ((this, HOOK_RESET, DT_END)); 443 HOOK_INVOKE ((this, HOOK_RESET, DT_END));
431} 444}
432 445
433/* ------------------------------------------------------------------------- */ 446void ecb_cold
434/*
435 * Free everything. That way malloc debugging can find leakage.
436 */
437void
438rxvt_term::scr_release () NOTHROW 447rxvt_term::scr_release () noexcept
439{ 448{
440 free (chunk); 449 chunk_free (chunk, chunk_size);
450 chunk = 0;
451 row_buf = 0;
452
441 free (tabs); 453 free (tabs);
454 tabs = 0;
442} 455}
443 456
444/* ------------------------------------------------------------------------- */ 457/* ------------------------------------------------------------------------- */
445/* 458/*
446 * Hard/Soft reset 459 * Hard/Soft reset
447 */ 460 */
448void 461void ecb_cold
449rxvt_term::scr_poweron () 462rxvt_term::scr_poweron ()
450{ 463{
451 scr_release (); 464 scr_release ();
452 465
453 row_buf = 0;
454 tabs = 0;
455 prev_nrow = prev_ncol = 0; 466 prev_nrow = prev_ncol = 0;
456 rvideo_mode = false; 467 rvideo_mode = false;
457 scr_soft_reset (); 468 scr_soft_reset ();
458 scr_reset (); 469 scr_reset ();
459 470
460 scr_clear (true); 471 scr_clear (true);
461 scr_refresh (); 472 scr_refresh ();
462} 473}
463 474
464void 475void ecb_cold
465rxvt_term::scr_soft_reset () NOTHROW 476rxvt_term::scr_soft_reset () noexcept
466{ 477{
467 /* only affects modes, nothing drastic such as clearing the screen */ 478 /* only affects modes, nothing drastic such as clearing the screen */
468#if ENABLE_OVERLAY 479#if ENABLE_OVERLAY
469 scr_overlay_off (); 480 scr_overlay_off ();
470#endif 481#endif
484 * Save and Restore cursor 495 * Save and Restore cursor
485 * XTERM_SEQ: Save cursor : ESC 7 496 * XTERM_SEQ: Save cursor : ESC 7
486 * XTERM_SEQ: Restore cursor: ESC 8 497 * XTERM_SEQ: Restore cursor: ESC 8
487 */ 498 */
488void 499void
489rxvt_term::scr_cursor (cursor_mode mode) NOTHROW 500rxvt_term::scr_cursor (cursor_mode mode) noexcept
490{ 501{
491 screen_t *s; 502 screen_t *s;
492 503
493#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR) 504#if NSCREENS && !defined(NO_SECONDARY_SCREEN_CURSOR)
494 if (current_screen == SECONDARY) 505 if (current_screen == SECONDARY)
525 assert (s->cur.row >= 0); 536 assert (s->cur.row >= 0);
526 assert (s->cur.col >= 0); 537 assert (s->cur.col >= 0);
527} 538}
528 539
529void 540void
530rxvt_term::scr_swap_screen () NOTHROW 541rxvt_term::scr_swap_screen () noexcept
531{ 542{
532 if (!option (Opt_secondaryScreen)) 543 if (!option (Opt_secondaryScreen))
533 return; 544 return;
534 545
535 for (int i = prev_nrow; i--; ) 546 for (int i = prev_nrow; i--; )
583 scr_scroll_text (0, prev_nrow - 1, prev_nrow); 594 scr_scroll_text (0, prev_nrow - 1, prev_nrow);
584} 595}
585 596
586// clear WrapNext indicator, solidifying position on next line 597// clear WrapNext indicator, solidifying position on next line
587void 598void
588rxvt_term::scr_do_wrap () NOTHROW 599rxvt_term::scr_do_wrap () noexcept
589{ 600{
590 if (!(screen.flags & Screen_WrapNext)) 601 if (!(screen.flags & Screen_WrapNext))
591 return; 602 return;
592 603
593 screen.flags &= ~Screen_WrapNext; 604 screen.flags &= ~Screen_WrapNext;
603/* ------------------------------------------------------------------------- */ 614/* ------------------------------------------------------------------------- */
604/* 615/*
605 * Change the colour for following text 616 * Change the colour for following text
606 */ 617 */
607void 618void
608rxvt_term::scr_color (unsigned int color, int fgbg) NOTHROW 619rxvt_term::scr_color (unsigned int color, int fgbg) noexcept
609{ 620{
610 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) 621 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR24))
611 color = fgbg; 622 color = fgbg;
612 623
613 if (fgbg == Color_fg) 624 if (fgbg == Color_fg)
614 rstyle = SET_FGCOLOR (rstyle, color); 625 rstyle = SET_FGCOLOR (rstyle, color);
615 else 626 else
619/* ------------------------------------------------------------------------- */ 630/* ------------------------------------------------------------------------- */
620/* 631/*
621 * Change the rendition style for following text 632 * Change the rendition style for following text
622 */ 633 */
623void 634void
624rxvt_term::scr_rendition (int set, int style) NOTHROW 635rxvt_term::scr_rendition (int set, int style) noexcept
625{ 636{
626 if (set) 637 if (set)
627 rstyle |= style; 638 rstyle |= style;
628 else if (style == ~RS_None) 639 else if (style == ~RS_None)
629 rstyle = DEFAULT_RSTYLE; 640 rstyle = DEFAULT_RSTYLE;
635/* 646/*
636 * Scroll text between <row1> and <row2> inclusive, by <count> lines 647 * Scroll text between <row1> and <row2> inclusive, by <count> lines
637 * count positive ==> scroll up 648 * count positive ==> scroll up
638 * count negative ==> scroll down 649 * count negative ==> scroll down
639 */ 650 */
640int 651int ecb_hot
641rxvt_term::scr_scroll_text (int row1, int row2, int count) NOTHROW 652rxvt_term::scr_scroll_text (int row1, int row2, int count) noexcept
642{ 653{
643 if (count == 0 || (row1 > row2)) 654 if (count == 0 || (row1 > row2))
644 return 0; 655 return 0;
645 656
646 want_refresh = 1; 657 want_refresh = 1;
706 717
707 // finally move the view window, if desired 718 // finally move the view window, if desired
708 if (option (Opt_scrollWithBuffer) 719 if (option (Opt_scrollWithBuffer)
709 && view_start != 0 720 && view_start != 0
710 && view_start != -saveLines) 721 && view_start != -saveLines)
711 scr_page (UP, count); 722 scr_page (count);
712 723
713 if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) 724 if (SHOULD_INVOKE (HOOK_SCROLL_BACK))
714 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END)); 725 HOOK_INVOKE ((this, HOOK_SCROLL_BACK, DT_INT, count, DT_INT, top_row, DT_END));
715 } 726 }
716 else 727 else
779 790
780/* ------------------------------------------------------------------------- */ 791/* ------------------------------------------------------------------------- */
781/* 792/*
782 * Add text given in <str> of length <len> to screen struct 793 * Add text given in <str> of length <len> to screen struct
783 */ 794 */
784void 795void ecb_hot
785rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) NOTHROW 796rxvt_term::scr_add_lines (const wchar_t *str, int len, int minlines) noexcept
786{ 797{
787 if (len <= 0) /* sanity */ 798 if (len <= 0) /* sanity */
788 return; 799 return;
789 800
790 bool checksel; 801 bool checksel;
1002 } 1013 }
1003 else if (screen.cur.row > 0 1014 else if (screen.cur.row > 0
1004 && ROW(screen.cur.row - 1).is_longer ()) 1015 && ROW(screen.cur.row - 1).is_longer ())
1005 { 1016 {
1006 linep = &ROW(screen.cur.row - 1); 1017 linep = &ROW(screen.cur.row - 1);
1007 tp = line->t + ncol - 1; 1018 tp = linep->t + ncol - 1;
1008 rp = line->r + ncol - 1; 1019 rp = linep->r + ncol - 1;
1009 } 1020 }
1010 else 1021 else
1011 continue; 1022 continue;
1012 1023
1013 linep->touch (); 1024 linep->touch ();
1036/* 1047/*
1037 * Process Backspace. Move back the cursor back a position, wrap if have to 1048 * Process Backspace. Move back the cursor back a position, wrap if have to
1038 * XTERM_SEQ: CTRL-H 1049 * XTERM_SEQ: CTRL-H
1039 */ 1050 */
1040void 1051void
1041rxvt_term::scr_backspace () NOTHROW 1052rxvt_term::scr_backspace () noexcept
1042{ 1053{
1043 if (screen.cur.col == 0) 1054 if (screen.cur.col == 0)
1044 { 1055 {
1045 if (screen.cur.row > 0) 1056 if (screen.cur.row > 0)
1046 { 1057 {
1063 * Process Horizontal Tab 1074 * Process Horizontal Tab
1064 * count: +ve = forward; -ve = backwards 1075 * count: +ve = forward; -ve = backwards
1065 * XTERM_SEQ: CTRL-I 1076 * XTERM_SEQ: CTRL-I
1066 */ 1077 */
1067void 1078void
1068rxvt_term::scr_tab (int count, bool ht) NOTHROW 1079rxvt_term::scr_tab (int count, bool ht) noexcept
1069{ 1080{
1070 int i, x; 1081 int i, x;
1071 1082
1072 want_refresh = 1; 1083 want_refresh = 1;
1073 i = x = screen.cur.col; 1084 i = x = screen.cur.col;
1139 * XTERM_SEQ: ESC 6 1150 * XTERM_SEQ: ESC 6
1140 * Move cursor left in row. If we're at the left boundary, shift everything 1151 * Move cursor left in row. If we're at the left boundary, shift everything
1141 * in that row right. Clear left column. 1152 * in that row right. Clear left column.
1142 */ 1153 */
1143#if !ENABLE_MINIMAL 1154#if !ENABLE_MINIMAL
1144void 1155void ecb_cold
1145rxvt_term::scr_backindex () NOTHROW 1156rxvt_term::scr_backindex () noexcept
1146{ 1157{
1147 if (screen.cur.col > 0) 1158 if (screen.cur.col > 0)
1148 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); 1159 scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE);
1149 else 1160 else
1150 scr_insdel_chars (1, INSERT); 1161 scr_insdel_chars (1, INSERT);
1156 * XTERM_SEQ: ESC 9 1167 * XTERM_SEQ: ESC 9
1157 * Move cursor right in row. If we're at the right boundary, shift everything 1168 * Move cursor right in row. If we're at the right boundary, shift everything
1158 * in that row left. Clear right column. 1169 * in that row left. Clear right column.
1159 */ 1170 */
1160#if !ENABLE_MINIMAL 1171#if !ENABLE_MINIMAL
1161void 1172void ecb_cold
1162rxvt_term::scr_forwardindex () NOTHROW 1173rxvt_term::scr_forwardindex () noexcept
1163{ 1174{
1164 if (screen.cur.col < ncol - 1) 1175 if (screen.cur.col < ncol - 1)
1165 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); 1176 scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE);
1166 else 1177 else
1167 { 1178 {
1180/* ------------------------------------------------------------------------- */ 1191/* ------------------------------------------------------------------------- */
1181/* 1192/*
1182 * Goto Row/Column 1193 * Goto Row/Column
1183 */ 1194 */
1184void 1195void
1185rxvt_term::scr_gotorc (int row, int col, int relative) NOTHROW 1196rxvt_term::scr_gotorc (int row, int col, int relative) noexcept
1186{ 1197{
1187 want_refresh = 1; 1198 want_refresh = 1;
1188 ZERO_SCROLLBACK (); 1199 ZERO_SCROLLBACK ();
1189 1200
1190 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col; 1201 screen.cur.col = relative & C_RELATIVE ? screen.cur.col + col : col;
1229/* ------------------------------------------------------------------------- */ 1240/* ------------------------------------------------------------------------- */
1230/* 1241/*
1231 * direction should be UP or DN 1242 * direction should be UP or DN
1232 */ 1243 */
1233void 1244void
1234rxvt_term::scr_index (enum page_dirn direction) NOTHROW 1245rxvt_term::scr_index (enum page_dirn direction) noexcept
1235{ 1246{
1236 int dirn;
1237
1238 want_refresh = 1; 1247 want_refresh = 1;
1239 ZERO_SCROLLBACK (); 1248 ZERO_SCROLLBACK ();
1240 1249
1241 dirn = ((direction == UP) ? 1 : -1);
1242
1243 screen.flags &= ~Screen_WrapNext; 1250 screen.flags &= ~Screen_WrapNext;
1244 1251
1245 if ((screen.cur.row == screen.bscroll && direction == UP) 1252 if ((screen.cur.row == screen.bscroll && direction == UP)
1246 || (screen.cur.row == screen.tscroll && direction == DN)) 1253 || (screen.cur.row == screen.tscroll && direction == DN))
1247 scr_scroll_text (screen.tscroll, screen.bscroll, dirn); 1254 scr_scroll_text (screen.tscroll, screen.bscroll, direction);
1248 else 1255 else
1249 screen.cur.row += dirn; 1256 screen.cur.row += direction;
1250 1257
1251 clamp_it (screen.cur.row, 0, nrow - 1); 1258 clamp_it (screen.cur.row, 0, nrow - 1);
1252 selection_check (0); 1259 selection_check (0);
1253} 1260}
1254 1261
1259 * XTERM_SEQ: Clear line to left : ESC [ 1 K 1266 * XTERM_SEQ: Clear line to left : ESC [ 1 K
1260 * XTERM_SEQ: Clear whole line : ESC [ 2 K 1267 * XTERM_SEQ: Clear whole line : ESC [ 2 K
1261 * extension: clear to right unless wrapped: ESC [ 3 K 1268 * extension: clear to right unless wrapped: ESC [ 3 K
1262 */ 1269 */
1263void 1270void
1264rxvt_term::scr_erase_line (int mode) NOTHROW 1271rxvt_term::scr_erase_line (int mode) noexcept
1265{ 1272{
1266 unsigned int col, num; 1273 unsigned int col, num;
1267 1274
1268 want_refresh = 1; 1275 want_refresh = 1;
1269 ZERO_SCROLLBACK (); 1276 ZERO_SCROLLBACK ();
1323 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J 1330 * XTERM_SEQ: Clear screen after cursor : ESC [ 0 J
1324 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J 1331 * XTERM_SEQ: Clear screen before cursor: ESC [ 1 J
1325 * XTERM_SEQ: Clear whole screen : ESC [ 2 J 1332 * XTERM_SEQ: Clear whole screen : ESC [ 2 J
1326 */ 1333 */
1327void 1334void
1328rxvt_term::scr_erase_screen (int mode) NOTHROW 1335rxvt_term::scr_erase_screen (int mode) noexcept
1329{ 1336{
1330 int num; 1337 int num;
1331 int32_t row; 1338 int32_t row;
1332 rend_t ren; 1339 rend_t ren;
1333 XGCValues gcvalue; 1340 XGCValues gcvalue;
1403 } 1410 }
1404} 1411}
1405 1412
1406#if !ENABLE_MINIMAL 1413#if !ENABLE_MINIMAL
1407void 1414void
1408rxvt_term::scr_erase_savelines () NOTHROW 1415rxvt_term::scr_erase_savelines () noexcept
1409{ 1416{
1410 want_refresh = 1; 1417 want_refresh = 1;
1411 ZERO_SCROLLBACK (); 1418 ZERO_SCROLLBACK ();
1412 1419
1413 top_row = 0; 1420 top_row = 0;
1417/* ------------------------------------------------------------------------- */ 1424/* ------------------------------------------------------------------------- */
1418/* 1425/*
1419 * Fill the screen with `E's 1426 * Fill the screen with `E's
1420 * XTERM_SEQ: Screen Alignment Test: ESC # 8 1427 * XTERM_SEQ: Screen Alignment Test: ESC # 8
1421 */ 1428 */
1422void 1429void ecb_cold
1423rxvt_term::scr_E () NOTHROW 1430rxvt_term::scr_E () noexcept
1424{ 1431{
1425 rend_t fs; 1432 rend_t fs;
1426 1433
1427 want_refresh = 1; 1434 want_refresh = 1;
1428 ZERO_SCROLLBACK (); 1435 ZERO_SCROLLBACK ();
1453/* ------------------------------------------------------------------------- */ 1460/* ------------------------------------------------------------------------- */
1454/* 1461/*
1455 * Insert/Delete <count> lines 1462 * Insert/Delete <count> lines
1456 */ 1463 */
1457void 1464void
1458rxvt_term::scr_insdel_lines (int count, int insdel) NOTHROW 1465rxvt_term::scr_insdel_lines (int count, int insdel) noexcept
1459{ 1466{
1460 int end; 1467 int end;
1461 1468
1462 ZERO_SCROLLBACK (); 1469 ZERO_SCROLLBACK ();
1463 1470
1483/* ------------------------------------------------------------------------- */ 1490/* ------------------------------------------------------------------------- */
1484/* 1491/*
1485 * Insert/Delete <count> characters from the current position 1492 * Insert/Delete <count> characters from the current position
1486 */ 1493 */
1487void 1494void
1488rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW 1495rxvt_term::scr_insdel_chars (int count, int insdel) noexcept
1489{ 1496{
1490 want_refresh = 1; 1497 want_refresh = 1;
1491 ZERO_SCROLLBACK (); 1498 ZERO_SCROLLBACK ();
1492 1499
1493 if (count <= 0) 1500 if (count <= 0)
1591/* ------------------------------------------------------------------------- */ 1598/* ------------------------------------------------------------------------- */
1592/* 1599/*
1593 * Set the scrolling region 1600 * Set the scrolling region
1594 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r 1601 * XTERM_SEQ: Set region <top> - <bot> inclusive: ESC [ <top> ; <bot> r
1595 */ 1602 */
1596void 1603void ecb_cold
1597rxvt_term::scr_scroll_region (int top, int bot) NOTHROW 1604rxvt_term::scr_scroll_region (int top, int bot) noexcept
1598{ 1605{
1599 max_it (top, 0); 1606 max_it (top, 0);
1600 min_it (bot, nrow - 1); 1607 min_it (bot, nrow - 1);
1601 1608
1602 if (top > bot) 1609 if (top > bot)
1611/* 1618/*
1612 * Make the cursor visible/invisible 1619 * Make the cursor visible/invisible
1613 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h 1620 * XTERM_SEQ: Make cursor visible : ESC [ ? 25 h
1614 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l 1621 * XTERM_SEQ: Make cursor invisible: ESC [ ? 25 l
1615 */ 1622 */
1616void 1623void ecb_cold
1617rxvt_term::scr_cursor_visible (int mode) NOTHROW 1624rxvt_term::scr_cursor_visible (int mode) noexcept
1618{ 1625{
1619 want_refresh = 1; 1626 want_refresh = 1;
1620 1627
1621 if (mode) 1628 if (mode)
1622 screen.flags |= Screen_VisibleCursor; 1629 screen.flags |= Screen_VisibleCursor;
1628/* 1635/*
1629 * Set/unset automatic wrapping 1636 * Set/unset automatic wrapping
1630 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h 1637 * XTERM_SEQ: Set Wraparound : ESC [ ? 7 h
1631 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l 1638 * XTERM_SEQ: Unset Wraparound: ESC [ ? 7 l
1632 */ 1639 */
1633void 1640void ecb_cold
1634rxvt_term::scr_autowrap (int mode) NOTHROW 1641rxvt_term::scr_autowrap (int mode) noexcept
1635{ 1642{
1636 if (mode) 1643 if (mode)
1637 screen.flags |= Screen_Autowrap; 1644 screen.flags |= Screen_Autowrap;
1638 else 1645 else
1639 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext); 1646 screen.flags &= ~(Screen_Autowrap | Screen_WrapNext);
1647 * Relative mode: line numbers are relative to top margin of scrolling region 1654 * Relative mode: line numbers are relative to top margin of scrolling region
1648 * and the cursor cannot be moved outside. 1655 * and the cursor cannot be moved outside.
1649 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h 1656 * XTERM_SEQ: Set Absolute: ESC [ ? 6 h
1650 * XTERM_SEQ: Set Relative: ESC [ ? 6 l 1657 * XTERM_SEQ: Set Relative: ESC [ ? 6 l
1651 */ 1658 */
1652void 1659void ecb_cold
1653rxvt_term::scr_relative_origin (int mode) NOTHROW 1660rxvt_term::scr_relative_origin (int mode) noexcept
1654{ 1661{
1655 if (mode) 1662 if (mode)
1656 screen.flags |= Screen_Relative; 1663 screen.flags |= Screen_Relative;
1657 else 1664 else
1658 screen.flags &= ~Screen_Relative; 1665 screen.flags &= ~Screen_Relative;
1664/* 1671/*
1665 * Set insert/replace mode 1672 * Set insert/replace mode
1666 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h 1673 * XTERM_SEQ: Set Insert mode : ESC [ ? 4 h
1667 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l 1674 * XTERM_SEQ: Set Replace mode: ESC [ ? 4 l
1668 */ 1675 */
1669void 1676void ecb_cold
1670rxvt_term::scr_insert_mode (int mode) NOTHROW 1677rxvt_term::scr_insert_mode (int mode) noexcept
1671{ 1678{
1672 if (mode) 1679 if (mode)
1673 screen.flags |= Screen_Insert; 1680 screen.flags |= Screen_Insert;
1674 else 1681 else
1675 screen.flags &= ~Screen_Insert; 1682 screen.flags &= ~Screen_Insert;
1680 * Set/Unset tabs 1687 * Set/Unset tabs
1681 * XTERM_SEQ: Set tab at current column : ESC H 1688 * XTERM_SEQ: Set tab at current column : ESC H
1682 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g 1689 * XTERM_SEQ: Clear tab at current column: ESC [ 0 g
1683 * XTERM_SEQ: Clear all tabs : ESC [ 3 g 1690 * XTERM_SEQ: Clear all tabs : ESC [ 3 g
1684 */ 1691 */
1685void 1692void ecb_cold
1686rxvt_term::scr_set_tab (int mode) NOTHROW 1693rxvt_term::scr_set_tab (int mode) noexcept
1687{ 1694{
1688 if (mode < 0) 1695 if (mode < 0)
1689 memset (tabs, 0, ncol); 1696 memset (tabs, 0, ncol);
1690 else if (screen.cur.col < ncol) 1697 else if (screen.cur.col < ncol)
1691 tabs [screen.cur.col] = !!mode; 1698 tabs [screen.cur.col] = !!mode;
1696 * Set reverse/normal video 1703 * Set reverse/normal video
1697 * XTERM_SEQ: Reverse video: ESC [ ? 5 h 1704 * XTERM_SEQ: Reverse video: ESC [ ? 5 h
1698 * XTERM_SEQ: Normal video : ESC [ ? 5 l 1705 * XTERM_SEQ: Normal video : ESC [ ? 5 l
1699 */ 1706 */
1700void 1707void
1701rxvt_term::scr_rvideo_mode (bool on) NOTHROW 1708rxvt_term::scr_rvideo_mode (bool on) noexcept
1702{ 1709{
1703 rvideo_mode = on; 1710 rvideo_mode = on;
1704 1711
1705#ifndef NO_BELL 1712#ifndef NO_BELL
1706 on ^= rvideo_bell; 1713 on ^= rvideo_bell;
1708 1715
1709 if (rvideo_state != on) 1716 if (rvideo_state != on)
1710 { 1717 {
1711 rvideo_state = on; 1718 rvideo_state = on;
1712 1719
1720#if OFF_FOCUS_FADING
1721 if (rs[Rs_fade])
1722 {
1723 ::swap (pix_colors_focused[Color_fg], pix_colors_focused[Color_bg]);
1724 ::swap (pix_colors_unfocused[Color_fg], pix_colors_unfocused[Color_bg]);
1725 }
1726 else
1727#endif
1713 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); 1728 ::swap (pix_colors[Color_fg], pix_colors[Color_bg]);
1714#ifdef HAVE_BG_PIXMAP 1729#ifdef HAVE_IMG
1715 if (bg_pixmap == None) 1730 if (bg_img == 0)
1716#endif 1731#endif
1717 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 1732 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
1718 1733
1719 XGCValues gcvalue; 1734 XGCValues gcvalue;
1720 gcvalue.foreground = pix_colors[Color_fg]; 1735 gcvalue.foreground = pix_colors[Color_fg];
1729/* ------------------------------------------------------------------------- */ 1744/* ------------------------------------------------------------------------- */
1730/* 1745/*
1731 * Report current cursor position 1746 * Report current cursor position
1732 * XTERM_SEQ: Report position: ESC [ 6 n 1747 * XTERM_SEQ: Report position: ESC [ 6 n
1733 */ 1748 */
1734void 1749void ecb_cold
1735rxvt_term::scr_report_position () NOTHROW 1750rxvt_term::scr_report_position () noexcept
1736{ 1751{
1737 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1); 1752 tt_printf ("\033[%d;%dR", screen.cur.row + 1, screen.cur.col + 1);
1738} 1753}
1739 1754
1740/* ------------------------------------------------------------------------- * 1755/* ------------------------------------------------------------------------- *
1742 * ------------------------------------------------------------------------- */ 1757 * ------------------------------------------------------------------------- */
1743 1758
1744/* 1759/*
1745 * Set font style 1760 * Set font style
1746 */ 1761 */
1747void 1762void ecb_cold
1748rxvt_term::set_font_style () NOTHROW 1763rxvt_term::set_font_style () noexcept
1749{ 1764{
1750#if 0 1765#if 0
1751 switch (charsets [screen.charset]) 1766 switch (charsets [screen.charset])
1752 { 1767 {
1753 case '0': /* DEC Special Character & Line Drawing Set */ 1768 case '0': /* DEC Special Character & Line Drawing Set */
1774 * XTERM_SEQ: Invoke G0 character set: CTRL-O 1789 * XTERM_SEQ: Invoke G0 character set: CTRL-O
1775 * XTERM_SEQ: Invoke G1 character set: CTRL-N 1790 * XTERM_SEQ: Invoke G1 character set: CTRL-N
1776 * XTERM_SEQ: Invoke G2 character set: ESC N 1791 * XTERM_SEQ: Invoke G2 character set: ESC N
1777 * XTERM_SEQ: Invoke G3 character set: ESC O 1792 * XTERM_SEQ: Invoke G3 character set: ESC O
1778 */ 1793 */
1779void 1794void ecb_cold
1780rxvt_term::scr_charset_choose (int set) NOTHROW 1795rxvt_term::scr_charset_choose (int set) noexcept
1781{ 1796{
1782 screen.charset = set; 1797 screen.charset = set;
1783 set_font_style (); 1798 set_font_style ();
1784} 1799}
1785 1800
1791 * XTERM_SEQ: Set G2 character set: ESC * <C> 1806 * XTERM_SEQ: Set G2 character set: ESC * <C>
1792 * XTERM_SEQ: Set G3 character set: ESC + <C> 1807 * XTERM_SEQ: Set G3 character set: ESC + <C>
1793 * See set_font_style for possible values for <C> 1808 * See set_font_style for possible values for <C>
1794 */ 1809 */
1795void 1810void
1796rxvt_term::scr_charset_set (int set, unsigned int ch) NOTHROW 1811rxvt_term::scr_charset_set (int set, unsigned int ch) noexcept
1797{ 1812{
1798 charsets[set] = (unsigned char)ch; 1813 charsets[set] = (unsigned char)ch;
1799 set_font_style (); 1814 set_font_style ();
1800} 1815}
1801 1816
1805 * ------------------------------------------------------------------------- */ 1820 * ------------------------------------------------------------------------- */
1806 1821
1807/* 1822/*
1808 * refresh matching text. 1823 * refresh matching text.
1809 */ 1824 */
1810bool 1825bool ecb_cold
1811rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) NOTHROW 1826rxvt_term::scr_refresh_rend (rend_t mask, rend_t value) noexcept
1812{ 1827{
1813 bool found = false; 1828 bool found = false;
1814 1829
1815 for (int i = 0; i < nrow; i++) 1830 for (int i = 0; i < nrow; i++)
1816 { 1831 {
1834 PART_BEG = 0, 1849 PART_BEG = 0,
1835 PART_END, 1850 PART_END,
1836 RC_COUNT 1851 RC_COUNT
1837}; 1852};
1838 1853
1839void 1854void ecb_hot
1840rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) NOTHROW 1855rxvt_term::scr_expose (int x, int y, int ewidth, int eheight, bool refresh) noexcept
1841{ 1856{
1842 int i; 1857 int i;
1843 row_col_t rc[RC_COUNT]; 1858 row_col_t rc[RC_COUNT];
1844 1859
1845 if (!drawn_buf) /* sanity check */ 1860 if (!drawn_buf) /* sanity check */
1879/* ------------------------------------------------------------------------- */ 1894/* ------------------------------------------------------------------------- */
1880/* 1895/*
1881 * Refresh the entire screen 1896 * Refresh the entire screen
1882 */ 1897 */
1883void 1898void
1884rxvt_term::scr_touch (bool refresh) NOTHROW 1899rxvt_term::scr_touch (bool refresh) noexcept
1885{ 1900{
1886 scr_expose (0, 0, vt_width, vt_height, refresh); 1901 scr_expose (0, 0, vt_width, vt_height, refresh);
1887} 1902}
1888 1903
1889/* ------------------------------------------------------------------------- */ 1904/* ------------------------------------------------------------------------- */
1890/* 1905/*
1891 * Move the display so that the line represented by scrollbar value Y is at 1906 * Move the display so that the line represented by scrollbar value Y is at
1892 * the top of the screen 1907 * the top of the screen
1893 */ 1908 */
1894void 1909void
1895rxvt_term::scr_move_to (int y, int len) NOTHROW 1910rxvt_term::scr_move_to (int y, int len) noexcept
1896{ 1911{
1897 scr_changeview ((top_row - nrow) * (len - y) / len + (nrow - 1)); 1912 // lerp (y, 0, len, top_row, nrow - 1)
1913 scr_changeview (top_row + (nrow - 1 - top_row) * y / len);
1898} 1914}
1899 1915
1900/* ------------------------------------------------------------------------- */ 1916/* ------------------------------------------------------------------------- */
1901/* 1917/*
1902 * Page the screen up/down nlines 1918 * Page the screen up/down nlines
1903 * direction should be UP or DN 1919 * direction should be UP or DN
1904 */ 1920 */
1905bool 1921bool
1906rxvt_term::scr_page (enum page_dirn direction, int nlines) NOTHROW 1922rxvt_term::scr_page (int nlines) noexcept
1907{ 1923{
1908 int new_view_start =
1909 direction == UP ? view_start - nlines
1910 : view_start + nlines;
1911
1912 return scr_changeview (new_view_start); 1924 return scr_changeview (view_start - nlines);
1913} 1925}
1914 1926
1915bool 1927bool
1916rxvt_term::scr_changeview (int new_view_start) NOTHROW 1928rxvt_term::scr_changeview (int new_view_start) noexcept
1917{ 1929{
1918 clamp_it (new_view_start, top_row, 0); 1930 clamp_it (new_view_start, top_row, 0);
1919 1931
1920 if (new_view_start == view_start) 1932 if (new_view_start == view_start)
1921 return false; 1933 return false;
1939} 1951}
1940#endif 1952#endif
1941 1953
1942/* ------------------------------------------------------------------------- */ 1954/* ------------------------------------------------------------------------- */
1943void 1955void
1944rxvt_term::scr_bell () NOTHROW 1956rxvt_term::scr_bell () noexcept
1945{ 1957{
1946#ifndef NO_BELL 1958#ifndef NO_BELL
1947 1959
1948# ifndef NO_MAPALERT 1960# ifndef NO_MAPALERT
1949# ifdef MAPALERT_OPTION 1961# ifdef MAPALERT_OPTION
1970 HOOK_INVOKE ((this, HOOK_BELL, DT_END)); 1982 HOOK_INVOKE ((this, HOOK_BELL, DT_END));
1971#endif 1983#endif
1972} 1984}
1973 1985
1974/* ------------------------------------------------------------------------- */ 1986/* ------------------------------------------------------------------------- */
1975void 1987void ecb_cold
1976rxvt_term::scr_printscreen (int fullhist) NOTHROW 1988rxvt_term::scr_printscreen (int fullhist) noexcept
1977{ 1989{
1978#ifdef PRINTPIPE 1990#ifdef PRINTPIPE
1979 int nrows, row_start; 1991 int nrows, row_start;
1980 FILE *fd = popen_printer (); 1992 FILE *fd = popen_printer ();
1981 1993
2029/* 2041/*
2030 * Refresh the screen 2042 * Refresh the screen
2031 * drawn_text/drawn_rend contain the screen information before the update. 2043 * drawn_text/drawn_rend contain the screen information before the update.
2032 * screen.text/screen.rend contain what the screen will change to. 2044 * screen.text/screen.rend contain what the screen will change to.
2033 */ 2045 */
2034void 2046void ecb_hot
2035rxvt_term::scr_refresh () NOTHROW 2047rxvt_term::scr_refresh () noexcept
2036{ 2048{
2037 int16_t col, row, /* column/row we're processing */ 2049 int16_t col, row, /* column/row we're processing */
2038 ocrow; /* old cursor row */ 2050 ocrow; /* old cursor row */
2039 int i; /* tmp */ 2051 int i; /* tmp */
2040#ifndef NO_CURSORCOLOR
2041 rend_t cc1; /* store colours at cursor position (s) */
2042#endif
2043 rend_t *crp; // cursor rendition pointer
2044 rend_t ccol1, /* Cursor colour */ 2052 rend_t ccol1, /* Cursor colour */
2045 ccol2; /* Cursor colour2 */ 2053 ccol2; /* Cursor colour2 */
2054 rend_t cur_rend;
2055 int cur_col;
2056 int cursorwidth;
2046 2057
2047 want_refresh = 0; /* screen is current */ 2058 want_refresh = 0; /* screen is current */
2048 2059
2049 if (refresh_type == NO_REFRESH || !mapped) 2060 if (refresh_type == NO_REFRESH || !mapped)
2050 return; 2061 return;
2054 */ 2065 */
2055 refresh_count = 0; 2066 refresh_count = 0;
2056 2067
2057 unsigned int old_screen_flags = screen.flags; 2068 unsigned int old_screen_flags = screen.flags;
2058 bool have_bg = 0; 2069 bool have_bg = 0;
2059#ifdef HAVE_BG_PIXMAP 2070#ifdef HAVE_IMG
2060 have_bg = bg_pixmap != None; 2071 have_bg = bg_img != 0;
2061#endif 2072#endif
2062 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ 2073 ocrow = oldcursor.row; /* is there an old outline cursor on screen? */
2063 2074
2064 /* 2075 /*
2065 * B: reverse any characters which are selected 2076 * B: reverse any characters which are selected
2075 2086
2076 /* 2087 /*
2077 * C: set the cursor character (s) 2088 * C: set the cursor character (s)
2078 */ 2089 */
2079 { 2090 {
2080 bool setoldcursor;
2081
2082#ifdef CURSOR_BLINK 2091#ifdef CURSOR_BLINK
2083 if (hidden_cursor) 2092 if (hidden_cursor)
2084 showcursor = 0; 2093 showcursor = 0;
2085#endif 2094#endif
2086 2095
2089 int col = screen.cur.col; 2098 int col = screen.cur.col;
2090 2099
2091 while (col && ROW(screen.cur.row).t[col] == NOCHAR) 2100 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2092 col--; 2101 col--;
2093 2102
2103 cursorwidth = 1;
2104 while (col + cursorwidth < ncol
2105 && ROW(screen.cur.row).t[col + cursorwidth] == NOCHAR)
2106 cursorwidth++;
2107
2094 crp = &ROW(screen.cur.row).r[col]; 2108 cur_rend = ROW(screen.cur.row).r[col];
2109 cur_col = col;
2095 2110
2096#ifndef NO_CURSORCOLOR 2111#ifndef NO_CURSORCOLOR
2097 cc1 = *crp & (RS_fgMask | RS_bgMask);
2098 if (ISSET_PIXCOLOR (Color_cursor)) 2112 if (ISSET_PIXCOLOR (Color_cursor))
2099 ccol1 = Color_cursor; 2113 ccol1 = Color_cursor;
2100 else 2114 else
2101#endif 2115#endif
2102#ifdef CURSOR_COLOR_IS_RENDITION_COLOR 2116#ifdef CURSOR_COLOR_IS_RENDITION_COLOR
2114 ccol2 = bgcolor_of (rstyle); 2128 ccol2 = bgcolor_of (rstyle);
2115#else 2129#else
2116 ccol2 = Color_bg; 2130 ccol2 = Color_bg;
2117#endif 2131#endif
2118 2132
2119 if (focus) 2133 if (focus && cursor_type == 0)
2120 { 2134 {
2121 if (option (Opt_cursorUnderline)) 2135 rend_t rend = cur_rend;
2122 *crp ^= RS_Uline; 2136
2123 else
2124 {
2125 *crp ^= RS_RVid; 2137 rend ^= RS_RVid;
2126 *crp = SET_FGCOLOR (*crp, ccol1); 2138 rend = SET_FGCOLOR (rend, ccol1);
2127 *crp = SET_BGCOLOR (*crp, ccol2); 2139 rend = SET_BGCOLOR (rend, ccol2);
2128 } 2140
2141 scr_set_char_rend (ROW(screen.cur.row), cur_col, rend);
2129 } 2142 }
2130 } 2143 }
2131 2144
2132 /* make sure no outline cursor is left around */ 2145 /* make sure no outline cursor is left around */
2133 setoldcursor = 0; 2146 if (ocrow != -1 && ocrow < nrow && oldcursor.col < ncol)
2134 if (ocrow != -1) 2147 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2148
2149 // save the current cursor coordinates if the cursor is visible
2150 // and either the window is unfocused or the cursor style is
2151 // underline or vertical bar, so as to clear the outline cursor in
2152 // the next refresh if the cursor moves or becomes invisible
2153 if (showcursor && (!focus || cursor_type != 0) && screen.cur.row - view_start < nrow)
2135 { 2154 {
2136 if (screen.cur.row - view_start != ocrow 2155 oldcursor.row = screen.cur.row - view_start;
2137 || screen.cur.col != oldcursor.col) 2156 oldcursor.col = screen.cur.col;
2138 {
2139 if (ocrow < nrow
2140 && oldcursor.col < ncol)
2141 drawn_buf[ocrow].r[oldcursor.col] ^= (RS_RVid | RS_Uline);
2142
2143 if (focus || !showcursor)
2144 oldcursor.row = -1;
2145 else
2146 setoldcursor = 1;
2147 }
2148 } 2157 }
2149 else if (!focus) 2158 else
2150 setoldcursor = 1;
2151
2152 if (setoldcursor)
2153 {
2154 if (screen.cur.row - view_start >= nrow)
2155 oldcursor.row = -1; 2159 oldcursor.row = -1;
2156 else
2157 {
2158 oldcursor.row = screen.cur.row - view_start;
2159 oldcursor.col = screen.cur.col;
2160 }
2161 }
2162 } 2160 }
2163 2161
2164#ifndef NO_SLOW_LINK_SUPPORT 2162#ifndef NO_SLOW_LINK_SUPPORT
2165 /* 2163 /*
2166 * D: CopyArea pass - very useful for slower links 2164 * D: CopyArea pass - very useful for slower links
2247 int ypixel = (int)Row2Pixel (row); 2245 int ypixel = (int)Row2Pixel (row);
2248 2246
2249 for (col = 0; col < ncol; col++) 2247 for (col = 0; col < ncol; col++)
2250 { 2248 {
2251 /* compare new text with old - if exactly the same then continue */ 2249 /* compare new text with old - if exactly the same then continue */
2252 if (stp[col] == dtp[col] /* Must match characters to skip. */ 2250 if (stp[col] == dtp[col] && RS_SAME (srp[col], drp[col]))
2253 && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */
2254 || (stp[col] == ' ' /* space w/ no background change */
2255 && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col]))))
2256 continue; 2251 continue;
2257 2252
2258 // redraw one or more characters 2253 // redraw one or more characters
2259 2254
2260 // seek to the beginning of wide characters 2255 // seek to the beginning of wide characters
2432 else 2427 else
2433 font->draw (*drawable, xpixel, ypixel, text, count, fore, back); 2428 font->draw (*drawable, xpixel, ypixel, text, count, fore, back);
2434 2429
2435 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back)) 2430 if (ecb_unlikely (rend & RS_Uline && font->descent > 1 && fore != back))
2436 { 2431 {
2432 if (showcursor && focus && row == screen.cur.row
2433 && IN_RANGE_EXC (col, cur_col, cur_col + cursorwidth))
2434 XSetForeground (dpy, gc, pix_colors[ccol1]);
2435 else
2437#if ENABLE_FRILLS 2436#if ENABLE_FRILLS
2438 if (ISSET_PIXCOLOR (Color_underline)) 2437 if (ISSET_PIXCOLOR (Color_underline))
2439 XSetForeground (dpy, gc, pix_colors[Color_underline]); 2438 XSetForeground (dpy, gc, pix_colors[Color_underline]);
2440 else 2439 else
2441#endif 2440#endif
2453 */ 2452 */
2454 if (showcursor) 2453 if (showcursor)
2455 { 2454 {
2456 if (focus) 2455 if (focus)
2457 { 2456 {
2458 if (option (Opt_cursorUnderline)) 2457 if (cursor_type == 0)
2459 *crp ^= RS_Uline; 2458 scr_set_char_rend (ROW(screen.cur.row), cur_col, cur_rend);
2460 else 2459 else if (oldcursor.row >= 0)
2461 { 2460 {
2462 *crp ^= RS_RVid; 2461 XSetForeground (dpy, gc, pix_colors[ccol1]);
2463#ifndef NO_CURSORCOLOR 2462 if (cursor_type == 1)
2464 *crp = (*crp & ~ (RS_fgMask | RS_bgMask)) | cc1; 2463 XFillRectangle (dpy, vt, gc,
2465#endif 2464 Col2Pixel (cur_col),
2465 Row2Pixel (oldcursor.row + 1) - 2,
2466 Width2Pixel (1),
2467 2);
2468 else
2469 XFillRectangle (dpy, vt, gc,
2470 Col2Pixel (cur_col),
2471 Row2Pixel (oldcursor.row),
2472 2,
2473 Height2Pixel (1));
2466 } 2474 }
2467 } 2475 }
2468 else if (oldcursor.row >= 0) 2476 else if (oldcursor.row >= 0)
2469 { 2477 {
2470 int cursorwidth = 1;
2471 int col = oldcursor.col;
2472
2473 while (col && ROW(screen.cur.row).t[col] == NOCHAR)
2474 col--;
2475
2476 while (col + cursorwidth < ncol
2477 && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR)
2478 cursorwidth++;
2479
2480#ifndef NO_CURSORCOLOR
2481 if (ISSET_PIXCOLOR (Color_cursor))
2482 XSetForeground (dpy, gc, pix_colors[Color_cursor]);
2483 else
2484#endif
2485 XSetForeground (dpy, gc, pix_colors[ccol1]); 2478 XSetForeground (dpy, gc, pix_colors[ccol1]);
2486 2479
2487 XDrawRectangle (dpy, vt, gc, 2480 XDrawRectangle (dpy, vt, gc,
2488 Col2Pixel (col), 2481 Col2Pixel (cur_col),
2489 Row2Pixel (oldcursor.row), 2482 Row2Pixel (oldcursor.row),
2490 (unsigned int) (Width2Pixel (cursorwidth) - 1), 2483 (unsigned int) (Width2Pixel (cursorwidth) - 1),
2491 (unsigned int) (Height2Pixel (1) - 1)); 2484 (unsigned int) (Height2Pixel (1) - 1));
2492 } 2485 }
2493 } 2486 }
2505 screen.flags = old_screen_flags; 2498 screen.flags = old_screen_flags;
2506 num_scr = 0; 2499 num_scr = 0;
2507 num_scr_allow = 1; 2500 num_scr_allow = 1;
2508} 2501}
2509 2502
2510void 2503void ecb_cold
2511rxvt_term::scr_remap_chars (line_t &l) NOTHROW 2504rxvt_term::scr_remap_chars (line_t &l) noexcept
2512{ 2505{
2513 if (!l.valid ()) 2506 if (!l.valid ())
2514 return; 2507 return;
2515 2508
2516 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant 2509 l.touch (); // maybe a bit of an overkill, but it's not performance-relevant
2517 2510
2518 for (int i = ncol; i--; ) 2511 for (int i = ncol; i--; )
2519 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i])); 2512 l.r[i] = SET_FONT (l.r[i], FONTSET (l.r[i])->find_font (l.t[i]));
2520} 2513}
2521 2514
2522void 2515void ecb_cold
2523rxvt_term::scr_remap_chars () NOTHROW 2516rxvt_term::scr_remap_chars () noexcept
2524{ 2517{
2525 for (int i = total_rows; i--; ) 2518 for (int i = total_rows; i--; )
2526 scr_remap_chars (row_buf [i]); 2519 scr_remap_chars (row_buf [i]);
2527 2520
2528 for (int i = nrow; i--; ) 2521 for (int i = nrow; i--; )
2530 scr_remap_chars (drawn_buf [i]); 2523 scr_remap_chars (drawn_buf [i]);
2531 scr_remap_chars (swap_buf [i]); 2524 scr_remap_chars (swap_buf [i]);
2532 } 2525 }
2533} 2526}
2534 2527
2535void 2528void ecb_cold
2536rxvt_term::scr_recolour (bool refresh) NOTHROW 2529rxvt_term::scr_recolor (bool refresh) noexcept
2537{ 2530{
2538 bool transparent = false; 2531 bool transparent = false;
2539 2532
2540#ifdef HAVE_BG_PIXMAP 2533#ifdef HAVE_IMG
2541 if (bg_pixmap != None) 2534 if (bg_img != 0)
2542 { 2535 {
2543# ifdef ENABLE_TRANSPARENCY 2536# if ENABLE_TRANSPARENCY
2544 if (bg_flags & BG_IS_TRANSPARENT) 2537 if (bg_flags & BG_IS_TRANSPARENT)
2545 { 2538 {
2546 XSetWindowBackgroundPixmap (dpy, parent, bg_pixmap); 2539 XSetWindowBackgroundPixmap (dpy, parent, bg_img->pm);
2547 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); 2540 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2548 2541
2549 transparent = true; 2542 transparent = true;
2550 } 2543 }
2551 else 2544 else
2552# endif 2545# endif
2553 { 2546 {
2554 XSetWindowBackground (dpy, parent, pix_colors[Color_border]); 2547 XSetWindowBackground (dpy, parent, pix_colors[Color_border]);
2555 XSetWindowBackgroundPixmap (dpy, vt, bg_pixmap); 2548 XSetWindowBackgroundPixmap (dpy, vt, bg_img->pm);
2556 } 2549 }
2557 } 2550 }
2558 else 2551 else
2559#endif 2552#endif
2560 { 2553 {
2562 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); 2555 XSetWindowBackground (dpy, vt, pix_colors[Color_bg]);
2563 } 2556 }
2564 2557
2565 XClearWindow (dpy, parent); 2558 XClearWindow (dpy, parent);
2566 2559
2567 if (scrollBar.win) 2560 if (scrollBar.state && scrollBar.win)
2568 { 2561 {
2569 if (transparent) 2562 if (transparent)
2570 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); 2563 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2571 else 2564 else
2572 XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); 2565 XSetWindowBackground (dpy, scrollBar.win, pix_colors[scrollBar.color ()]);
2573 scrollBar.state = SB_STATE_IDLE; 2566 scrollBar.state = SB_STATE_IDLE;
2574 scrollBar.show (0); 2567 scrollBar.show (0);
2575 } 2568 }
2576 2569
2577 if (refresh) 2570 if (refresh)
2582 want_refresh = 1; 2575 want_refresh = 1;
2583} 2576}
2584 2577
2585/* ------------------------------------------------------------------------- */ 2578/* ------------------------------------------------------------------------- */
2586void 2579void
2587rxvt_term::scr_clear (bool really) NOTHROW 2580rxvt_term::scr_clear (bool really) noexcept
2588{ 2581{
2589 if (!mapped) 2582 if (!mapped)
2590 return; 2583 return;
2591 2584
2592 num_scr_allow = 0; 2585 num_scr_allow = 0;
2595 if (really) 2588 if (really)
2596 XClearWindow (dpy, vt); 2589 XClearWindow (dpy, vt);
2597} 2590}
2598 2591
2599void 2592void
2600rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW 2593rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) noexcept
2601{ 2594{
2602 int view_end = view_start + nrow; 2595 int view_end = view_start + nrow;
2603 int row, col; 2596 int row, col;
2604 2597
2605 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++) 2598 for (row = max (beg_row, view_start); row <= min (end_row, view_end); row++)
2617 srp[col] ^= rstyle2; 2610 srp[col] ^= rstyle2;
2618 } 2611 }
2619} 2612}
2620 2613
2621void 2614void
2622rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) NOTHROW 2615rxvt_term::scr_xor_span (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle) noexcept
2623{ 2616{
2624 int view_end = view_start + nrow; 2617 int view_end = view_start + nrow;
2625 int row, col; 2618 int row, col;
2626 2619
2627 if (beg_row >= view_start) 2620 if (beg_row >= view_start)
2643 for (rend_t *srp = ROW(row).r; col < end_col; col++) 2636 for (rend_t *srp = ROW(row).r; col < end_col; col++)
2644 srp[col] ^= rstyle; 2637 srp[col] ^= rstyle;
2645} 2638}
2646 2639
2647/* ------------------------------------------------------------------------- */ 2640/* ------------------------------------------------------------------------- */
2648void 2641void ecb_hot
2649rxvt_term::scr_reverse_selection () NOTHROW 2642rxvt_term::scr_reverse_selection () noexcept
2650{ 2643{
2651 if (selection.op 2644 if (selection.op
2652 && current_screen == selection.screen 2645 && current_screen == selection.screen
2653 && selection.end.row >= view_start) 2646 && selection.end.row >= view_start)
2654 { 2647 {
2670 * Dump the whole scrollback and screen to the passed filedescriptor. The 2663 * Dump the whole scrollback and screen to the passed filedescriptor. The
2671 * invoking routine must close the fd. 2664 * invoking routine must close the fd.
2672 */ 2665 */
2673#if 0 2666#if 0
2674void 2667void
2675rxvt_term::scr_dump (int fd) NOTHROW 2668rxvt_term::scr_dump (int fd) noexcept
2676{ 2669{
2677 // if this method is needed, it can be implemented by factoring the 2670 // if this method is needed, it can be implemented by factoring the
2678 // relevant code in scr_printscreen 2671 // relevant code in scr_printscreen
2679} 2672}
2680#endif 2673#endif
2681 2674
2682/* ------------------------------------------------------------------------- * 2675/* ------------------------------------------------------------------------- *
2683 * CHARACTER SELECTION * 2676 * CHARACTER SELECTION *
2684 * ------------------------------------------------------------------------- */ 2677 * ------------------------------------------------------------------------- */
2685void 2678void
2686rxvt_term::selection_check (int check_more) NOTHROW 2679rxvt_term::selection_check (int check_more) noexcept
2687{ 2680{
2688 if (!selection.op) 2681 if (!selection.op)
2689 return; 2682 return;
2690 2683
2691 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow) 2684 if (!IN_RANGE_EXC (selection.beg.row, top_row, nrow)
2696 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) 2689 && !ROWCOL_IS_BEFORE (screen.cur, selection.beg)
2697 && ROWCOL_IS_BEFORE (screen.cur, selection.end))) 2690 && ROWCOL_IS_BEFORE (screen.cur, selection.end)))
2698 CLEAR_ALL_SELECTION (); 2691 CLEAR_ALL_SELECTION ();
2699} 2692}
2700 2693
2694void
2695rxvt_term::selection_changed () noexcept
2696{
2697 line_t &r1 = ROW (selection.beg.row);
2698 while (selection.beg.col < r1.l && r1.t [selection.beg.col] == NOCHAR)
2699 ++selection.beg.col;
2700
2701 line_t &r2 = ROW (selection.end.row);
2702 while (selection.end.col < r2.l && r2.t [selection.end.col] == NOCHAR)
2703 ++selection.end.col;
2704
2705 want_refresh = 1;
2706}
2707
2701/* ------------------------------------------------------------------------- */ 2708/* ------------------------------------------------------------------------- */
2702/* 2709/*
2703 * Paste a selection direct to the command fd 2710 * Paste a selection direct to the command fd
2704 */ 2711 */
2705void 2712void
2706rxvt_term::tt_paste (char *data, unsigned int len) NOTHROW 2713rxvt_term::tt_paste (char *data, unsigned int len) noexcept
2707{ 2714{
2708 /* convert normal newline chars into common keyboard Return key sequence */ 2715 /* convert normal newline chars into common keyboard Return key sequence */
2709 for (unsigned int i = 0; i < len; i++) 2716 for (unsigned int i = 0; i < len; i++)
2710 if (data[i] == C0_LF) 2717 if (data[i] == C0_LF)
2711 data[i] = C0_CR; 2718 data[i] = C0_CR;
2712 2719
2713 if (priv_modes & PrivMode_BracketPaste) 2720 #if ENABLE_FRILLS
2721 if ((priv_modes & PrivMode_BracketPaste) && !option (Opt_disablePasteBrackets))
2714 tt_printf ("\x1b[200~"); 2722 tt_printf ("\x1b[200~");
2723 #endif
2715 2724
2716 tt_write (data, len); 2725 tt_write (data, len);
2717 2726
2718 if (priv_modes & PrivMode_BracketPaste) 2727 #if ENABLE_FRILLS
2728 if ((priv_modes & PrivMode_BracketPaste) && !option (Opt_disablePasteBrackets))
2719 tt_printf ("\x1b[201~"); 2729 tt_printf ("\x1b[201~");
2730 #endif
2720} 2731}
2721 2732
2722void 2733void
2723rxvt_term::paste (char *data, unsigned int len) NOTHROW 2734rxvt_term::paste (char *data, unsigned int len) noexcept
2724{ 2735{
2725 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END))) 2736 if (HOOK_INVOKE ((this, HOOK_TT_PASTE, DT_STR_LEN, data, len, DT_END)))
2726 return; 2737 return;
2727 2738
2728 tt_paste (data, len); 2739 tt_paste (data, len);
2734 * if the requested selection has no owner or is empty CUT_BUFFER0 is used 2745 * if the requested selection has no owner or is empty CUT_BUFFER0 is used
2735 * as fallback 2746 * as fallback
2736 * EXT: button 2 release 2747 * EXT: button 2 release
2737 */ 2748 */
2738void 2749void
2739rxvt_term::selection_request (Time tm, int selnum) NOTHROW 2750rxvt_term::selection_request (Time tm, int selnum) noexcept
2740{ 2751{
2741 if (!selection_req) 2752 if (!selection_req)
2742 { 2753 {
2743 selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this); 2754 selection_req = new rxvt_selection (display, selnum, tm, vt, xa[XA_VT_SELECTION], this);
2744 selection_req->run (); 2755 selection_req->run ();
2749/* 2760/*
2750 * Clear all selected text 2761 * Clear all selected text
2751 * EXT: SelectionClear 2762 * EXT: SelectionClear
2752 */ 2763 */
2753void 2764void
2754rxvt_term::selection_clear (bool clipboard) NOTHROW 2765rxvt_term::selection_clear (bool clipboard) noexcept
2755{ 2766{
2756 if (!clipboard) 2767 if (!clipboard)
2757 { 2768 {
2758 want_refresh = 1; 2769 want_refresh = 1;
2759 free (selection.text); 2770 free (selection.text);
2844 if (*t == NOCHAR) 2855 if (*t == NOCHAR)
2845 t++; 2856 t++;
2846#if ENABLE_COMBINING 2857#if ENABLE_COMBINING
2847 else if (IS_COMPOSE (*t)) 2858 else if (IS_COMPOSE (*t))
2848 { 2859 {
2849 int len = rxvt_composite.expand (*t, 0); 2860 int len = rxvt_composite.expand (*t);
2850 2861
2851 extra -= (len - 1); 2862 extra -= (len - 1);
2852 2863
2853 if (extra < 0) 2864 if (extra < 0)
2854 { 2865 {
2901 2912
2902 selection_grab (tm); 2913 selection_grab (tm);
2903} 2914}
2904 2915
2905bool 2916bool
2906rxvt_term::selection_grab (Time tm, bool clipboard) NOTHROW 2917rxvt_term::selection_grab (Time tm, bool clipboard) noexcept
2907{ 2918{
2908 Atom sel; 2919 Atom sel;
2909 2920
2910 if (!clipboard) 2921 if (!clipboard)
2911 { 2922 {
2944/* ------------------------------------------------------------------------- */ 2955/* ------------------------------------------------------------------------- */
2945/* 2956/*
2946 * Mark or select text based upon number of clicks: 1, 2, or 3 2957 * Mark or select text based upon number of clicks: 1, 2, or 3
2947 * EXT: button 1 press 2958 * EXT: button 1 press
2948 */ 2959 */
2949void 2960void ecb_cold
2950rxvt_term::selection_click (int clicks, int x, int y) NOTHROW 2961rxvt_term::selection_click (int clicks, int x, int y) noexcept
2951{ 2962{
2952 clicks = ((clicks - 1) % 3) + 1; 2963 clicks = ((clicks - 1) % 3) + 1;
2953 selection.clicks = clicks; /* save clicks so extend will work */ 2964 selection.clicks = clicks; /* save clicks so extend will work */
2954 2965
2955 if (clicks == 2 && !selection.rect 2966 if (clicks == 2 && !selection.rect
2973 2984
2974/* ------------------------------------------------------------------------- */ 2985/* ------------------------------------------------------------------------- */
2975/* 2986/*
2976 * Mark a selection at the specified col/row 2987 * Mark a selection at the specified col/row
2977 */ 2988 */
2978void 2989void ecb_cold
2979rxvt_term::selection_start_colrow (int col, int row) NOTHROW 2990rxvt_term::selection_start_colrow (int col, int row) noexcept
2980{ 2991{
2981 want_refresh = 1; 2992 want_refresh = 1;
2982 2993
2983 selection.mark.row = row + view_start; 2994 selection.mark.row = row + view_start;
2984 selection.mark.col = col; 2995 selection.mark.col = col;
3006 * Word select: select text for 2 clicks 3017 * Word select: select text for 2 clicks
3007 * We now only find out the boundary in one direction 3018 * We now only find out the boundary in one direction
3008 */ 3019 */
3009 3020
3010/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */ 3021/* what do we want: spaces/tabs are delimiters or cutchars or non-cutchars */
3011#define DELIMIT_TEXT(x) \ 3022#define DELIMIT_TEXT(x) \
3012 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x))) 3023 (unicode::is_space (x) ? 2 : (x) <= 0xff && !!strchr (rs[Rs_cutchars], (x)))
3013#define DELIMIT_REND(x) 1 3024#define DELIMIT_REND(x) 1
3014 3025
3015void 3026void ecb_cold
3016rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) NOTHROW 3027rxvt_term::selection_delimit_word (enum page_dirn dirn, const row_col_t *mark, row_col_t *ret) noexcept
3017{ 3028{
3018 int col, row, dirnadd, tcol, trow, w1, w2; 3029 int col, row, dirnadd, tcol, trow, w1, w2;
3019 row_col_t bound; 3030 row_col_t bound;
3020 text_t *stp; 3031 text_t *stp;
3021 rend_t *srp; 3032 rend_t *srp;
3094 * EXT: button 3 press; button 1 or 3 drag 3105 * EXT: button 3 press; button 1 or 3 drag
3095 * flag == 0 ==> button 1 3106 * flag == 0 ==> button 1
3096 * flag == 1 ==> button 3 press 3107 * flag == 1 ==> button 3 press
3097 * flag == 2 ==> button 3 motion 3108 * flag == 2 ==> button 3 motion
3098 */ 3109 */
3099void 3110void ecb_cold
3100rxvt_term::selection_extend (int x, int y, int flag) NOTHROW 3111rxvt_term::selection_extend (int x, int y, int flag) noexcept
3101{ 3112{
3102 int col = clamp (Pixel2Col (x), 0, ncol); 3113 int col = clamp (Pixel2Col (x), 0, ncol);
3103 int row = clamp (Pixel2Row (y), 0, nrow - 1); 3114 int row = clamp (Pixel2Row (y), 0, nrow - 1);
3104 3115
3105 /* 3116 /*
3130 3141
3131/* ------------------------------------------------------------------------- */ 3142/* ------------------------------------------------------------------------- */
3132/* 3143/*
3133 * Extend the selection to the specified col/row 3144 * Extend the selection to the specified col/row
3134 */ 3145 */
3135void 3146void ecb_cold
3136rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) NOTHROW 3147rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int buttonpress, int clickchange) noexcept
3137{ 3148{
3138 row_col_t pos; 3149 row_col_t pos;
3139 enum { 3150 enum {
3140 LEFT, RIGHT 3151 LEFT, RIGHT
3141 } closeto = RIGHT; 3152 } closeto = RIGHT;
3142
3143 want_refresh = 1;
3144 3153
3145 switch (selection.op) 3154 switch (selection.op)
3146 { 3155 {
3147 case SELECTION_INIT: 3156 case SELECTION_INIT:
3148 CLEAR_SELECTION (); 3157 CLEAR_SELECTION ();
3328 3337
3329#if !ENABLE_MINIMAL 3338#if !ENABLE_MINIMAL
3330 if (selection.rect && selection.beg.col > selection.end.col) 3339 if (selection.rect && selection.beg.col > selection.end.col)
3331 ::swap (selection.beg.col, selection.end.col); 3340 ::swap (selection.beg.col, selection.end.col);
3332#endif 3341#endif
3342
3343 selection_changed ();
3333} 3344}
3334 3345
3335#if !ENABLE_MINIMAL 3346#if !ENABLE_MINIMAL
3336void 3347void ecb_cold
3337rxvt_term::selection_remove_trailing_spaces () NOTHROW 3348rxvt_term::selection_remove_trailing_spaces () noexcept
3338{ 3349{
3339 int32_t end_col, end_row; 3350 int32_t end_col, end_row;
3340 text_t *stp; 3351 text_t *stp;
3341 3352
3342 end_col = selection.end.col; 3353 end_col = selection.end.col;
3379/* ------------------------------------------------------------------------- */ 3390/* ------------------------------------------------------------------------- */
3380/* 3391/*
3381 * Double click on button 3 when already selected 3392 * Double click on button 3 when already selected
3382 * EXT: button 3 double click 3393 * EXT: button 3 double click
3383 */ 3394 */
3384void 3395void ecb_cold
3385rxvt_term::selection_rotate (int x, int y) NOTHROW 3396rxvt_term::selection_rotate (int x, int y) noexcept
3386{ 3397{
3387 selection.clicks = selection.clicks % 3 + 1; 3398 selection.clicks = selection.clicks % 3 + 1;
3388 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1); 3399 selection_extend_colrow (Pixel2Col (x), Pixel2Row (y), 1, 0, 1);
3389} 3400}
3390 3401
3391/* ------------------------------------------------------------------------- */ 3402/* ------------------------------------------------------------------------- */
3392/* 3403/*
3393 * Respond to a request for our current selection 3404 * Respond to a request for our current selection
3394 * EXT: SelectionRequest 3405 * EXT: SelectionRequest
3395 */ 3406 */
3396void 3407void ecb_cold
3397rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW 3408rxvt_term::selection_send (const XSelectionRequestEvent &rq) noexcept
3398{ 3409{
3399 Atom property = rq.property == None ? rq.target : rq.property; 3410 Atom property = rq.property == None ? rq.target : rq.property;
3400 XSelectionEvent ev; 3411 XSelectionEvent ev;
3401 3412
3402 ev.type = SelectionNotify; 3413 ev.type = SelectionNotify;
3494 cl = selection.clip_text; 3505 cl = selection.clip_text;
3495 selectlen = selection.clip_len; 3506 selectlen = selection.clip_len;
3496 } 3507 }
3497 else 3508 else
3498 { 3509 {
3499 cl = L""; 3510 cl = (wchar_t *)L"";
3500 selectlen = 0; 3511 selectlen = 0;
3501 } 3512 }
3502 3513
3503#if !ENABLE_MINIMAL 3514#if !ENABLE_MINIMAL
3504 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it 3515 // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it
3534 3545
3535 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); 3546 XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev);
3536} 3547}
3537 3548
3538/* ------------------------------------------------------------------------- */ 3549/* ------------------------------------------------------------------------- */
3539#ifdef USE_XIM 3550#if USE_XIM
3540void 3551void ecb_cold
3541rxvt_term::im_set_position (XPoint &pos) NOTHROW 3552rxvt_term::im_set_position (XPoint &pos) noexcept
3542{ 3553{
3543 XWindowAttributes xwa; 3554 XWindowAttributes xwa;
3544 3555
3545 XGetWindowAttributes (dpy, vt, &xwa); 3556 XGetWindowAttributes (dpy, vt, &xwa);
3546 3557
3549} 3560}
3550#endif 3561#endif
3551 3562
3552#if ENABLE_OVERLAY 3563#if ENABLE_OVERLAY
3553void 3564void
3554rxvt_term::scr_overlay_new (int x, int y, int w, int h) NOTHROW 3565rxvt_term::scr_overlay_new (int x, int y, int w, int h) noexcept
3555{ 3566{
3556 if (nrow < 1 || ncol < 1) 3567 if (nrow < 1 || ncol < 1)
3557 return; 3568 return;
3558 3569
3559 want_refresh = 1; 3570 want_refresh = 1;
3604 *rp = r; 3615 *rp = r;
3605 } 3616 }
3606} 3617}
3607 3618
3608void 3619void
3609rxvt_term::scr_overlay_off () NOTHROW 3620rxvt_term::scr_overlay_off () noexcept
3610{ 3621{
3611 if (!ov.text) 3622 if (!ov.text)
3612 return; 3623 return;
3613 3624
3614 want_refresh = 1; 3625 want_refresh = 1;
3622 delete [] ov.text; ov.text = 0; 3633 delete [] ov.text; ov.text = 0;
3623 delete [] ov.rend; ov.rend = 0; 3634 delete [] ov.rend; ov.rend = 0;
3624} 3635}
3625 3636
3626void 3637void
3627rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) NOTHROW 3638rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) noexcept
3628{ 3639{
3629 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2) 3640 if (!ov.text || x >= ov.w - 2 || y >= ov.h - 2)
3630 return; 3641 return;
3631 3642
3632 x++, y++; 3643 x++, y++;
3634 ov.text[y][x] = text; 3645 ov.text[y][x] = text;
3635 ov.rend[y][x] = rend; 3646 ov.rend[y][x] = rend;
3636} 3647}
3637 3648
3638void 3649void
3639rxvt_term::scr_overlay_set (int x, int y, const char *s) NOTHROW 3650rxvt_term::scr_overlay_set (int x, int y, const char *s) noexcept
3640{ 3651{
3641 while (*s) 3652 while (*s)
3642 scr_overlay_set (x++, y, *s++); 3653 scr_overlay_set (x++, y, *s++);
3643} 3654}
3644 3655
3645void 3656void
3646rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW 3657rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) noexcept
3647{ 3658{
3648 while (*s) 3659 while (*s)
3649 { 3660 {
3650 text_t t = *s++; 3661 text_t t = *s++;
3651 int width = WCWIDTH (t); 3662 int width = WCWIDTH (t);
3657 } 3668 }
3658 } 3669 }
3659} 3670}
3660 3671
3661void 3672void
3662rxvt_term::scr_swap_overlay () NOTHROW 3673rxvt_term::scr_swap_overlay () noexcept
3663{ 3674{
3664 if (!ov.text) 3675 if (!ov.text)
3665 return; 3676 return;
3666 3677
3667 // hide cursor if it is within the overlay area 3678 // hide cursor if it is within the overlay area

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines