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