1 | /*--------------------------------*-C-*--------------------------------------* |
1 | /*---------------------------------------------------------------------------* |
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-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * 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 |
9 | * 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 |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
… | |
… | |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
29 | #include "rxvtperl.h" /* NECESSARY */ |
30 | |
30 | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
|
|
32 | |
|
|
33 | #include <inttypes.h> |
31 | #include <inttypes.h> |
34 | |
32 | |
35 | #include "salloc.C" // HACK, should be a seperate compile! |
33 | #include "salloc.C" // HACK, should be a seperate compile! |
36 | |
34 | |
37 | inline void fill_text (text_t *start, text_t value, int len) |
35 | static inline void fill_text (text_t *start, text_t value, int len) |
38 | { |
36 | { |
39 | while (len--) |
37 | while (len--) |
40 | *start++ = value; |
38 | *start++ = value; |
41 | } |
39 | } |
42 | |
40 | |
… | |
… | |
47 | |
45 | |
48 | /* ------------------------------------------------------------------------- * |
46 | /* ------------------------------------------------------------------------- * |
49 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
47 | * GENERAL SCREEN AND SELECTION UPDATE ROUTINES * |
50 | * ------------------------------------------------------------------------- */ |
48 | * ------------------------------------------------------------------------- */ |
51 | #define ZERO_SCROLLBACK() \ |
49 | #define ZERO_SCROLLBACK() \ |
52 | if (OPTION (Opt_scrollTtyOutput)) \ |
50 | if (option (Opt_scrollTtyOutput)) \ |
53 | view_start = 0 |
51 | view_start = 0 |
54 | #define CLEAR_SELECTION() \ |
52 | #define CLEAR_SELECTION() \ |
55 | selection.beg.row = selection.beg.col \ |
53 | selection.beg.row = selection.beg.col \ |
56 | = selection.end.row = selection.end.col = 0 |
54 | = selection.end.row = selection.end.col = 0 |
57 | #define CLEAR_ALL_SELECTION() \ |
55 | #define CLEAR_ALL_SELECTION() \ |
… | |
… | |
85 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
83 | ROW_AND_COL_IN_ROW_AT_OR_AFTER ((X).row, (X).col, (Y).row, (Y).col) |
86 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
84 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
87 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
85 | ROW_AND_COL_IN_ROW_AT_OR_BEFORE ((X).row, (X).col, (Y).row, (Y).col) |
88 | |
86 | |
89 | /* |
87 | /* |
90 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
|
|
91 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
88 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
92 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
|
|
93 | */ |
89 | */ |
94 | #define drawBuffer vt |
|
|
95 | |
|
|
96 | #define CLEAR_ROWS(row, num) \ |
|
|
97 | if (mapped) \ |
|
|
98 | XClearArea (display->display, drawBuffer, 0, \ |
|
|
99 | Row2Pixel (row), (unsigned int)width, \ |
|
|
100 | (unsigned int)Height2Pixel (num), False) |
|
|
101 | |
|
|
102 | #define CLEAR_CHARS(x, y, num) \ |
90 | #define CLEAR_CHARS(x, y, num) \ |
103 | if (mapped) \ |
91 | if (mapped) \ |
104 | XClearArea (display->display, drawBuffer, x, y, \ |
92 | XClearArea (dpy, vt, x, y, \ |
105 | (unsigned int)Width2Pixel (num), \ |
93 | (unsigned int)Width2Pixel (num), \ |
106 | (unsigned int)Height2Pixel (1), False) |
94 | (unsigned int)Height2Pixel (1), False) |
107 | |
|
|
108 | #define ERASE_ROWS(row, num) \ |
|
|
109 | XFillRectangle (display->display, drawBuffer, gc, \ |
|
|
110 | 0, Row2Pixel (row), \ |
|
|
111 | (unsigned int)width, \ |
|
|
112 | (unsigned int)Height2Pixel (num)) |
|
|
113 | |
95 | |
114 | /* ------------------------------------------------------------------------- * |
96 | /* ------------------------------------------------------------------------- * |
115 | * SCREEN `COMMON' ROUTINES * |
97 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
98 | * ------------------------------------------------------------------------- */ |
117 | |
99 | |
… | |
… | |
126 | width = ncol; |
108 | width = ncol; |
127 | } |
109 | } |
128 | |
110 | |
129 | l.touch (); |
111 | l.touch (); |
130 | |
112 | |
131 | efs &= ~RS_baseattrMask; |
113 | efs &= ~RS_baseattrMask; // remove italic etc. fontstyles |
132 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
114 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
133 | |
115 | |
134 | text_t *et = l.t + col; |
116 | text_t *et = l.t + col; |
135 | rend_t *er = l.r + col; |
117 | rend_t *er = l.r + col; |
136 | |
118 | |
… | |
… | |
161 | { |
143 | { |
162 | #if ENABLE_OVERLAY |
144 | #if ENABLE_OVERLAY |
163 | scr_overlay_off (); |
145 | scr_overlay_off (); |
164 | #endif |
146 | #endif |
165 | |
147 | |
|
|
148 | rvideo_mode = false; |
166 | view_start = 0; |
149 | view_start = 0; |
167 | num_scr = 0; |
150 | num_scr = 0; |
168 | |
151 | |
169 | if (ncol == 0) |
152 | if (ncol == 0) |
170 | ncol = 80; |
153 | ncol = 80; |
… | |
… | |
237 | selection.text = NULL; |
220 | selection.text = NULL; |
238 | selection.len = 0; |
221 | selection.len = 0; |
239 | selection.op = SELECTION_CLEAR; |
222 | selection.op = SELECTION_CLEAR; |
240 | selection.screen = PRIMARY; |
223 | selection.screen = PRIMARY; |
241 | selection.clicks = 0; |
224 | selection.clicks = 0; |
242 | rvideo_state = rvideo_mode = false; |
|
|
243 | } |
225 | } |
244 | else |
226 | else |
245 | { |
227 | { |
246 | /* |
228 | /* |
247 | * add or delete rows as appropriate |
229 | * add or delete rows as appropriate |
… | |
… | |
276 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
258 | drawn_buf[row].clear (); scr_blank_screen_mem (drawn_buf[row], DEFAULT_RSTYLE); |
277 | } |
259 | } |
278 | |
260 | |
279 | line_t *old_buf = row_buf; |
261 | line_t *old_buf = row_buf; |
280 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
262 | row_buf = (line_t *)rxvt_calloc (total_rows + nrow, sizeof (line_t)); |
281 | |
263 | |
282 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
264 | int p = MOD (term_start + prev_nrow, prev_total_rows); // previous row |
283 | int pend = MOD (term_start + top_row , prev_total_rows); |
265 | int pend = MOD (term_start + top_row , prev_total_rows); |
284 | int q = total_rows; // rewrapped row |
266 | int q = total_rows; // rewrapped row |
285 | |
267 | |
286 | if (top_row) |
268 | if (top_row) |
… | |
… | |
330 | int qcol = 0; |
312 | int qcol = 0; |
331 | |
313 | |
332 | // see below for cursor adjustment rationale |
314 | // see below for cursor adjustment rationale |
333 | if (p == ocur.row) |
315 | if (p == ocur.row) |
334 | screen.cur.row = q - (total_rows - nrow); |
316 | screen.cur.row = q - (total_rows - nrow); |
335 | |
317 | |
336 | // fill a single destination line |
318 | // fill a single destination line |
337 | while (lofs < llen && qcol < ncol) |
319 | while (lofs < llen && qcol < ncol) |
338 | { |
320 | { |
339 | int prow = lofs / prev_ncol; |
321 | int prow = lofs / prev_ncol; |
340 | int pcol = lofs % prev_ncol; |
322 | int pcol = lofs % prev_ncol; |
… | |
… | |
366 | } |
348 | } |
367 | while (p != pend && q > 0); |
349 | while (p != pend && q > 0); |
368 | |
350 | |
369 | term_start = total_rows - nrow; |
351 | term_start = total_rows - nrow; |
370 | top_row = q - term_start; |
352 | top_row = q - term_start; |
371 | |
353 | |
372 | // make sure all terminal lines exist |
354 | // make sure all terminal lines exist |
373 | while (top_row > 0) |
355 | while (top_row > 0) |
374 | scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); |
356 | scr_blank_screen_mem (ROW (--top_row), DEFAULT_RSTYLE); |
375 | } |
357 | } |
376 | else |
358 | else |
377 | { |
359 | { |
378 | // if no scrollback exists (yet), wing, instead of wrap |
360 | // if no scrollback exists (yet), wing, instead of wrap |
379 | |
361 | |
380 | for (int row = min (nrow, prev_nrow); row--; ) |
362 | for (int row = min (nrow, prev_nrow); row--; ) |
381 | { |
363 | { |
382 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
364 | line_t &pline = old_buf [MOD (term_start + row, prev_total_rows)]; |
383 | line_t &qline = row_buf [row]; |
365 | line_t &qline = row_buf [row]; |
384 | |
366 | |
… | |
… | |
407 | CLEAR_ALL_SELECTION (); |
389 | CLEAR_ALL_SELECTION (); |
408 | |
390 | |
409 | prev_nrow = nrow; |
391 | prev_nrow = nrow; |
410 | prev_ncol = ncol; |
392 | prev_ncol = ncol; |
411 | |
393 | |
412 | tabs = (char *)rxvt_malloc (ncol * sizeof (char)); |
394 | tabs = (char *)rxvt_malloc (ncol); |
413 | |
395 | |
414 | for (int col = ncol; col--; ) |
396 | for (int col = ncol; --col; ) |
415 | tabs [col] = col % TABSIZE == 0; |
397 | tabs [col] = col % TABSIZE == 0; |
416 | |
398 | |
417 | if (current_screen != PRIMARY) |
399 | if (current_screen != PRIMARY) |
418 | scr_swap_screen (); |
400 | scr_swap_screen (); |
419 | |
401 | |
… | |
… | |
510 | } |
492 | } |
511 | |
493 | |
512 | void |
494 | void |
513 | rxvt_term::scr_swap_screen () |
495 | rxvt_term::scr_swap_screen () |
514 | { |
496 | { |
515 | if (!OPTION (Opt_secondaryScreen)) |
497 | if (!option (Opt_secondaryScreen)) |
516 | return; |
498 | return; |
517 | |
499 | |
518 | for (int i = prev_nrow; i--; ) |
500 | for (int i = prev_nrow; i--; ) |
519 | ::swap (ROW(i), swap_buf [i]); |
501 | ::swap (ROW(i), swap_buf [i]); |
520 | |
502 | |
… | |
… | |
542 | selection_check (2); /* check for boundary cross */ |
524 | selection_check (2); /* check for boundary cross */ |
543 | |
525 | |
544 | int i = current_screen; current_screen = scrn; scrn = i; |
526 | int i = current_screen; current_screen = scrn; scrn = i; |
545 | |
527 | |
546 | #if NSCREENS |
528 | #if NSCREENS |
547 | if (OPTION (Opt_secondaryScreen)) |
529 | if (option (Opt_secondaryScreen)) |
548 | { |
530 | { |
549 | num_scr = 0; |
531 | num_scr = 0; |
550 | |
532 | |
551 | scr_swap_screen (); |
533 | scr_swap_screen (); |
552 | |
534 | |
… | |
… | |
555 | screen.flags |= Screen_VisibleCursor; |
537 | screen.flags |= Screen_VisibleCursor; |
556 | swap.flags |= Screen_VisibleCursor; |
538 | swap.flags |= Screen_VisibleCursor; |
557 | } |
539 | } |
558 | else |
540 | else |
559 | #endif |
541 | #endif |
560 | if (OPTION (Opt_secondaryScroll)) |
542 | if (option (Opt_secondaryScroll)) |
561 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
543 | scr_scroll_text (0, prev_nrow - 1, prev_nrow); |
562 | } |
544 | } |
563 | |
545 | |
564 | // clear WrapNext indicator, solidifying position on next line |
546 | // clear WrapNext indicator, solidifying position on next line |
565 | void |
547 | void |
… | |
… | |
598 | /* |
580 | /* |
599 | * Change the rendition style for following text |
581 | * Change the rendition style for following text |
600 | */ |
582 | */ |
601 | void |
583 | void |
602 | rxvt_term::scr_rendition (int set, int style) NOTHROW |
584 | rxvt_term::scr_rendition (int set, int style) NOTHROW |
603 | { |
585 | { |
604 | if (set) |
586 | if (set) |
605 | rstyle |= style; |
587 | rstyle |= style; |
606 | else if (style == ~RS_None) |
588 | else if (style == ~RS_None) |
607 | rstyle = DEFAULT_RSTYLE; |
589 | rstyle = DEFAULT_RSTYLE; |
608 | else |
590 | else |
609 | rstyle &= ~style; |
591 | rstyle &= ~style; |
610 | } |
592 | } |
611 | |
593 | |
612 | /* ------------------------------------------------------------------------- */ |
594 | /* ------------------------------------------------------------------------- */ |
613 | /* |
595 | /* |
614 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
596 | * Scroll text between <row1> and <row2> inclusive, by <count> lines |
615 | * count positive ==> scroll up |
597 | * count positive ==> scroll up |
… | |
… | |
624 | want_refresh = 1; |
606 | want_refresh = 1; |
625 | num_scr += count; |
607 | num_scr += count; |
626 | |
608 | |
627 | if (count > 0 |
609 | if (count > 0 |
628 | && row1 == 0 |
610 | && row1 == 0 |
629 | && (current_screen == PRIMARY || OPTION (Opt_secondaryScroll))) |
611 | && (current_screen == PRIMARY || option (Opt_secondaryScroll))) |
630 | { |
612 | { |
631 | top_row = max (top_row - count, -saveLines); |
613 | top_row = max (top_row - count, -saveLines); |
632 | |
614 | |
633 | // scroll everything up 'count' lines |
615 | // scroll everything up 'count' lines |
634 | term_start = (term_start + count) % total_rows; |
616 | term_start = (term_start + count) % total_rows; |
… | |
… | |
641 | } |
623 | } |
642 | |
624 | |
643 | // erase newly scrolled-in lines |
625 | // erase newly scrolled-in lines |
644 | for (int i = count; i--; ) |
626 | for (int i = count; i--; ) |
645 | { |
627 | { |
646 | // basically this is a slightly optimized scr_blank_screen_mem |
|
|
647 | // it is worth the effort on slower machines |
|
|
648 | line_t &l = ROW(nrow - 1 - i); |
628 | line_t &l = ROW(nrow - 1 - i); |
649 | |
629 | |
|
|
630 | // optimize if already cleared, can be significant on slow machines |
|
|
631 | // could be rolled into scr_blank_screen_mem |
|
|
632 | if (l.r && l.l < ncol - 1 && !((l.r[l.l + 1] ^ rstyle) & (RS_fgMask | RS_bgMask))) |
|
|
633 | { |
650 | scr_blank_line (l, 0, l.l, rstyle); |
634 | scr_blank_line (l, 0, l.l, rstyle); |
651 | |
|
|
652 | l.l = 0; |
635 | l.l = 0; |
653 | l.f = 0; |
636 | l.f = 0; |
|
|
637 | } |
|
|
638 | else |
|
|
639 | scr_blank_screen_mem (l, rstyle); |
654 | } |
640 | } |
655 | |
641 | |
656 | // now copy lines below the scroll region bottom to the |
642 | // now copy lines below the scroll region bottom to the |
657 | // bottom of the screen again, so they look as if they |
643 | // bottom of the screen again, so they look as if they |
658 | // hadn't moved. |
644 | // hadn't moved. |
… | |
… | |
662 | line_t &l2 = ROW(i); |
648 | line_t &l2 = ROW(i); |
663 | |
649 | |
664 | ::swap (l1, l2); |
650 | ::swap (l1, l2); |
665 | l2.touch (); |
651 | l2.touch (); |
666 | } |
652 | } |
667 | |
653 | |
668 | // move and/or clear selection, if any |
654 | // move and/or clear selection, if any |
669 | if (selection.op && current_screen == selection.screen) |
655 | if (selection.op && current_screen == selection.screen) |
670 | { |
656 | { |
671 | selection.beg.row -= count; |
657 | selection.beg.row -= count; |
672 | selection.end.row -= count; |
658 | selection.end.row -= count; |
… | |
… | |
680 | selection.op = SELECTION_CLEAR; |
666 | selection.op = SELECTION_CLEAR; |
681 | } |
667 | } |
682 | } |
668 | } |
683 | |
669 | |
684 | // finally move the view window, if desired |
670 | // finally move the view window, if desired |
685 | if (OPTION (Opt_scrollWithBuffer) |
671 | if (option (Opt_scrollWithBuffer) |
686 | && view_start != 0 |
672 | && view_start != 0 |
687 | && view_start != -saveLines) |
673 | && view_start != -saveLines) |
688 | scr_page (UP, count); |
674 | scr_page (UP, count); |
689 | |
675 | |
690 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
676 | if (SHOULD_INVOKE (HOOK_SCROLL_BACK)) |
… | |
… | |
708 | { |
694 | { |
709 | /* move selected region too */ |
695 | /* move selected region too */ |
710 | selection.beg.row -= count; |
696 | selection.beg.row -= count; |
711 | selection.end.row -= count; |
697 | selection.end.row -= count; |
712 | selection.mark.row -= count; |
698 | selection.mark.row -= count; |
713 | |
699 | |
714 | selection_check (0); |
700 | selection_check (0); |
715 | } |
701 | } |
716 | } |
702 | } |
717 | |
703 | |
718 | // use a simple and robust scrolling algorithm, this |
704 | // use a simple and robust scrolling algorithm, this |
… | |
… | |
785 | |
771 | |
786 | while (str < strend) |
772 | while (str < strend) |
787 | { |
773 | { |
788 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
774 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
789 | |
775 | |
790 | if (c < 0x20) |
776 | if (expect_false (c < 0x20)) |
791 | if (c == C0_LF) |
777 | if (c == C0_LF) |
792 | { |
778 | { |
793 | max_it (line->l, screen.cur.col); |
779 | max_it (line->l, screen.cur.col); |
794 | |
780 | |
795 | screen.flags &= ~Screen_WrapNext; |
781 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
814 | { |
800 | { |
815 | scr_tab (1, true); |
801 | scr_tab (1, true); |
816 | continue; |
802 | continue; |
817 | } |
803 | } |
818 | |
804 | |
|
|
805 | if (expect_false ( |
819 | if (checksel /* see if we're writing within selection */ |
806 | checksel /* see if we're writing within selection */ |
820 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
807 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
821 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
808 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
|
|
809 | )) |
822 | { |
810 | { |
823 | checksel = 0; |
811 | checksel = 0; |
824 | /* |
812 | /* |
825 | * If we wrote anywhere in the selected area, kill the selection |
813 | * If we wrote anywhere in the selected area, kill the selection |
826 | * XXX: should we kill the mark too? Possibly, but maybe that |
814 | * XXX: should we kill the mark too? Possibly, but maybe that |
827 | * should be a similar check. |
815 | * should be a similar check. |
828 | */ |
816 | */ |
829 | CLEAR_SELECTION (); |
817 | CLEAR_SELECTION (); |
830 | } |
818 | } |
831 | |
819 | |
832 | if (screen.flags & Screen_WrapNext) |
820 | if (expect_false (screen.flags & Screen_WrapNext)) |
833 | { |
821 | { |
834 | scr_do_wrap (); |
822 | scr_do_wrap (); |
835 | |
823 | |
836 | line->l = ncol; |
824 | line->l = ncol; |
837 | line->is_longer (1); |
825 | line->is_longer (1); |
838 | |
826 | |
839 | row = screen.cur.row; |
827 | row = screen.cur.row; |
840 | line = &ROW(row); /* _must_ refresh */ |
828 | line = &ROW(row); /* _must_ refresh */ |
841 | } |
829 | } |
842 | |
830 | |
843 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
831 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
844 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
832 | if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
845 | c = 0xfffd; |
833 | c = 0xfffd; |
846 | |
834 | |
847 | // rely on wcwidth to tell us the character width, at least for non-latin1 |
835 | // rely on wcwidth to tell us the character width, do wcwidth before |
848 | // do wcwidth before further replacements, as wcwidth might return -1 |
836 | // further replacements, as wcwidth might return -1 for the line |
849 | // for the line drawing characters below as they might be invalid in the current |
837 | // drawing characters below as they might be invalid in the current |
850 | // locale. |
838 | // locale. |
851 | int width = c < 0x100 ? 1 : wcwidth (c); |
839 | int width = WCWIDTH (c); |
852 | |
840 | |
853 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
841 | if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL |
854 | { |
842 | { |
855 | // vt100 special graphics and line drawing |
843 | // vt100 special graphics and line drawing |
856 | // 5f-7e standard vt100 |
844 | // 5f-7e standard vt100 |
857 | // 40-5e rxvt extension for extra curses acs chars |
845 | // 40-5e rxvt extension for extra curses acs chars |
858 | static uint16_t vt100_0[62] = { // 41 .. 7e |
846 | static uint16_t vt100_0[62] = { // 41 .. 7e |
… | |
… | |
871 | c = vt100_0[c - 0x41]; |
859 | c = vt100_0[c - 0x41]; |
872 | width = 1; // vt100 line drawing characters are always single-width |
860 | width = 1; // vt100 line drawing characters are always single-width |
873 | } |
861 | } |
874 | } |
862 | } |
875 | |
863 | |
876 | if (screen.flags & Screen_Insert) |
864 | if (expect_false (screen.flags & Screen_Insert)) |
877 | scr_insdel_chars (width, INSERT); |
865 | scr_insdel_chars (width, INSERT); |
878 | |
866 | |
879 | if (width != 0) |
867 | if (width != 0) |
880 | { |
868 | { |
881 | #if !UNICODE_3 |
869 | #if !UNICODE_3 |
… | |
… | |
887 | c = 0xfffd; |
875 | c = 0xfffd; |
888 | # endif |
876 | # endif |
889 | #endif |
877 | #endif |
890 | |
878 | |
891 | // nuke the character at this position, if required |
879 | // nuke the character at this position, if required |
|
|
880 | if (expect_false ( |
892 | if (line->t[screen.cur.col] == NOCHAR |
881 | line->t[screen.cur.col] == NOCHAR |
893 | || (screen.cur.col < ncol - 1 |
882 | || (screen.cur.col < ncol - 1 |
894 | && line->t[screen.cur.col + 1] == NOCHAR)) |
883 | && line->t[screen.cur.col + 1] == NOCHAR) |
|
|
884 | )) |
895 | { |
885 | { |
896 | int col = screen.cur.col; |
886 | int col = screen.cur.col; |
897 | |
887 | |
898 | // find begin |
888 | // find begin |
899 | while (col > 0 && line->t[col] == NOCHAR) |
889 | while (col > 0 && line->t[col] == NOCHAR) |
… | |
… | |
910 | } |
900 | } |
911 | |
901 | |
912 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
902 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
913 | |
903 | |
914 | // if the character doesn't fit into the remaining columns... |
904 | // if the character doesn't fit into the remaining columns... |
915 | if (screen.cur.col > ncol - width && ncol >= width) |
905 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
916 | { |
906 | { |
917 | // ...output spaces |
907 | // ...output spaces |
918 | c = ' '; |
908 | c = ' '; |
919 | // and try the same character next loop iteration |
909 | // and try the same character next loop iteration |
920 | --str; |
910 | --str; |
… | |
… | |
925 | do |
915 | do |
926 | { |
916 | { |
927 | line->t[screen.cur.col] = c; |
917 | line->t[screen.cur.col] = c; |
928 | line->r[screen.cur.col] = rend; |
918 | line->r[screen.cur.col] = rend; |
929 | |
919 | |
930 | if (screen.cur.col < ncol - 1) |
920 | if (expect_true (screen.cur.col < ncol - 1)) |
931 | screen.cur.col++; |
921 | screen.cur.col++; |
932 | else |
922 | else |
933 | { |
923 | { |
934 | line->l = ncol; |
924 | line->l = ncol; |
935 | if (screen.flags & Screen_Autowrap) |
925 | if (screen.flags & Screen_Autowrap) |
… | |
… | |
937 | break; |
927 | break; |
938 | } |
928 | } |
939 | |
929 | |
940 | c = NOCHAR; |
930 | c = NOCHAR; |
941 | } |
931 | } |
942 | while (--width > 0); |
932 | while (expect_false (--width > 0)); |
943 | |
933 | |
944 | // pad with spaces when overwriting wide character with smaller one |
934 | // pad with spaces when overwriting wide character with smaller one |
945 | if (!width) |
935 | if (expect_false (!width)) |
946 | { |
936 | { |
947 | line->touch (); |
937 | line->touch (); |
948 | |
938 | |
949 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
939 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
950 | { |
940 | { |
951 | line->t[c] = ' '; |
941 | line->t[c] = ' '; |
952 | line->r[c] = rend; |
942 | line->r[c] = rend; |
953 | } |
943 | } |
954 | } |
944 | } |
955 | } |
945 | } |
|
|
946 | #if ENABLE_COMBINING |
956 | else // width == 0 |
947 | else // width == 0 |
957 | { |
948 | { |
958 | #if ENABLE_COMBINING |
949 | if (c != 0xfeff) // ignore BOM |
959 | // handle combining characters |
|
|
960 | // we just tag the accent on the previous on-screen character. |
|
|
961 | // this is arguably not correct, but also arguably not wrong. |
|
|
962 | // we don't handle double-width characters nicely yet. |
|
|
963 | line_t *linep; |
|
|
964 | text_t *tp; |
|
|
965 | rend_t *rp; |
|
|
966 | |
|
|
967 | if (screen.cur.col > 0) |
|
|
968 | { |
950 | { |
|
|
951 | // handle combining characters |
|
|
952 | // we just tag the accent on the previous on-screen character. |
|
|
953 | // this is arguably not correct, but also arguably not wrong. |
|
|
954 | // we don't handle double-width characters nicely yet. |
|
|
955 | line_t *linep; |
|
|
956 | text_t *tp; |
|
|
957 | rend_t *rp; |
|
|
958 | |
|
|
959 | if (screen.cur.col > 0) |
|
|
960 | { |
969 | linep = line; |
961 | linep = line; |
970 | tp = line->t + screen.cur.col - 1; |
962 | tp = line->t + screen.cur.col - 1; |
971 | rp = line->r + screen.cur.col - 1; |
963 | rp = line->r + screen.cur.col - 1; |
|
|
964 | } |
|
|
965 | else if (screen.cur.row > 0 |
|
|
966 | && ROW(screen.cur.row - 1).is_longer ()) |
|
|
967 | { |
|
|
968 | linep = &ROW(screen.cur.row - 1); |
|
|
969 | tp = line->t + ncol - 1; |
|
|
970 | rp = line->r + ncol - 1; |
|
|
971 | } |
|
|
972 | else |
|
|
973 | continue; |
|
|
974 | |
|
|
975 | linep->touch (); |
|
|
976 | |
|
|
977 | while (*tp == NOCHAR && tp > linep->t) |
|
|
978 | tp--, rp--; |
|
|
979 | |
|
|
980 | // first try to find a precomposed character |
|
|
981 | unicode_t n = rxvt_compose (*tp, c); |
|
|
982 | if (n == NOCHAR) |
|
|
983 | n = rxvt_composite.compose (*tp, c); |
|
|
984 | |
|
|
985 | *tp = n; |
|
|
986 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
972 | } |
987 | } |
973 | else if (screen.cur.row > 0 |
|
|
974 | && ROW(screen.cur.row - 1).is_longer ()) |
|
|
975 | { |
|
|
976 | linep = &ROW(screen.cur.row - 1); |
|
|
977 | tp = line->t + ncol - 1; |
|
|
978 | rp = line->r + ncol - 1; |
|
|
979 | } |
988 | } |
980 | else |
|
|
981 | continue; |
|
|
982 | |
|
|
983 | linep->touch (); |
|
|
984 | |
|
|
985 | while (*tp == NOCHAR && tp > linep->t) |
|
|
986 | tp--, rp--; |
|
|
987 | |
|
|
988 | // first try to find a precomposed character |
|
|
989 | unicode_t n = rxvt_compose (*tp, c); |
|
|
990 | if (n == NOCHAR) |
|
|
991 | n = rxvt_composite.compose (*tp, c); |
|
|
992 | |
|
|
993 | *tp = n; |
|
|
994 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
|
|
995 | #endif |
989 | #endif |
996 | } |
|
|
997 | } |
990 | } |
998 | |
991 | |
999 | max_it (line->l, screen.cur.col); |
992 | max_it (line->l, screen.cur.col); |
1000 | |
993 | |
1001 | #ifdef DEBUG_STRICT |
994 | #ifdef DEBUG_STRICT |
… | |
… | |
1009 | * XTERM_SEQ: CTRL-H |
1002 | * XTERM_SEQ: CTRL-H |
1010 | */ |
1003 | */ |
1011 | void |
1004 | void |
1012 | rxvt_term::scr_backspace () NOTHROW |
1005 | rxvt_term::scr_backspace () NOTHROW |
1013 | { |
1006 | { |
1014 | want_refresh = 1; |
|
|
1015 | |
|
|
1016 | if (screen.cur.col == 0) |
1007 | if (screen.cur.col == 0) |
1017 | { |
1008 | { |
1018 | if (screen.cur.row > 0) |
1009 | if (screen.cur.row > 0) |
1019 | { |
1010 | { |
1020 | #ifdef TERMCAP_HAS_BW |
1011 | #ifdef TERMCAP_HAS_BW |
1021 | screen.cur.col = ncol - 1; |
1012 | screen.cur.col = ncol - 1; |
1022 | screen.cur.row--; |
1013 | --screen.cur.row; |
1023 | return; |
1014 | |
|
|
1015 | want_refresh = 1; |
1024 | #endif |
1016 | #endif |
1025 | } |
1017 | } |
1026 | } |
1018 | } |
1027 | else if (!(screen.flags & Screen_WrapNext)) |
1019 | else |
1028 | scr_gotorc (0, -1, RELATIVE); |
1020 | scr_gotorc (0, -1, RELATIVE); |
1029 | |
|
|
1030 | screen.flags &= ~Screen_WrapNext; |
|
|
1031 | } |
1021 | } |
1032 | |
1022 | |
1033 | /* ------------------------------------------------------------------------- */ |
1023 | /* ------------------------------------------------------------------------- */ |
1034 | /* |
1024 | /* |
1035 | * Process Horizontal Tab |
1025 | * Process Horizontal Tab |
… | |
… | |
1058 | x = i; |
1048 | x = i; |
1059 | |
1049 | |
1060 | if (!--count) |
1050 | if (!--count) |
1061 | break; |
1051 | break; |
1062 | } |
1052 | } |
1063 | else |
1053 | else |
1064 | ht &= l.t[i] == ' ' |
1054 | ht &= l.t[i] == ' ' |
1065 | && RS_SAME (l.r[i], base_rend); |
1055 | && RS_SAME (l.r[i], base_rend); |
1066 | |
1056 | |
1067 | if (count) |
1057 | if (count) |
1068 | x = ncol - 1; |
1058 | x = ncol - 1; |
1069 | |
1059 | |
1070 | // store horizontal tab commands as characters inside the text |
1060 | // store horizontal tab commands as characters inside the text |
1071 | // buffer so they can be selected and pasted. |
1061 | // buffer so they can be selected and pasted. |
1072 | if (ht && OPTION (Opt_pastableTabs)) |
1062 | if (ht && option (Opt_pastableTabs)) |
1073 | { |
1063 | { |
1074 | base_rend = SET_FONT (base_rend, 0); |
1064 | base_rend = SET_FONT (base_rend, 0); |
1075 | |
1065 | |
1076 | l.touch (x); |
1066 | l.touch (x); |
1077 | |
1067 | |
… | |
… | |
1110 | * Process DEC Back Index |
1100 | * Process DEC Back Index |
1111 | * XTERM_SEQ: ESC 6 |
1101 | * XTERM_SEQ: ESC 6 |
1112 | * Move cursor left in row. If we're at the left boundary, shift everything |
1102 | * Move cursor left in row. If we're at the left boundary, shift everything |
1113 | * in that row right. Clear left column. |
1103 | * in that row right. Clear left column. |
1114 | */ |
1104 | */ |
1115 | #if ENABLE_FRILLS |
1105 | #if !ENABLE_MINIMAL |
1116 | void |
1106 | void |
1117 | rxvt_term::scr_backindex () NOTHROW |
1107 | rxvt_term::scr_backindex () NOTHROW |
1118 | { |
1108 | { |
1119 | if (screen.cur.col > 0) |
1109 | if (screen.cur.col > 0) |
1120 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
1110 | scr_gotorc (0, -1, R_RELATIVE | C_RELATIVE); |
… | |
… | |
1127 | * Process DEC Forward Index |
1117 | * Process DEC Forward Index |
1128 | * XTERM_SEQ: ESC 9 |
1118 | * XTERM_SEQ: ESC 9 |
1129 | * Move cursor right in row. If we're at the right boundary, shift everything |
1119 | * Move cursor right in row. If we're at the right boundary, shift everything |
1130 | * in that row left. Clear right column. |
1120 | * in that row left. Clear right column. |
1131 | */ |
1121 | */ |
1132 | #if ENABLE_FRILLS |
1122 | #if !ENABLE_MINIMAL |
1133 | void |
1123 | void |
1134 | rxvt_term::scr_forwardindex () NOTHROW |
1124 | rxvt_term::scr_forwardindex () NOTHROW |
1135 | { |
1125 | { |
1136 | if (screen.cur.col < ncol - 1) |
1126 | if (screen.cur.col < ncol - 1) |
1137 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
1127 | scr_gotorc (0, 1, R_RELATIVE | C_RELATIVE); |
… | |
… | |
1184 | } |
1174 | } |
1185 | } |
1175 | } |
1186 | else |
1176 | else |
1187 | { |
1177 | { |
1188 | if (screen.flags & Screen_Relative) |
1178 | if (screen.flags & Screen_Relative) |
|
|
1179 | { |
1189 | { /* relative origin mode */ |
1180 | /* relative origin mode */ |
1190 | screen.cur.row = row + screen.tscroll; |
1181 | screen.cur.row = row + screen.tscroll; |
1191 | min_it (screen.cur.row, screen.bscroll); |
1182 | min_it (screen.cur.row, screen.bscroll); |
1192 | } |
1183 | } |
1193 | else |
1184 | else |
1194 | screen.cur.row = row; |
1185 | screen.cur.row = row; |
… | |
… | |
1227 | /* |
1218 | /* |
1228 | * Erase part or whole of a line |
1219 | * Erase part or whole of a line |
1229 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1220 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1230 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1221 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1231 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1222 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
|
|
1223 | * extension: clear to right unless wrapped: ESC [ 3 K |
1232 | */ |
1224 | */ |
1233 | void |
1225 | void |
1234 | rxvt_term::scr_erase_line (int mode) NOTHROW |
1226 | rxvt_term::scr_erase_line (int mode) NOTHROW |
1235 | { |
1227 | { |
1236 | unsigned int col, num; |
1228 | unsigned int col, num; |
… | |
… | |
1245 | line.touch (); |
1237 | line.touch (); |
1246 | line.is_longer (0); |
1238 | line.is_longer (0); |
1247 | |
1239 | |
1248 | switch (mode) |
1240 | switch (mode) |
1249 | { |
1241 | { |
|
|
1242 | case 3: |
|
|
1243 | if (screen.flags & Screen_WrapNext) |
|
|
1244 | return; |
|
|
1245 | |
|
|
1246 | /* fall through */ |
|
|
1247 | |
1250 | case 0: /* erase to end of line */ |
1248 | case 0: /* erase to end of line */ |
1251 | col = screen.cur.col; |
1249 | col = screen.cur.col; |
1252 | num = ncol - col; |
1250 | num = ncol - col; |
1253 | min_it (line.l, col); |
1251 | min_it (line.l, col); |
|
|
1252 | |
1254 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1253 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1255 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1254 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1256 | CLEAR_SELECTION (); |
1255 | CLEAR_SELECTION (); |
1257 | break; |
1256 | break; |
|
|
1257 | |
1258 | case 1: /* erase to beginning of line */ |
1258 | case 1: /* erase to beginning of line */ |
1259 | col = 0; |
1259 | col = 0; |
1260 | num = screen.cur.col + 1; |
1260 | num = screen.cur.col + 1; |
|
|
1261 | |
1261 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1262 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1262 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1263 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1263 | CLEAR_SELECTION (); |
1264 | CLEAR_SELECTION (); |
1264 | break; |
1265 | break; |
|
|
1266 | |
1265 | case 2: /* erase whole line */ |
1267 | case 2: /* erase whole line */ |
1266 | col = 0; |
1268 | col = 0; |
1267 | num = ncol; |
1269 | num = ncol; |
1268 | line.l = 0; |
1270 | line.l = 0; |
1269 | if (selection.beg.row <= screen.cur.row |
1271 | if (selection.beg.row <= screen.cur.row |
… | |
… | |
1327 | if (row >= nrow) /* Out Of Bounds */ |
1329 | if (row >= nrow) /* Out Of Bounds */ |
1328 | return; |
1330 | return; |
1329 | |
1331 | |
1330 | min_it (num, nrow - row); |
1332 | min_it (num, nrow - row); |
1331 | |
1333 | |
|
|
1334 | /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ |
1332 | if (rstyle & (RS_RVid | RS_Uline)) |
1335 | if (rstyle & (RS_RVid | RS_Uline)) |
1333 | ren = (rend_t) ~RS_None; |
1336 | ren = (rend_t) ~RS_None; |
1334 | else if (GET_BASEBG (rstyle) == Color_bg) |
1337 | else if (GET_BASEBG (rstyle) == Color_bg) |
1335 | { |
1338 | { |
1336 | ren = DEFAULT_RSTYLE; |
1339 | ren = DEFAULT_RSTYLE; |
1337 | CLEAR_ROWS (row, num); |
1340 | |
|
|
1341 | if (mapped) |
|
|
1342 | XClearArea (dpy, vt, 0, |
|
|
1343 | Row2Pixel (row), (unsigned int)width, |
|
|
1344 | (unsigned int)Height2Pixel (num), False); |
1338 | } |
1345 | } |
1339 | else |
1346 | else |
1340 | { |
1347 | { |
1341 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1348 | ren = rstyle & (RS_fgMask | RS_bgMask); |
|
|
1349 | |
1342 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1350 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1343 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1351 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1344 | ERASE_ROWS (row, num); |
1352 | XFillRectangle (dpy, vt, gc, |
|
|
1353 | 0, Row2Pixel (row), |
|
|
1354 | (unsigned int)width, |
|
|
1355 | (unsigned int)Height2Pixel (num)); |
1345 | gcvalue.foreground = pix_colors[Color_fg]; |
1356 | gcvalue.foreground = pix_colors[Color_fg]; |
1346 | XChangeGC (display->display, gc, GCForeground, &gcvalue); |
1357 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1347 | } |
1358 | } |
1348 | |
1359 | |
1349 | for (; num--; row++) |
1360 | for (; num--; row++) |
1350 | { |
1361 | { |
1351 | scr_blank_screen_mem (ROW(row), rstyle); |
1362 | scr_blank_screen_mem (ROW(row), rstyle); |
1352 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1363 | scr_blank_line (drawn_buf [row], 0, ncol, ren); |
1353 | } |
1364 | } |
1354 | } |
1365 | } |
1355 | |
1366 | |
1356 | #if ENABLE_FRILLS |
1367 | #if !ENABLE_MINIMAL |
1357 | void |
1368 | void |
1358 | rxvt_term::scr_erase_savelines () NOTHROW |
1369 | rxvt_term::scr_erase_savelines () NOTHROW |
1359 | { |
1370 | { |
1360 | want_refresh = 1; |
1371 | want_refresh = 1; |
1361 | ZERO_SCROLLBACK (); |
1372 | ZERO_SCROLLBACK (); |
… | |
… | |
1470 | { |
1481 | { |
1471 | if (selection.end.row != screen.cur.row |
1482 | if (selection.end.row != screen.cur.row |
1472 | || (selection.end.col + count >= ncol)) |
1483 | || (selection.end.col + count >= ncol)) |
1473 | CLEAR_SELECTION (); |
1484 | CLEAR_SELECTION (); |
1474 | else |
1485 | else |
|
|
1486 | { |
1475 | { /* shift selection */ |
1487 | /* shift selection */ |
1476 | selection.beg.col += count; |
1488 | selection.beg.col += count; |
1477 | selection.mark.col += count; /* XXX: yes? */ |
1489 | selection.mark.col += count; /* XXX: yes? */ |
1478 | selection.end.col += count; |
1490 | selection.end.col += count; |
1479 | } |
1491 | } |
1480 | } |
1492 | } |
… | |
… | |
1485 | case ERASE: |
1497 | case ERASE: |
1486 | screen.cur.col += count; /* don't worry if > ncol */ |
1498 | screen.cur.col += count; /* don't worry if > ncol */ |
1487 | selection_check (1); |
1499 | selection_check (1); |
1488 | screen.cur.col -= count; |
1500 | screen.cur.col -= count; |
1489 | |
1501 | |
1490 | line->l = max (line->l - count, 0); |
|
|
1491 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1502 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1492 | break; |
1503 | break; |
1493 | |
1504 | |
1494 | case DELETE: |
1505 | case DELETE: |
1495 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1506 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
… | |
… | |
1619 | */ |
1630 | */ |
1620 | void |
1631 | void |
1621 | rxvt_term::scr_set_tab (int mode) NOTHROW |
1632 | rxvt_term::scr_set_tab (int mode) NOTHROW |
1622 | { |
1633 | { |
1623 | if (mode < 0) |
1634 | if (mode < 0) |
1624 | memset (tabs, 0, ncol * sizeof (char)); |
1635 | memset (tabs, 0, ncol); |
1625 | else if (screen.cur.col < ncol) |
1636 | else if (screen.cur.col < ncol) |
1626 | tabs [screen.cur.col] = !!mode; |
1637 | tabs [screen.cur.col] = !!mode; |
1627 | } |
1638 | } |
1628 | |
1639 | |
1629 | /* ------------------------------------------------------------------------- */ |
1640 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1644 | if (rvideo_state != on) |
1655 | if (rvideo_state != on) |
1645 | { |
1656 | { |
1646 | rvideo_state = on; |
1657 | rvideo_state = on; |
1647 | |
1658 | |
1648 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1659 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1649 | #if XPM_BACKGROUND |
1660 | #ifdef HAVE_BG_PIXMAP |
1650 | if (bgPixmap.pixmap == None) |
1661 | if (bgPixmap.pixmap == None) |
1651 | #endif |
1662 | #endif |
1652 | #if TRANSPARENT |
|
|
1653 | if (!OPTION (Opt_transparent) || am_transparent == 0) |
|
|
1654 | #endif |
|
|
1655 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
1663 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1656 | |
1664 | |
1657 | XGCValues gcvalue; |
1665 | XGCValues gcvalue; |
1658 | gcvalue.foreground = pix_colors[Color_fg]; |
1666 | gcvalue.foreground = pix_colors[Color_fg]; |
1659 | gcvalue.background = pix_colors[Color_bg]; |
1667 | gcvalue.background = pix_colors[Color_bg]; |
1660 | XChangeGC (display->display, gc, GCBackground | GCForeground, &gcvalue); |
1668 | XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue); |
1661 | |
1669 | |
1662 | scr_clear (); |
1670 | scr_clear (); |
1663 | scr_touch (true); |
1671 | scr_touch (true); |
1664 | } |
1672 | } |
1665 | } |
1673 | } |
… | |
… | |
1750 | { |
1758 | { |
1751 | bool found = false; |
1759 | bool found = false; |
1752 | |
1760 | |
1753 | for (int i = 0; i < nrow; i++) |
1761 | for (int i = 0; i < nrow; i++) |
1754 | { |
1762 | { |
1755 | int col = 0; |
|
|
1756 | rend_t *drp = drawn_buf[i].r; |
1763 | rend_t *drp = drawn_buf[i].r; |
1757 | |
1764 | |
1758 | for (; col < ncol; col++, drp++) |
1765 | for (int col = 0; col < ncol; col++, drp++) |
1759 | if ((*drp & mask) == value) |
1766 | if ((*drp & mask) == value) |
1760 | { |
1767 | { |
1761 | found = true; |
1768 | found = true; |
1762 | *drp = ~value; |
1769 | *drp = ~value; |
1763 | } |
1770 | } |
… | |
… | |
1803 | for (i = PART_BEG; i < RC_COUNT; i++) |
1810 | for (i = PART_BEG; i < RC_COUNT; i++) |
1804 | { |
1811 | { |
1805 | min_it (rc[i].col, ncol - 1); |
1812 | min_it (rc[i].col, ncol - 1); |
1806 | min_it (rc[i].row, nrow - 1); |
1813 | min_it (rc[i].row, nrow - 1); |
1807 | } |
1814 | } |
1808 | |
1815 | // TODO: this line somehow causes segfault if scr_expose() is called just after resize |
1809 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1816 | for (i = rc[PART_BEG].row; i <= rc[PART_END].row; i++) |
1810 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1817 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1811 | |
1818 | |
1812 | num_scr_allow = 0; |
1819 | num_scr_allow = 0; |
1813 | |
1820 | |
… | |
… | |
1868 | return true; |
1875 | return true; |
1869 | } |
1876 | } |
1870 | |
1877 | |
1871 | #ifndef NO_BELL |
1878 | #ifndef NO_BELL |
1872 | void |
1879 | void |
1873 | rxvt_term::bell_cb (time_watcher &w) |
1880 | rxvt_term::bell_cb (ev::timer &w, int revents) |
1874 | { |
1881 | { |
1875 | rvideo_bell = false; |
1882 | rvideo_bell = false; |
1876 | scr_rvideo_mode (rvideo_mode); |
1883 | scr_rvideo_mode (rvideo_mode); |
|
|
1884 | refresh_check (); |
1877 | } |
1885 | } |
1878 | #endif |
1886 | #endif |
1879 | |
1887 | |
1880 | /* ------------------------------------------------------------------------- */ |
1888 | /* ------------------------------------------------------------------------- */ |
1881 | void |
1889 | void |
… | |
… | |
1883 | { |
1891 | { |
1884 | #ifndef NO_BELL |
1892 | #ifndef NO_BELL |
1885 | |
1893 | |
1886 | # ifndef NO_MAPALERT |
1894 | # ifndef NO_MAPALERT |
1887 | # ifdef MAPALERT_OPTION |
1895 | # ifdef MAPALERT_OPTION |
1888 | if (OPTION (Opt_mapAlert)) |
1896 | if (option (Opt_mapAlert)) |
1889 | # endif |
1897 | # endif |
1890 | XMapWindow (display->display, parent[0]); |
1898 | XMapWindow (dpy, parent[0]); |
1891 | # endif |
1899 | # endif |
1892 | |
1900 | |
|
|
1901 | # if ENABLE_FRILLS |
|
|
1902 | if (option (Opt_urgentOnBell)) |
|
|
1903 | set_urgency (1); |
|
|
1904 | # endif |
|
|
1905 | |
1893 | if (OPTION (Opt_visualBell)) |
1906 | if (option (Opt_visualBell)) |
1894 | { |
1907 | { |
1895 | rvideo_bell = true; |
1908 | rvideo_bell = true; |
1896 | scr_rvideo_mode (rvideo_mode); |
1909 | scr_rvideo_mode (rvideo_mode); |
1897 | display->flush (); |
1910 | flush (); |
1898 | |
1911 | |
1899 | bell_ev.start (NOW + VISUAL_BELL_DURATION); |
1912 | bell_ev.start (VISUAL_BELL_DURATION); |
1900 | } |
1913 | } |
1901 | else |
1914 | else |
1902 | XBell (display->display, 0); |
1915 | XBell (dpy, 0); |
1903 | |
|
|
1904 | #endif |
1916 | #endif |
1905 | } |
1917 | } |
1906 | |
1918 | |
1907 | /* ------------------------------------------------------------------------- */ |
1919 | /* ------------------------------------------------------------------------- */ |
1908 | /* ARGSUSED */ |
1920 | /* ARGSUSED */ |
1909 | void |
1921 | void |
1910 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1922 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1911 | { |
1923 | { |
1912 | #ifdef PRINTPIPE |
1924 | #ifdef PRINTPIPE |
1913 | int nrows, row_start; |
1925 | int nrows, row_start; |
1914 | FILE *fd; |
1926 | FILE *fd = popen_printer (); |
1915 | |
1927 | |
1916 | if ((fd = popen_printer ()) == NULL) |
1928 | if (!fd) |
1917 | return; |
1929 | return; |
1918 | |
1930 | |
1919 | if (fullhist) |
1931 | if (fullhist) |
1920 | { |
1932 | { |
1921 | nrows = nrow - top_row; |
1933 | nrows = nrow - top_row; |
… | |
… | |
1966 | * screen.text/screen.rend contain what the screen will change to. |
1978 | * screen.text/screen.rend contain what the screen will change to. |
1967 | */ |
1979 | */ |
1968 | void |
1980 | void |
1969 | rxvt_term::scr_refresh () NOTHROW |
1981 | rxvt_term::scr_refresh () NOTHROW |
1970 | { |
1982 | { |
1971 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1983 | unsigned char have_bg, |
1972 | showcursor; /* show the cursor */ |
1984 | showcursor; /* show the cursor */ |
1973 | int16_t col, row, /* column/row we're processing */ |
1985 | int16_t col, row, /* column/row we're processing */ |
1974 | ocrow; /* old cursor row */ |
1986 | ocrow; /* old cursor row */ |
1975 | int i; /* tmp */ |
1987 | int i; /* tmp */ |
1976 | #ifndef NO_CURSORCOLOR |
1988 | #ifndef NO_CURSORCOLOR |
1977 | rend_t cc1; /* store colours at cursor position (s) */ |
1989 | rend_t cc1; /* store colours at cursor position (s) */ |
1978 | #endif |
1990 | #endif |
1979 | rend_t *crp; // cursor rendition pointer |
1991 | rend_t *crp; // cursor rendition pointer |
|
|
1992 | rend_t ccol1, /* Cursor colour */ |
|
|
1993 | ccol2; /* Cursor colour2 */ |
1980 | |
1994 | |
1981 | want_refresh = 0; /* screen is current */ |
1995 | want_refresh = 0; /* screen is current */ |
1982 | |
1996 | |
1983 | if (refresh_type == NO_REFRESH || !mapped) |
1997 | if (refresh_type == NO_REFRESH || !mapped) |
1984 | return; |
1998 | return; |
1985 | |
1999 | |
1986 | /* |
2000 | /* |
1987 | * A: set up vars |
2001 | * A: set up vars |
1988 | */ |
2002 | */ |
1989 | must_clear = 0; |
|
|
1990 | refresh_count = 0; |
2003 | refresh_count = 0; |
1991 | |
2004 | |
1992 | #if XPM_BACKGROUND |
2005 | have_bg = 0; |
|
|
2006 | #ifdef HAVE_BG_PIXMAP |
1993 | must_clear |= bgPixmap.pixmap != None; |
2007 | have_bg = bgPixmap.pixmap != None; |
1994 | #endif |
|
|
1995 | #if TRANSPARENT |
|
|
1996 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
|
|
1997 | #endif |
2008 | #endif |
1998 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2009 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1999 | |
2010 | |
2000 | /* |
2011 | /* |
2001 | * B: reverse any characters which are selected |
2012 | * B: reverse any characters which are selected |
… | |
… | |
2005 | /* |
2016 | /* |
2006 | * C: set the cursor character (s) |
2017 | * C: set the cursor character (s) |
2007 | */ |
2018 | */ |
2008 | { |
2019 | { |
2009 | unsigned char setoldcursor; |
2020 | unsigned char setoldcursor; |
2010 | rend_t ccol1, /* Cursor colour */ |
|
|
2011 | ccol2; /* Cursor colour2 */ |
|
|
2012 | |
2021 | |
2013 | showcursor = (screen.flags & Screen_VisibleCursor); |
2022 | showcursor = (screen.flags & Screen_VisibleCursor); |
2014 | #ifdef CURSOR_BLINK |
2023 | #ifdef CURSOR_BLINK |
2015 | if (hidden_cursor) |
2024 | if (hidden_cursor) |
2016 | showcursor = 0; |
2025 | showcursor = 0; |
… | |
… | |
2023 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2032 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2024 | col--; |
2033 | col--; |
2025 | |
2034 | |
2026 | crp = &ROW(screen.cur.row).r[col]; |
2035 | crp = &ROW(screen.cur.row).r[col]; |
2027 | |
2036 | |
|
|
2037 | #ifndef NO_CURSORCOLOR |
|
|
2038 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2039 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2040 | ccol1 = Color_cursor; |
|
|
2041 | else |
|
|
2042 | #endif |
|
|
2043 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2044 | ccol1 = fgcolor_of (rstyle); |
|
|
2045 | #else |
|
|
2046 | ccol1 = Color_fg; |
|
|
2047 | #endif |
|
|
2048 | |
|
|
2049 | #ifndef NO_CURSORCOLOR |
|
|
2050 | if (ISSET_PIXCOLOR (Color_cursor2)) |
|
|
2051 | ccol2 = Color_cursor2; |
|
|
2052 | else |
|
|
2053 | #endif |
|
|
2054 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2055 | ccol2 = bgcolor_of (rstyle); |
|
|
2056 | #else |
|
|
2057 | ccol2 = Color_bg; |
|
|
2058 | #endif |
|
|
2059 | |
2028 | if (showcursor && focus) |
2060 | if (showcursor && focus) |
2029 | { |
2061 | { |
2030 | if (OPTION (Opt_cursorUnderline)) |
2062 | if (option (Opt_cursorUnderline)) |
2031 | *crp ^= RS_Uline; |
2063 | *crp ^= RS_Uline; |
2032 | else |
2064 | else |
2033 | { |
2065 | { |
2034 | *crp ^= RS_RVid; |
2066 | *crp ^= RS_RVid; |
2035 | |
|
|
2036 | #ifndef NO_CURSORCOLOR |
|
|
2037 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2038 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2039 | ccol1 = Color_cursor; |
|
|
2040 | else |
|
|
2041 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2042 | ccol1 = fgcolor_of (rstyle); |
|
|
2043 | #else |
|
|
2044 | ccol1 = Color_fg; |
|
|
2045 | #endif |
|
|
2046 | if (ISSET_PIXCOLOR (Color_cursor2)) |
|
|
2047 | ccol2 = Color_cursor2; |
|
|
2048 | else |
|
|
2049 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2050 | ccol2 = bgcolor_of (rstyle); |
|
|
2051 | #else |
|
|
2052 | ccol2 = Color_bg; |
|
|
2053 | #endif |
|
|
2054 | *crp = SET_FGCOLOR (*crp, ccol1); |
2067 | *crp = SET_FGCOLOR (*crp, ccol1); |
2055 | *crp = SET_BGCOLOR (*crp, ccol2); |
2068 | *crp = SET_BGCOLOR (*crp, ccol2); |
2056 | #endif |
|
|
2057 | } |
2069 | } |
2058 | } |
2070 | } |
2059 | } |
2071 | } |
2060 | |
2072 | |
2061 | /* make sure no outline cursor is left around */ |
2073 | /* make sure no outline cursor is left around */ |
… | |
… | |
2100 | * D: CopyArea pass - very useful for slower links |
2112 | * D: CopyArea pass - very useful for slower links |
2101 | * This has been deliberately kept simple. |
2113 | * This has been deliberately kept simple. |
2102 | */ |
2114 | */ |
2103 | if (!display->is_local |
2115 | if (!display->is_local |
2104 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2116 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2105 | && abs (num_scr) < nrow && !must_clear) |
2117 | && abs (num_scr) < nrow && !have_bg) |
2106 | { |
2118 | { |
2107 | int16_t nits; |
2119 | int16_t nits; |
|
|
2120 | int i = num_scr; |
2108 | int j; |
2121 | int j; |
2109 | int len, wlen; |
2122 | int len, wlen; |
2110 | dLocal (int, num_scr); |
2123 | dLocal (int, num_scr); |
2111 | |
2124 | |
2112 | j = nrow; |
2125 | j = nrow; |
2113 | wlen = len = -1; |
2126 | wlen = len = -1; |
2114 | row = i > 0 ? 0 : j - 1; |
2127 | row = i > 0 ? 0 : j - 1; |
|
|
2128 | |
2115 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2129 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2116 | { |
2130 | { |
2117 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2131 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2118 | { |
2132 | { |
2119 | line_t s = ROW(view_start + row); |
2133 | line_t s = ROW(view_start + row); |
… | |
… | |
2140 | wlen = row; |
2154 | wlen = row; |
2141 | continue; |
2155 | continue; |
2142 | } |
2156 | } |
2143 | } |
2157 | } |
2144 | |
2158 | |
2145 | if (len != -1) |
2159 | if (len >= 0) |
2146 | { |
2160 | { |
2147 | /* also comes here at end if needed because of >= above */ |
2161 | /* also comes here at end if needed because of >= above */ |
2148 | if (wlen < len) |
2162 | if (wlen < len) |
2149 | ::swap (wlen, len); |
2163 | ::swap (wlen, len); |
2150 | |
2164 | |
|
|
2165 | XGCValues gcv; |
|
|
2166 | |
|
|
2167 | gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
2151 | XCopyArea (display->display, vt, vt, |
2168 | XCopyArea (dpy, vt, vt, |
2152 | gc, 0, Row2Pixel (len + i), |
2169 | gc, 0, Row2Pixel (len + i), |
2153 | (unsigned int)this->width, |
2170 | (unsigned int)this->width, |
2154 | (unsigned int)Height2Pixel (wlen - len + 1), |
2171 | (unsigned int)Height2Pixel (wlen - len + 1), |
2155 | 0, Row2Pixel (len)); |
2172 | 0, Row2Pixel (len)); |
|
|
2173 | gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
|
|
2174 | |
2156 | len = -1; |
2175 | len = -1; |
2157 | } |
2176 | } |
2158 | } |
2177 | } |
2159 | } |
2178 | } |
2160 | #endif |
2179 | #endif |
… | |
… | |
2184 | continue; |
2203 | continue; |
2185 | |
2204 | |
2186 | // redraw one or more characters |
2205 | // redraw one or more characters |
2187 | |
2206 | |
2188 | // seek to the beginning of wide characters |
2207 | // seek to the beginning of wide characters |
2189 | while (stp[col] == NOCHAR && col > 0) |
2208 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2190 | --col; |
2209 | --col; |
2191 | |
2210 | |
2192 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2211 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2193 | text_t *text = stp + col; |
2212 | text_t *text = stp + col; |
2194 | int count = 1; |
2213 | int count = 1; |
… | |
… | |
2216 | count++; |
2235 | count++; |
2217 | |
2236 | |
2218 | if (stp[col] != dtp[col] |
2237 | if (stp[col] != dtp[col] |
2219 | || !RS_SAME (srp[col], drp[col])) |
2238 | || !RS_SAME (srp[col], drp[col])) |
2220 | { |
2239 | { |
2221 | if (must_clear && (i++ > count / 2)) |
2240 | if (have_bg && (i++ > count / 2)) |
2222 | break; |
2241 | break; |
2223 | |
2242 | |
2224 | dtp[col] = stp[col]; |
2243 | dtp[col] = stp[col]; |
2225 | drp[col] = rend; |
2244 | drp[col] = rend; |
2226 | i = 0; |
2245 | i = 0; |
2227 | } |
2246 | } |
2228 | else if (must_clear || (stp[col] != ' ' && ++i >= 16)) |
2247 | else if (have_bg || (stp[col] != ' ' && ++i >= 16)) |
2229 | break; |
2248 | break; |
2230 | } |
2249 | } |
2231 | |
2250 | |
2232 | col--; /* went one too far. move back */ |
2251 | col--; /* went one too far. move back */ |
2233 | count -= i; /* dump any matching trailing chars */ |
2252 | count -= i; /* dump any matching trailing chars */ |
2234 | |
2253 | |
2235 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2254 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2236 | while (i && text[count] == NOCHAR) |
2255 | while (expect_false (i && text[count] == NOCHAR)) |
2237 | count++, i--; |
2256 | count++, i--; |
2238 | |
2257 | |
2239 | /* |
2258 | /* |
2240 | * Determine the attributes for the string |
2259 | * Determine the attributes for the string |
2241 | */ |
2260 | */ |
2242 | int fore = fgcolor_of (rend); // desired foreground |
2261 | int fore = fgcolor_of (rend); // desired foreground |
2243 | int back = bgcolor_of (rend); // desired background |
2262 | int back = bgcolor_of (rend); // desired background |
2244 | |
2263 | |
2245 | // only do special processing if any attributes are set, which is unlikely |
2264 | // only do special processing if any attributes are set, which is unlikely |
2246 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2265 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2247 | { |
2266 | { |
2248 | #if ENABLE_STYLES |
|
|
2249 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2250 | if (srp[col] & RS_Careful && col < ncol - 1 && 0) |
|
|
2251 | drp[col + 1] = ~srp[col + 1]; |
|
|
2252 | |
|
|
2253 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2254 | while (text > stp |
|
|
2255 | && srp[text - stp - 1] & RS_Careful |
|
|
2256 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2257 | text--, count++, xpixel -= fwidth; |
|
|
2258 | #endif |
|
|
2259 | |
|
|
2260 | bool invert = rend & RS_RVid; |
2267 | bool invert = rend & RS_RVid; |
2261 | |
2268 | |
2262 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2269 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2263 | if (rend & RS_Bold |
|
|
2264 | && fore == Color_fg) |
2270 | if (rend & RS_Bold && fore == Color_fg) |
2265 | { |
2271 | { |
2266 | if (ISSET_PIXCOLOR (Color_BD)) |
2272 | if (ISSET_PIXCOLOR (Color_BD)) |
2267 | fore = Color_BD; |
2273 | fore = Color_BD; |
2268 | # if !ENABLE_STYLES |
2274 | # if !ENABLE_STYLES |
2269 | else |
2275 | else |
2270 | invert = !invert; |
2276 | invert = !invert; |
2271 | # endif |
2277 | # endif |
2272 | } |
2278 | } |
2273 | |
2279 | |
2274 | if (rend & RS_Italic |
2280 | if (rend & RS_Italic && fore == Color_fg) |
2275 | && fore == Color_fg) |
|
|
2276 | { |
2281 | { |
2277 | if (ISSET_PIXCOLOR (Color_IT)) |
2282 | if (ISSET_PIXCOLOR (Color_IT)) |
2278 | fore = Color_IT; |
2283 | fore = Color_IT; |
2279 | # if !ENABLE_STYLES |
2284 | # if !ENABLE_STYLES |
2280 | else |
2285 | else |
2281 | invert = !invert; |
2286 | invert = !invert; |
2282 | # endif |
2287 | # endif |
2283 | } |
2288 | } |
2284 | |
2289 | |
2285 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
2290 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2286 | fore = Color_UL; |
2291 | fore = Color_UL; |
2287 | #endif |
2292 | #endif |
2288 | |
2293 | |
2289 | if (invert) |
2294 | if (invert) |
2290 | { |
2295 | { |
|
|
2296 | #ifdef OPTION_HC |
|
|
2297 | if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2298 | || !ISSET_PIXCOLOR (Color_HC)) |
|
|
2299 | #endif |
|
|
2300 | /* invert the column if no highlightColor is set or it is the |
|
|
2301 | * current cursor column */ |
2291 | ::swap (fore, back); |
2302 | ::swap (fore, back); |
|
|
2303 | #ifdef OPTION_HC |
|
|
2304 | else if (ISSET_PIXCOLOR (Color_HC)) |
|
|
2305 | back = Color_HC; |
|
|
2306 | #endif |
2292 | |
2307 | |
2293 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2308 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2309 | # ifndef OPTION_HC |
2294 | if (ISSET_PIXCOLOR (Color_RV)) |
2310 | if (ISSET_PIXCOLOR (Color_RV)) |
2295 | back = Color_RV; |
2311 | back = Color_RV; |
2296 | |
2312 | # endif |
2297 | if (fore == back) |
2313 | if (fore == back) |
2298 | { |
2314 | { |
2299 | fore = Color_bg; |
2315 | fore = Color_bg; |
2300 | back = Color_fg; |
2316 | back = Color_fg; |
2301 | } |
2317 | } |
… | |
… | |
2303 | } |
2319 | } |
2304 | |
2320 | |
2305 | #ifdef TEXT_BLINK |
2321 | #ifdef TEXT_BLINK |
2306 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2322 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2307 | { |
2323 | { |
2308 | if (!text_blink_ev.active) |
2324 | if (!text_blink_ev.is_active ()) |
2309 | { |
2325 | { |
2310 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
2326 | text_blink_ev.again (); |
2311 | hidden_text = 0; |
2327 | hidden_text = 0; |
2312 | } |
2328 | } |
2313 | else if (hidden_text) |
2329 | else if (hidden_text) |
2314 | fore = back; |
2330 | fore = back; |
2315 | } |
2331 | } |
2316 | #endif |
2332 | #endif |
|
|
2333 | |
|
|
2334 | #if ENABLE_STYLES |
|
|
2335 | // "careful" (too wide) character handling |
|
|
2336 | |
|
|
2337 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2338 | while (text > stp |
|
|
2339 | && srp[text - stp - 1] & RS_Careful |
|
|
2340 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2341 | text--, count++, xpixel -= fwidth; |
|
|
2342 | |
|
|
2343 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2344 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2345 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2346 | |
|
|
2347 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2348 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2349 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
|
|
2350 | #endif |
2317 | } |
2351 | } |
2318 | |
2352 | |
2319 | /* |
2353 | /* |
2320 | * Actually do the drawing of the string here |
2354 | * Actually do the drawing of the string here |
2321 | */ |
2355 | */ |
2322 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2356 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2323 | |
2357 | |
2324 | if (back == fore) |
2358 | if (expect_true (have_bg && back == Color_bg)) |
2325 | font->clear_rect (*drawable, xpixel, ypixel, |
|
|
2326 | fwidth * count, fheight, |
|
|
2327 | back); |
|
|
2328 | else if (back == Color_bg) |
|
|
2329 | { |
2359 | { |
2330 | if (must_clear) |
2360 | // this is very ugly, maybe push it into ->draw? |
2331 | { |
|
|
2332 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2333 | |
2361 | |
2334 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2362 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2335 | if (text[i] != ' ') |
2363 | if (text[i] != ' ') |
2336 | { |
2364 | { |
2337 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2365 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent); |
2338 | break; |
2366 | goto did_clear; |
2339 | } |
|
|
2340 | } |
2367 | } |
2341 | else |
2368 | |
2342 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2369 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2370 | did_clear: ; |
2343 | } |
2371 | } |
2344 | else |
2372 | else |
2345 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2373 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2346 | |
2374 | |
2347 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2375 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2348 | { |
2376 | { |
2349 | #if ENABLE_FRILLS |
2377 | #if ENABLE_FRILLS |
2350 | if (ISSET_PIXCOLOR (Color_underline)) |
2378 | if (ISSET_PIXCOLOR (Color_underline)) |
2351 | XSetForeground (display->display, gc, pix_colors[Color_underline]); |
2379 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2352 | else |
2380 | else |
2353 | #endif |
2381 | #endif |
2354 | XSetForeground (display->display, gc, pix_colors[fore]); |
2382 | XSetForeground (dpy, gc, pix_colors[fore]); |
2355 | |
2383 | |
2356 | XDrawLine (display->display, drawBuffer, gc, |
2384 | XDrawLine (dpy, vt, gc, |
2357 | xpixel, ypixel + font->ascent + 1, |
2385 | xpixel, ypixel + font->ascent + 1, |
2358 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2386 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2359 | } |
2387 | } |
2360 | } /* for (col....) */ |
2388 | } /* for (col....) */ |
2361 | } /* for (row....) */ |
2389 | } /* for (row....) */ |
… | |
… | |
2370 | */ |
2398 | */ |
2371 | if (showcursor) |
2399 | if (showcursor) |
2372 | { |
2400 | { |
2373 | if (focus) |
2401 | if (focus) |
2374 | { |
2402 | { |
2375 | if (OPTION (Opt_cursorUnderline)) |
2403 | if (option (Opt_cursorUnderline)) |
2376 | *crp ^= RS_Uline; |
2404 | *crp ^= RS_Uline; |
2377 | else |
2405 | else |
2378 | { |
2406 | { |
2379 | *crp ^= RS_RVid; |
2407 | *crp ^= RS_RVid; |
2380 | #ifndef NO_CURSORCOLOR |
2408 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2394 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2422 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2395 | cursorwidth++; |
2423 | cursorwidth++; |
2396 | |
2424 | |
2397 | #ifndef NO_CURSORCOLOR |
2425 | #ifndef NO_CURSORCOLOR |
2398 | if (ISSET_PIXCOLOR (Color_cursor)) |
2426 | if (ISSET_PIXCOLOR (Color_cursor)) |
2399 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2427 | XSetForeground (dpy, gc, pix_colors[Color_cursor]); |
|
|
2428 | else |
2400 | #endif |
2429 | #endif |
|
|
2430 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2401 | |
2431 | |
2402 | XDrawRectangle (display->display, drawBuffer, gc, |
2432 | XDrawRectangle (dpy, vt, gc, |
2403 | Col2Pixel (col), |
2433 | Col2Pixel (col), |
2404 | Row2Pixel (oldcursor.row), |
2434 | Row2Pixel (oldcursor.row), |
2405 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2435 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2406 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2436 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2407 | } |
2437 | } |
… | |
… | |
2442 | } |
2472 | } |
2443 | |
2473 | |
2444 | void |
2474 | void |
2445 | rxvt_term::scr_recolour () NOTHROW |
2475 | rxvt_term::scr_recolour () NOTHROW |
2446 | { |
2476 | { |
2447 | if (1 |
2477 | #ifdef HAVE_BG_PIXMAP |
2448 | #if TRANSPARENT |
2478 | bgPixmap.apply (); |
2449 | && !am_transparent |
2479 | #else |
2450 | #endif |
2480 | |
2451 | #if XPM_BACKGROUND |
|
|
2452 | && !bgPixmap.pixmap |
|
|
2453 | #endif |
|
|
2454 | ) |
|
|
2455 | { |
|
|
2456 | XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); |
2481 | XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); |
2457 | XClearWindow (display->display, parent[0]); |
2482 | XClearWindow (dpy, parent[0]); |
2458 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
2483 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2459 | #if HAVE_SCROLLBARS |
2484 | |
2460 | if (scrollBar.win) |
2485 | if (scrollBar.win) |
2461 | { |
2486 | { |
2462 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
2487 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2463 | scrollBar.setIdle (); |
2488 | scrollBar.state = STATE_IDLE; |
2464 | scrollbar_show (0); |
2489 | scrollBar.show (0); |
2465 | } |
|
|
2466 | #endif |
|
|
2467 | } |
2490 | } |
2468 | |
2491 | |
|
|
2492 | #endif |
|
|
2493 | |
|
|
2494 | /* bgPixmap.apply () does not do the following : */ |
2469 | scr_clear (); |
2495 | scr_clear (); |
2470 | scr_touch (true); |
2496 | scr_touch (true); |
2471 | want_refresh = 1; |
2497 | want_refresh = 1; |
2472 | } |
2498 | } |
2473 | |
2499 | |
… | |
… | |
2480 | |
2506 | |
2481 | num_scr_allow = 0; |
2507 | num_scr_allow = 0; |
2482 | want_refresh = 1; |
2508 | want_refresh = 1; |
2483 | |
2509 | |
2484 | if (really) |
2510 | if (really) |
2485 | XClearWindow (display->display, vt); |
2511 | XClearWindow (dpy, vt); |
2486 | } |
2512 | } |
2487 | |
2513 | |
2488 | void |
2514 | void |
2489 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
2515 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
2490 | { |
2516 | { |
… | |
… | |
2539 | { |
2565 | { |
2540 | if (selection.op |
2566 | if (selection.op |
2541 | && current_screen == selection.screen |
2567 | && current_screen == selection.screen |
2542 | && selection.end.row >= view_start) |
2568 | && selection.end.row >= view_start) |
2543 | { |
2569 | { |
2544 | #if ENABLE_FRILLS |
2570 | #if !ENABLE_MINIMAL |
2545 | if (selection.rect) |
2571 | if (selection.rect) |
2546 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2572 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2547 | selection.end.row, selection.end.col, |
2573 | selection.end.row, selection.end.col, |
2548 | RS_RVid, RS_RVid | RS_Uline); |
2574 | RS_RVid, RS_RVid | RS_Uline); |
2549 | else |
2575 | else |
… | |
… | |
2565 | { |
2591 | { |
2566 | int row, wrote; |
2592 | int row, wrote; |
2567 | unsigned int width, towrite; |
2593 | unsigned int width, towrite; |
2568 | char r1[] = "\n"; |
2594 | char r1[] = "\n"; |
2569 | |
2595 | |
2570 | for (row = saveLines - nsaved; |
2596 | for (row = saveLines + top_row; |
2571 | row < saveLines + nrow - 1; row++) |
2597 | row < saveLines + nrow - 1; row++) |
2572 | { |
2598 | { |
2573 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2599 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2574 | : ncol; |
2600 | : ncol; |
2575 | for (towrite = width; towrite; towrite -= wrote) |
2601 | for (towrite = width; towrite; towrite -= wrote) |
… | |
… | |
2626 | /* convert normal newline chars into common keyboard Return key sequence */ |
2652 | /* convert normal newline chars into common keyboard Return key sequence */ |
2627 | for (unsigned int i = 0; i < len; i++) |
2653 | for (unsigned int i = 0; i < len; i++) |
2628 | if (data[i] == C0_LF) |
2654 | if (data[i] == C0_LF) |
2629 | data[i] = C0_CR; |
2655 | data[i] = C0_CR; |
2630 | |
2656 | |
|
|
2657 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2658 | tt_printf ("\e[200~"); |
|
|
2659 | |
2631 | tt_write (data, len); |
2660 | tt_write (data, len); |
|
|
2661 | |
|
|
2662 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2663 | tt_printf ("\e[201~"); |
2632 | } |
2664 | } |
2633 | |
2665 | |
2634 | /* ------------------------------------------------------------------------- */ |
2666 | /* ------------------------------------------------------------------------- */ |
2635 | /* |
2667 | /* |
2636 | * Respond to a notification that a primary selection has been sent |
2668 | * Respond to a notification that a primary selection has been sent |
… | |
… | |
2665 | } |
2697 | } |
2666 | |
2698 | |
2667 | unsigned long bytes_after; |
2699 | unsigned long bytes_after; |
2668 | XTextProperty ct; |
2700 | XTextProperty ct; |
2669 | |
2701 | |
2670 | if (XGetWindowProperty (display->display, win, prop, |
2702 | if (XGetWindowProperty (dpy, win, prop, |
2671 | 0, PROP_SIZE / 4, |
2703 | 0, PROP_SIZE / 4, |
2672 | delete_prop, AnyPropertyType, |
2704 | delete_prop, AnyPropertyType, |
2673 | &ct.encoding, &ct.format, |
2705 | &ct.encoding, &ct.format, |
2674 | &ct.nitems, &bytes_after, |
2706 | &ct.nitems, &bytes_after, |
2675 | &ct.value) != Success) |
2707 | &ct.value) != Success) |
… | |
… | |
2684 | if (bytes_after) |
2716 | if (bytes_after) |
2685 | { |
2717 | { |
2686 | // fetch and append remaining data |
2718 | // fetch and append remaining data |
2687 | XTextProperty ct2; |
2719 | XTextProperty ct2; |
2688 | |
2720 | |
2689 | if (XGetWindowProperty (display->display, win, prop, |
2721 | if (XGetWindowProperty (dpy, win, prop, |
2690 | ct.nitems / 4, (bytes_after + 3) / 4, |
2722 | ct.nitems / 4, (bytes_after + 3) / 4, |
2691 | delete_prop, AnyPropertyType, |
2723 | delete_prop, AnyPropertyType, |
2692 | &ct2.encoding, &ct2.format, |
2724 | &ct2.encoding, &ct2.format, |
2693 | &ct2.nitems, &bytes_after, |
2725 | &ct2.nitems, &bytes_after, |
2694 | &ct2.value) != Success) |
2726 | &ct2.value) != Success) |
… | |
… | |
2707 | |
2739 | |
2708 | if (ct.encoding == xa[XA_INCR]) |
2740 | if (ct.encoding == xa[XA_INCR]) |
2709 | { |
2741 | { |
2710 | // INCR selection, start handshake |
2742 | // INCR selection, start handshake |
2711 | if (!delete_prop) |
2743 | if (!delete_prop) |
2712 | XDeleteProperty (display->display, win, prop); |
2744 | XDeleteProperty (dpy, win, prop); |
2713 | |
2745 | |
2714 | selection_wait = Sel_incr; |
2746 | selection_wait = Sel_incr; |
2715 | incr_buf_fill = 0; |
2747 | incr_buf_fill = 0; |
2716 | incr_ev.start (NOW + 10); |
2748 | incr_ev.start (10); |
2717 | |
2749 | |
2718 | goto bailout; |
2750 | goto bailout; |
2719 | } |
2751 | } |
2720 | |
2752 | |
2721 | if (ct.nitems == 0) |
2753 | if (ct.nitems == 0) |
… | |
… | |
2730 | ct.nitems = incr_buf_fill; |
2762 | ct.nitems = incr_buf_fill; |
2731 | incr_buf = 0; |
2763 | incr_buf = 0; |
2732 | incr_buf_size = 0; |
2764 | incr_buf_size = 0; |
2733 | incr_ev.stop (); |
2765 | incr_ev.stop (); |
2734 | } |
2766 | } |
2735 | else |
2767 | else |
2736 | { |
2768 | { |
2737 | if (selection_wait == Sel_normal |
2769 | if (selection_wait == Sel_normal |
2738 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2770 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2739 | { |
2771 | { |
2740 | /* |
2772 | /* |
… | |
… | |
2747 | goto bailout; |
2779 | goto bailout; |
2748 | } |
2780 | } |
2749 | } |
2781 | } |
2750 | else if (selection_wait == Sel_incr) |
2782 | else if (selection_wait == Sel_incr) |
2751 | { |
2783 | { |
2752 | incr_ev.start (NOW + 10); |
2784 | incr_ev.start (10); |
2753 | |
2785 | |
2754 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2786 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2755 | { |
2787 | { |
2756 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2788 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2757 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
2789 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
… | |
… | |
2764 | } |
2796 | } |
2765 | |
2797 | |
2766 | char **cl; |
2798 | char **cl; |
2767 | int cr; |
2799 | int cr; |
2768 | |
2800 | |
2769 | #if ENABLE_FRILLS |
2801 | #if !ENABLE_MINIMAL |
2770 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2802 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2771 | // so recode it manually |
2803 | // so recode it manually |
2772 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2804 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2773 | { |
2805 | { |
2774 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2806 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
… | |
… | |
2778 | paste (s, strlen (s)); |
2810 | paste (s, strlen (s)); |
2779 | free (s); |
2811 | free (s); |
2780 | } |
2812 | } |
2781 | else |
2813 | else |
2782 | #endif |
2814 | #endif |
2783 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2815 | if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0 |
2784 | && cl) |
2816 | && cl) |
2785 | { |
2817 | { |
2786 | for (int i = 0; i < cr; i++) |
2818 | for (int i = 0; i < cr; i++) |
2787 | paste (cl[i], strlen (cl[i])); |
2819 | paste (cl[i], strlen (cl[i])); |
2788 | |
2820 | |
… | |
… | |
2797 | if (selection_wait == Sel_normal) |
2829 | if (selection_wait == Sel_normal) |
2798 | selection_wait = Sel_none; |
2830 | selection_wait = Sel_none; |
2799 | } |
2831 | } |
2800 | |
2832 | |
2801 | void |
2833 | void |
2802 | rxvt_term::incr_cb (time_watcher &w) NOTHROW |
2834 | rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW |
2803 | { |
2835 | { |
2804 | selection_wait = Sel_none; |
2836 | selection_wait = Sel_none; |
2805 | |
2837 | |
2806 | incr_buf_size = 0; |
2838 | incr_buf_size = 0; |
2807 | free (incr_buf); |
2839 | free (incr_buf); |
… | |
… | |
2818 | selection_paste (win, prop, true); |
2850 | selection_paste (win, prop, true); |
2819 | } |
2851 | } |
2820 | |
2852 | |
2821 | /* ------------------------------------------------------------------------- */ |
2853 | /* ------------------------------------------------------------------------- */ |
2822 | /* |
2854 | /* |
2823 | * Request the current selection: |
2855 | * Request the current selection: |
2824 | * Order: > internal selection if available |
2856 | * Order: > internal selection if available |
2825 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2857 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2826 | * > CUT_BUFFER0 |
2858 | * > CUT_BUFFER0 |
2827 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2859 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2828 | * will auto fallback to CUT_BUFFER0 |
2860 | * will auto fallback to CUT_BUFFER0 |
… | |
… | |
2830 | */ |
2862 | */ |
2831 | void |
2863 | void |
2832 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2864 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2833 | { |
2865 | { |
2834 | if (selection.text && selnum == Sel_Primary) |
2866 | if (selection.text && selnum == Sel_Primary) |
|
|
2867 | { |
2835 | { /* internal selection */ |
2868 | /* internal selection */ |
2836 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2869 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2837 | paste (str, strlen (str)); |
2870 | paste (str, strlen (str)); |
2838 | free (str); |
2871 | free (str); |
2839 | return; |
2872 | return; |
2840 | } |
2873 | } |
… | |
… | |
2870 | else if (selnum == Sel_Secondary) |
2903 | else if (selnum == Sel_Secondary) |
2871 | sel = XA_SECONDARY; |
2904 | sel = XA_SECONDARY; |
2872 | else |
2905 | else |
2873 | sel = xa[XA_CLIPBOARD]; |
2906 | sel = xa[XA_CLIPBOARD]; |
2874 | |
2907 | |
2875 | if (XGetSelectionOwner (display->display, sel) != None) |
2908 | if (XGetSelectionOwner (dpy, sel) != None) |
2876 | { |
2909 | { |
2877 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2910 | XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION], |
2878 | vt, selection_request_time); |
2911 | vt, selection_request_time); |
2879 | return 1; |
2912 | return 1; |
2880 | } |
2913 | } |
2881 | |
2914 | |
2882 | return 0; |
2915 | return 0; |
… | |
… | |
2945 | |
2978 | |
2946 | int end_col; |
2979 | int end_col; |
2947 | |
2980 | |
2948 | for (; row <= selection.end.row; row++, col = 0) |
2981 | for (; row <= selection.end.row; row++, col = 0) |
2949 | { |
2982 | { |
2950 | #if ENABLE_FRILLS |
2983 | #if !ENABLE_MINIMAL |
2951 | if (selection.rect) |
2984 | if (selection.rect) |
2952 | { |
2985 | { |
2953 | col = selection.beg.col; |
2986 | col = selection.beg.col; |
2954 | end_col = ncol + 1; |
2987 | end_col = ncol + 1; |
2955 | } |
2988 | } |
… | |
… | |
2958 | end_col = ROW(row).l; |
2991 | end_col = ROW(row).l; |
2959 | |
2992 | |
2960 | col = max (col, 0); |
2993 | col = max (col, 0); |
2961 | |
2994 | |
2962 | if (row == selection.end.row |
2995 | if (row == selection.end.row |
2963 | #if ENABLE_FRILLS |
2996 | #if !ENABLE_MINIMAL |
2964 | || selection.rect |
2997 | || selection.rect |
2965 | #endif |
2998 | #endif |
2966 | ) |
2999 | ) |
2967 | min_it (end_col, selection.end.col); |
3000 | min_it (end_col, selection.end.col); |
2968 | |
3001 | |
… | |
… | |
2991 | #endif |
3024 | #endif |
2992 | else |
3025 | else |
2993 | new_selection_text[ofs++] = *t++; |
3026 | new_selection_text[ofs++] = *t++; |
2994 | } |
3027 | } |
2995 | |
3028 | |
2996 | #if ENABLE_FRILLS |
3029 | #if !ENABLE_MINIMAL |
2997 | if (selection.rect) |
3030 | if (selection.rect) |
2998 | { |
3031 | { |
2999 | while (ofs |
3032 | while (ofs |
3000 | && new_selection_text[ofs - 1] != C0_LF |
3033 | && new_selection_text[ofs - 1] != C0_LF |
3001 | && unicode::is_space (new_selection_text[ofs - 1])) |
3034 | && unicode::is_space (new_selection_text[ofs - 1])) |
… | |
… | |
3035 | bool |
3068 | bool |
3036 | rxvt_term::selection_grab (Time tm) NOTHROW |
3069 | rxvt_term::selection_grab (Time tm) NOTHROW |
3037 | { |
3070 | { |
3038 | selection_time = tm; |
3071 | selection_time = tm; |
3039 | |
3072 | |
3040 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
3073 | XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); |
3041 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
3074 | if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) |
3042 | { |
3075 | { |
3043 | display->set_selection_owner (this); |
3076 | display->set_selection_owner (this); |
3044 | return true; |
3077 | return true; |
3045 | } |
3078 | } |
3046 | else |
3079 | else |
… | |
… | |
3050 | } |
3083 | } |
3051 | |
3084 | |
3052 | #if 0 |
3085 | #if 0 |
3053 | XTextProperty ct; |
3086 | XTextProperty ct; |
3054 | |
3087 | |
3055 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3088 | if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0) |
3056 | { |
3089 | { |
3057 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3090 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3058 | XFree (ct.value); |
3091 | XFree (ct.value); |
3059 | } |
3092 | } |
3060 | #endif |
3093 | #endif |
… | |
… | |
3106 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3139 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3107 | |
3140 | |
3108 | while (selection.mark.col > 0 |
3141 | while (selection.mark.col > 0 |
3109 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3142 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3110 | --selection.mark.col; |
3143 | --selection.mark.col; |
3111 | |
3144 | |
3112 | if (selection.op) |
3145 | if (selection.op) |
|
|
3146 | { |
3113 | { /* clear the old selection */ |
3147 | /* clear the old selection */ |
3114 | selection.beg.row = selection.end.row = selection.mark.row; |
3148 | selection.beg.row = selection.end.row = selection.mark.row; |
3115 | selection.beg.col = selection.end.col = selection.mark.col; |
3149 | selection.beg.col = selection.end.col = selection.mark.col; |
3116 | } |
3150 | } |
3117 | |
3151 | |
3118 | selection.op = SELECTION_INIT; |
3152 | selection.op = SELECTION_INIT; |
… | |
… | |
3307 | * a point/word/line which is either the start or end of the selection |
3341 | * a point/word/line which is either the start or end of the selection |
3308 | * and it was decided by whichever point/word/line was `fixed' at the |
3342 | * and it was decided by whichever point/word/line was `fixed' at the |
3309 | * time of the most recent button3 press |
3343 | * time of the most recent button3 press |
3310 | */ |
3344 | */ |
3311 | if (button3 && buttonpress) |
3345 | if (button3 && buttonpress) |
|
|
3346 | { |
3312 | { /* button3 press */ |
3347 | /* button3 press */ |
3313 | /* |
3348 | /* |
3314 | * first determine which edge of the selection we are closest to |
3349 | * first determine which edge of the selection we are closest to |
3315 | */ |
3350 | */ |
3316 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3351 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3317 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
3352 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
… | |
… | |
3335 | selection.mark.row = selection.beg.row; |
3370 | selection.mark.row = selection.beg.row; |
3336 | selection.mark.col = selection.beg.col; |
3371 | selection.mark.col = selection.beg.col; |
3337 | } |
3372 | } |
3338 | } |
3373 | } |
3339 | else |
3374 | else |
|
|
3375 | { |
3340 | { /* button1 drag or button3 drag */ |
3376 | /* button1 drag or button3 drag */ |
3341 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3377 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3342 | { |
3378 | { |
3343 | if (selection.mark.row == selection.end.row |
3379 | if (selection.mark.row == selection.end.row |
3344 | && selection.mark.col == selection.end.col |
3380 | && selection.mark.col == selection.end.col |
3345 | && clickchange |
3381 | && clickchange |
… | |
… | |
3362 | |
3398 | |
3363 | if (selection.clicks == 1) |
3399 | if (selection.clicks == 1) |
3364 | { |
3400 | { |
3365 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3401 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3366 | && !ROW(selection.beg.row).is_longer () |
3402 | && !ROW(selection.beg.row).is_longer () |
3367 | #if ENABLE_FRILLS |
3403 | #if !ENABLE_MINIMAL |
3368 | && !selection.rect |
3404 | && !selection.rect |
3369 | #endif |
3405 | #endif |
3370 | ) |
3406 | ) |
3371 | selection.beg.col = ncol; |
3407 | selection.beg.col = ncol; |
3372 | |
3408 | |
3373 | if ( |
3409 | if ( |
3374 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3410 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3375 | && !ROW(selection.end.row).is_longer () |
3411 | && !ROW(selection.end.row).is_longer () |
3376 | #if ENABLE_FRILLS |
3412 | #if !ENABLE_MINIMAL |
3377 | && !selection.rect |
3413 | && !selection.rect |
3378 | #endif |
3414 | #endif |
3379 | ) |
3415 | ) |
3380 | selection.end.col = ncol; |
3416 | selection.end.col = ncol; |
3381 | } |
3417 | } |
… | |
… | |
3388 | selection_delimit_word (DN, &selection.end, &selection.end); |
3424 | selection_delimit_word (DN, &selection.end, &selection.end); |
3389 | } |
3425 | } |
3390 | else if (selection.clicks == 3) |
3426 | else if (selection.clicks == 3) |
3391 | { |
3427 | { |
3392 | #if ENABLE_FRILLS |
3428 | #if ENABLE_FRILLS |
3393 | if (OPTION (Opt_tripleclickwords)) |
3429 | if (option (Opt_tripleclickwords)) |
3394 | { |
3430 | { |
3395 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3431 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3396 | |
3432 | |
3397 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3433 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3398 | { |
3434 | { |
3399 | if (!ROW(end_row).is_longer ()) |
3435 | if (!ROW(end_row).is_longer ()) |
3400 | { |
3436 | { |
3401 | selection.end.row = end_row; |
3437 | selection.end.row = end_row; |
3402 | selection.end.col = ROW(end_row).l; |
3438 | selection.end.col = ROW(end_row).l; |
|
|
3439 | # if !ENABLE_MINIMAL |
3403 | selection_remove_trailing_spaces (); |
3440 | selection_remove_trailing_spaces (); |
|
|
3441 | # endif |
3404 | break; |
3442 | break; |
3405 | } |
3443 | } |
3406 | } |
3444 | } |
3407 | } |
3445 | } |
3408 | else |
3446 | else |
… | |
… | |
3424 | selection.end.row++; |
3462 | selection.end.row++; |
3425 | } |
3463 | } |
3426 | } |
3464 | } |
3427 | |
3465 | |
3428 | if (button3 && buttonpress) |
3466 | if (button3 && buttonpress) |
|
|
3467 | { |
3429 | { /* mark may need to be changed */ |
3468 | /* mark may need to be changed */ |
3430 | if (closeto == LEFT) |
3469 | if (closeto == LEFT) |
3431 | { |
3470 | { |
3432 | selection.mark.row = selection.end.row; |
3471 | selection.mark.row = selection.end.row; |
3433 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3472 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3434 | } |
3473 | } |
… | |
… | |
3437 | selection.mark.row = selection.beg.row; |
3476 | selection.mark.row = selection.beg.row; |
3438 | selection.mark.col = selection.beg.col; |
3477 | selection.mark.col = selection.beg.col; |
3439 | } |
3478 | } |
3440 | } |
3479 | } |
3441 | |
3480 | |
3442 | #if ENABLE_FRILLS |
3481 | #if !ENABLE_MINIMAL |
3443 | if (selection.rect && selection.beg.col > selection.end.col) |
3482 | if (selection.rect && selection.beg.col > selection.end.col) |
3444 | ::swap (selection.beg.col, selection.end.col); |
3483 | ::swap (selection.beg.col, selection.end.col); |
3445 | #endif |
3484 | #endif |
3446 | } |
3485 | } |
3447 | |
3486 | |
3448 | #if ENABLE_FRILLS |
3487 | #if !ENABLE_MINIMAL |
3449 | void |
3488 | void |
3450 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3489 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3451 | { |
3490 | { |
3452 | int32_t end_col, end_row; |
3491 | int32_t end_col, end_row; |
3453 | text_t *stp; |
3492 | text_t *stp; |
… | |
… | |
3508 | */ |
3547 | */ |
3509 | void |
3548 | void |
3510 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3549 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3511 | { |
3550 | { |
3512 | XSelectionEvent ev; |
3551 | XSelectionEvent ev; |
3513 | dDisp; |
|
|
3514 | |
3552 | |
3515 | ev.type = SelectionNotify; |
3553 | ev.type = SelectionNotify; |
3516 | ev.property = None; |
3554 | ev.property = None; |
3517 | ev.display = rq.display; |
3555 | ev.display = rq.display; |
3518 | ev.requestor = rq.requestor; |
3556 | ev.requestor = rq.requestor; |
… | |
… | |
3532 | *target++ = xa[XA_COMPOUND_TEXT]; |
3570 | *target++ = xa[XA_COMPOUND_TEXT]; |
3533 | #if X_HAVE_UTF8_STRING |
3571 | #if X_HAVE_UTF8_STRING |
3534 | *target++ = xa[XA_UTF8_STRING]; |
3572 | *target++ = xa[XA_UTF8_STRING]; |
3535 | #endif |
3573 | #endif |
3536 | |
3574 | |
3537 | XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, |
3575 | XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM, |
3538 | 32, PropModeReplace, |
3576 | 32, PropModeReplace, |
3539 | (unsigned char *)target_list, target - target_list); |
3577 | (unsigned char *)target_list, target - target_list); |
3540 | ev.property = rq.property; |
3578 | ev.property = rq.property; |
3541 | } |
3579 | } |
3542 | #if TODO // TODO |
3580 | #if TODO // TODO |
… | |
… | |
3545 | /* TODO: Handle MULTIPLE */ |
3583 | /* TODO: Handle MULTIPLE */ |
3546 | } |
3584 | } |
3547 | #endif |
3585 | #endif |
3548 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3586 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3549 | { |
3587 | { |
3550 | XChangeProperty (disp, rq.requestor, rq.property, rq.target, |
3588 | XChangeProperty (dpy, rq.requestor, rq.property, rq.target, |
3551 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3589 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3552 | ev.property = rq.property; |
3590 | ev.property = rq.property; |
3553 | } |
3591 | } |
3554 | else if (rq.target == XA_STRING |
3592 | else if (rq.target == XA_STRING |
3555 | || rq.target == xa[XA_TEXT] |
3593 | || rq.target == xa[XA_TEXT] |
… | |
… | |
3579 | style = enc_string; |
3617 | style = enc_string; |
3580 | else if (target == xa[XA_TEXT]) |
3618 | else if (target == xa[XA_TEXT]) |
3581 | style = enc_text; |
3619 | style = enc_text; |
3582 | else if (target == xa[XA_COMPOUND_TEXT]) |
3620 | else if (target == xa[XA_COMPOUND_TEXT]) |
3583 | style = enc_compound_text; |
3621 | style = enc_compound_text; |
3584 | #if ENABLE_FRILLS |
3622 | #if !ENABLE_MINIMAL |
3585 | else if (target == xa[XA_UTF8_STRING]) |
3623 | else if (target == xa[XA_UTF8_STRING]) |
3586 | style = enc_utf8; |
3624 | style = enc_utf8; |
3587 | #endif |
3625 | #endif |
3588 | else |
3626 | else |
3589 | { |
3627 | { |
… | |
… | |
3600 | { |
3638 | { |
3601 | cl = L""; |
3639 | cl = L""; |
3602 | selectlen = 0; |
3640 | selectlen = 0; |
3603 | } |
3641 | } |
3604 | |
3642 | |
3605 | #if ENABLE_FRILLS |
3643 | #if !ENABLE_MINIMAL |
3606 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3644 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3607 | // so recode it manually |
3645 | // so recode it manually |
3608 | if (style == enc_utf8) |
3646 | if (style == enc_utf8) |
3609 | { |
3647 | { |
3610 | freect = 1; |
3648 | freect = 1; |
… | |
… | |
3613 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3651 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3614 | ct.nitems = strlen ((char *)ct.value); |
3652 | ct.nitems = strlen ((char *)ct.value); |
3615 | } |
3653 | } |
3616 | else |
3654 | else |
3617 | #endif |
3655 | #endif |
3618 | if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3656 | if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3619 | freect = 1; |
3657 | freect = 1; |
3620 | else |
3658 | else |
3621 | { |
3659 | { |
3622 | /* if we failed to convert then send it raw */ |
3660 | /* if we failed to convert then send it raw */ |
3623 | ct.value = (unsigned char *)cl; |
3661 | ct.value = (unsigned char *)cl; |
3624 | ct.nitems = selectlen; |
3662 | ct.nitems = selectlen; |
3625 | ct.encoding = target; |
3663 | ct.encoding = target; |
3626 | } |
3664 | } |
3627 | |
3665 | |
3628 | XChangeProperty (disp, rq.requestor, rq.property, |
3666 | XChangeProperty (dpy, rq.requestor, rq.property, |
3629 | ct.encoding, 8, PropModeReplace, |
3667 | ct.encoding, 8, PropModeReplace, |
3630 | ct.value, (int)ct.nitems); |
3668 | ct.value, (int)ct.nitems); |
3631 | ev.property = rq.property; |
3669 | ev.property = rq.property; |
3632 | |
3670 | |
3633 | if (freect) |
3671 | if (freect) |
3634 | XFree (ct.value); |
3672 | XFree (ct.value); |
3635 | } |
3673 | } |
3636 | |
3674 | |
3637 | XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); |
3675 | XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); |
3638 | } |
|
|
3639 | |
|
|
3640 | /* ------------------------------------------------------------------------- * |
|
|
3641 | * MOUSE ROUTINES * |
|
|
3642 | * ------------------------------------------------------------------------- */ |
|
|
3643 | |
|
|
3644 | /* |
|
|
3645 | * return col/row values corresponding to x/y pixel values |
|
|
3646 | */ |
|
|
3647 | void |
|
|
3648 | rxvt_term::pixel_position (int *x, int *y) NOTHROW |
|
|
3649 | { |
|
|
3650 | *x = Pixel2Col (*x); |
|
|
3651 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
|
|
3652 | *y = Pixel2Row (*y); |
|
|
3653 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
|
|
3654 | } |
3676 | } |
3655 | |
3677 | |
3656 | /* ------------------------------------------------------------------------- */ |
3678 | /* ------------------------------------------------------------------------- */ |
3657 | #ifdef USE_XIM |
3679 | #ifdef USE_XIM |
3658 | void |
3680 | void |
3659 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3681 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3660 | { |
3682 | { |
3661 | XWindowAttributes xwa; |
3683 | XWindowAttributes xwa; |
3662 | |
3684 | |
3663 | XGetWindowAttributes (display->display, vt, &xwa); |
3685 | XGetWindowAttributes (dpy, vt, &xwa); |
3664 | |
3686 | |
3665 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3687 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3666 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3688 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3667 | } |
3689 | } |
3668 | #endif |
3690 | #endif |
… | |
… | |
3764 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW |
3786 | rxvt_term::scr_overlay_set (int x, int y, const wchar_t *s) NOTHROW |
3765 | { |
3787 | { |
3766 | while (*s) |
3788 | while (*s) |
3767 | { |
3789 | { |
3768 | text_t t = *s++; |
3790 | text_t t = *s++; |
3769 | int width = wcwidth (t); |
3791 | int width = WCWIDTH (t); |
3770 | |
3792 | |
3771 | while (width--) |
3793 | while (width--) |
3772 | { |
3794 | { |
3773 | scr_overlay_set (x++, y, t); |
3795 | scr_overlay_set (x++, y, t); |
3774 | t = NOCHAR; |
3796 | t = NOCHAR; |