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, do wcwidth before |
835 | // rely on wcwidth to tell us the character width, do wcwidth before |
848 | // further replacements, as wcwidth might return -1 for the line |
836 | // further replacements, as wcwidth might return -1 for the line |
849 | // 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 = 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 | } |
… | |
… | |
1619 | */ |
1631 | */ |
1620 | void |
1632 | void |
1621 | rxvt_term::scr_set_tab (int mode) NOTHROW |
1633 | rxvt_term::scr_set_tab (int mode) NOTHROW |
1622 | { |
1634 | { |
1623 | if (mode < 0) |
1635 | if (mode < 0) |
1624 | memset (tabs, 0, ncol * sizeof (char)); |
1636 | memset (tabs, 0, ncol); |
1625 | else if (screen.cur.col < ncol) |
1637 | else if (screen.cur.col < ncol) |
1626 | tabs [screen.cur.col] = !!mode; |
1638 | tabs [screen.cur.col] = !!mode; |
1627 | } |
1639 | } |
1628 | |
1640 | |
1629 | /* ------------------------------------------------------------------------- */ |
1641 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1644 | if (rvideo_state != on) |
1656 | if (rvideo_state != on) |
1645 | { |
1657 | { |
1646 | rvideo_state = on; |
1658 | rvideo_state = on; |
1647 | |
1659 | |
1648 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1660 | ::swap (pix_colors[Color_fg], pix_colors[Color_bg]); |
1649 | #if XPM_BACKGROUND |
1661 | #ifdef HAVE_BG_PIXMAP |
1650 | if (bgPixmap.pixmap == None) |
1662 | if (bgPixmap.pixmap == None) |
1651 | #endif |
1663 | #endif |
1652 | #if TRANSPARENT |
|
|
1653 | if (!OPTION (Opt_transparent) || am_transparent == 0) |
|
|
1654 | #endif |
|
|
1655 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
1664 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
1656 | |
1665 | |
1657 | XGCValues gcvalue; |
1666 | XGCValues gcvalue; |
1658 | gcvalue.foreground = pix_colors[Color_fg]; |
1667 | gcvalue.foreground = pix_colors[Color_fg]; |
1659 | gcvalue.background = pix_colors[Color_bg]; |
1668 | gcvalue.background = pix_colors[Color_bg]; |
1660 | XChangeGC (display->display, gc, GCBackground | GCForeground, &gcvalue); |
1669 | XChangeGC (dpy, gc, GCBackground | GCForeground, &gcvalue); |
1661 | |
1670 | |
1662 | scr_clear (); |
1671 | scr_clear (); |
1663 | scr_touch (true); |
1672 | scr_touch (true); |
1664 | } |
1673 | } |
1665 | } |
1674 | } |
… | |
… | |
1750 | { |
1759 | { |
1751 | bool found = false; |
1760 | bool found = false; |
1752 | |
1761 | |
1753 | for (int i = 0; i < nrow; i++) |
1762 | for (int i = 0; i < nrow; i++) |
1754 | { |
1763 | { |
1755 | int col = 0; |
|
|
1756 | rend_t *drp = drawn_buf[i].r; |
1764 | rend_t *drp = drawn_buf[i].r; |
1757 | |
1765 | |
1758 | for (; col < ncol; col++, drp++) |
1766 | for (int col = 0; col < ncol; col++, drp++) |
1759 | if ((*drp & mask) == value) |
1767 | if ((*drp & mask) == value) |
1760 | { |
1768 | { |
1761 | found = true; |
1769 | found = true; |
1762 | *drp = ~value; |
1770 | *drp = ~value; |
1763 | } |
1771 | } |
… | |
… | |
1803 | for (i = PART_BEG; i < RC_COUNT; i++) |
1811 | for (i = PART_BEG; i < RC_COUNT; i++) |
1804 | { |
1812 | { |
1805 | min_it (rc[i].col, ncol - 1); |
1813 | min_it (rc[i].col, ncol - 1); |
1806 | min_it (rc[i].row, nrow - 1); |
1814 | min_it (rc[i].row, nrow - 1); |
1807 | } |
1815 | } |
1808 | |
1816 | // 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++) |
1817 | 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); |
1818 | fill_text (&drawn_buf[i].t[rc[PART_BEG].col], 0, rc[PART_END].col - rc[PART_BEG].col + 1); |
1811 | |
1819 | |
1812 | num_scr_allow = 0; |
1820 | num_scr_allow = 0; |
1813 | |
1821 | |
… | |
… | |
1868 | return true; |
1876 | return true; |
1869 | } |
1877 | } |
1870 | |
1878 | |
1871 | #ifndef NO_BELL |
1879 | #ifndef NO_BELL |
1872 | void |
1880 | void |
1873 | rxvt_term::bell_cb (time_watcher &w) |
1881 | rxvt_term::bell_cb (ev::timer &w, int revents) |
1874 | { |
1882 | { |
1875 | rvideo_bell = false; |
1883 | rvideo_bell = false; |
1876 | scr_rvideo_mode (rvideo_mode); |
1884 | scr_rvideo_mode (rvideo_mode); |
|
|
1885 | refresh_check (); |
1877 | } |
1886 | } |
1878 | #endif |
1887 | #endif |
1879 | |
1888 | |
1880 | /* ------------------------------------------------------------------------- */ |
1889 | /* ------------------------------------------------------------------------- */ |
1881 | void |
1890 | void |
… | |
… | |
1883 | { |
1892 | { |
1884 | #ifndef NO_BELL |
1893 | #ifndef NO_BELL |
1885 | |
1894 | |
1886 | # ifndef NO_MAPALERT |
1895 | # ifndef NO_MAPALERT |
1887 | # ifdef MAPALERT_OPTION |
1896 | # ifdef MAPALERT_OPTION |
1888 | if (OPTION (Opt_mapAlert)) |
1897 | if (option (Opt_mapAlert)) |
1889 | # endif |
1898 | # endif |
1890 | XMapWindow (display->display, parent[0]); |
1899 | XMapWindow (dpy, parent[0]); |
1891 | # endif |
1900 | # endif |
1892 | |
1901 | |
|
|
1902 | # if ENABLE_FRILLS |
|
|
1903 | if (option (Opt_urgentOnBell)) |
|
|
1904 | { |
|
|
1905 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1906 | { |
|
|
1907 | h->flags |= XUrgencyHint; |
|
|
1908 | XSetWMHints (dpy, parent[0], h); |
|
|
1909 | } |
|
|
1910 | } |
|
|
1911 | # endif |
|
|
1912 | |
1893 | if (OPTION (Opt_visualBell)) |
1913 | if (option (Opt_visualBell)) |
1894 | { |
1914 | { |
1895 | rvideo_bell = true; |
1915 | rvideo_bell = true; |
1896 | scr_rvideo_mode (rvideo_mode); |
1916 | scr_rvideo_mode (rvideo_mode); |
1897 | display->flush (); |
1917 | flush (); |
1898 | |
1918 | |
1899 | bell_ev.start (NOW + VISUAL_BELL_DURATION); |
1919 | bell_ev.start (VISUAL_BELL_DURATION); |
1900 | } |
1920 | } |
1901 | else |
1921 | else |
1902 | XBell (display->display, 0); |
1922 | XBell (dpy, 0); |
1903 | |
|
|
1904 | #endif |
1923 | #endif |
1905 | } |
1924 | } |
1906 | |
1925 | |
1907 | /* ------------------------------------------------------------------------- */ |
1926 | /* ------------------------------------------------------------------------- */ |
1908 | /* ARGSUSED */ |
1927 | /* ARGSUSED */ |
1909 | void |
1928 | void |
1910 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1929 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1911 | { |
1930 | { |
1912 | #ifdef PRINTPIPE |
1931 | #ifdef PRINTPIPE |
1913 | int nrows, row_start; |
1932 | int nrows, row_start; |
1914 | FILE *fd; |
1933 | FILE *fd = popen_printer (); |
1915 | |
1934 | |
1916 | if ((fd = popen_printer ()) == NULL) |
1935 | if (!fd) |
1917 | return; |
1936 | return; |
1918 | |
1937 | |
1919 | if (fullhist) |
1938 | if (fullhist) |
1920 | { |
1939 | { |
1921 | nrows = nrow - top_row; |
1940 | nrows = nrow - top_row; |
… | |
… | |
1966 | * screen.text/screen.rend contain what the screen will change to. |
1985 | * screen.text/screen.rend contain what the screen will change to. |
1967 | */ |
1986 | */ |
1968 | void |
1987 | void |
1969 | rxvt_term::scr_refresh () NOTHROW |
1988 | rxvt_term::scr_refresh () NOTHROW |
1970 | { |
1989 | { |
1971 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1990 | unsigned char have_bg, |
1972 | showcursor; /* show the cursor */ |
1991 | showcursor; /* show the cursor */ |
1973 | int16_t col, row, /* column/row we're processing */ |
1992 | int16_t col, row, /* column/row we're processing */ |
1974 | ocrow; /* old cursor row */ |
1993 | ocrow; /* old cursor row */ |
1975 | int i; /* tmp */ |
1994 | int i; /* tmp */ |
1976 | #ifndef NO_CURSORCOLOR |
1995 | #ifndef NO_CURSORCOLOR |
1977 | rend_t cc1; /* store colours at cursor position (s) */ |
1996 | rend_t cc1; /* store colours at cursor position (s) */ |
1978 | #endif |
1997 | #endif |
1979 | rend_t *crp; // cursor rendition pointer |
1998 | rend_t *crp; // cursor rendition pointer |
|
|
1999 | rend_t ccol1, /* Cursor colour */ |
|
|
2000 | ccol2; /* Cursor colour2 */ |
1980 | |
2001 | |
1981 | want_refresh = 0; /* screen is current */ |
2002 | want_refresh = 0; /* screen is current */ |
1982 | |
2003 | |
1983 | if (refresh_type == NO_REFRESH || !mapped) |
2004 | if (refresh_type == NO_REFRESH || !mapped) |
1984 | return; |
2005 | return; |
1985 | |
2006 | |
1986 | /* |
2007 | /* |
1987 | * A: set up vars |
2008 | * A: set up vars |
1988 | */ |
2009 | */ |
1989 | must_clear = 0; |
|
|
1990 | refresh_count = 0; |
2010 | refresh_count = 0; |
1991 | |
2011 | |
1992 | #if XPM_BACKGROUND |
2012 | have_bg = 0; |
|
|
2013 | #ifdef HAVE_BG_PIXMAP |
1993 | must_clear |= bgPixmap.pixmap != None; |
2014 | have_bg = bgPixmap.pixmap != None; |
1994 | #endif |
|
|
1995 | #if TRANSPARENT |
|
|
1996 | must_clear |= OPTION (Opt_transparent) && am_transparent; |
|
|
1997 | #endif |
2015 | #endif |
1998 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2016 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1999 | |
2017 | |
2000 | /* |
2018 | /* |
2001 | * B: reverse any characters which are selected |
2019 | * B: reverse any characters which are selected |
… | |
… | |
2005 | /* |
2023 | /* |
2006 | * C: set the cursor character (s) |
2024 | * C: set the cursor character (s) |
2007 | */ |
2025 | */ |
2008 | { |
2026 | { |
2009 | unsigned char setoldcursor; |
2027 | unsigned char setoldcursor; |
2010 | rend_t ccol1, /* Cursor colour */ |
|
|
2011 | ccol2; /* Cursor colour2 */ |
|
|
2012 | |
2028 | |
2013 | showcursor = (screen.flags & Screen_VisibleCursor); |
2029 | showcursor = (screen.flags & Screen_VisibleCursor); |
2014 | #ifdef CURSOR_BLINK |
2030 | #ifdef CURSOR_BLINK |
2015 | if (hidden_cursor) |
2031 | if (hidden_cursor) |
2016 | showcursor = 0; |
2032 | showcursor = 0; |
… | |
… | |
2023 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2039 | while (col && ROW(screen.cur.row).t[col] == NOCHAR) |
2024 | col--; |
2040 | col--; |
2025 | |
2041 | |
2026 | crp = &ROW(screen.cur.row).r[col]; |
2042 | crp = &ROW(screen.cur.row).r[col]; |
2027 | |
2043 | |
|
|
2044 | #ifndef NO_CURSORCOLOR |
|
|
2045 | cc1 = *crp & (RS_fgMask | RS_bgMask); |
|
|
2046 | if (ISSET_PIXCOLOR (Color_cursor)) |
|
|
2047 | ccol1 = Color_cursor; |
|
|
2048 | else |
|
|
2049 | #endif |
|
|
2050 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2051 | ccol1 = fgcolor_of (rstyle); |
|
|
2052 | #else |
|
|
2053 | ccol1 = Color_fg; |
|
|
2054 | #endif |
|
|
2055 | |
|
|
2056 | #ifndef NO_CURSORCOLOR |
|
|
2057 | if (ISSET_PIXCOLOR (Color_cursor2)) |
|
|
2058 | ccol2 = Color_cursor2; |
|
|
2059 | else |
|
|
2060 | #endif |
|
|
2061 | #ifdef CURSOR_COLOR_IS_RENDITION_COLOR |
|
|
2062 | ccol2 = bgcolor_of (rstyle); |
|
|
2063 | #else |
|
|
2064 | ccol2 = Color_bg; |
|
|
2065 | #endif |
|
|
2066 | |
2028 | if (showcursor && focus) |
2067 | if (showcursor && focus) |
2029 | { |
2068 | { |
2030 | if (OPTION (Opt_cursorUnderline)) |
2069 | if (option (Opt_cursorUnderline)) |
2031 | *crp ^= RS_Uline; |
2070 | *crp ^= RS_Uline; |
2032 | else |
2071 | else |
2033 | { |
2072 | { |
2034 | *crp ^= RS_RVid; |
2073 | *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); |
2074 | *crp = SET_FGCOLOR (*crp, ccol1); |
2055 | *crp = SET_BGCOLOR (*crp, ccol2); |
2075 | *crp = SET_BGCOLOR (*crp, ccol2); |
2056 | #endif |
|
|
2057 | } |
2076 | } |
2058 | } |
2077 | } |
2059 | } |
2078 | } |
2060 | |
2079 | |
2061 | /* make sure no outline cursor is left around */ |
2080 | /* make sure no outline cursor is left around */ |
… | |
… | |
2100 | * D: CopyArea pass - very useful for slower links |
2119 | * D: CopyArea pass - very useful for slower links |
2101 | * This has been deliberately kept simple. |
2120 | * This has been deliberately kept simple. |
2102 | */ |
2121 | */ |
2103 | if (!display->is_local |
2122 | if (!display->is_local |
2104 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2123 | && refresh_type == FAST_REFRESH && num_scr_allow && num_scr |
2105 | && abs (num_scr) < nrow && !must_clear) |
2124 | && abs (num_scr) < nrow && !have_bg) |
2106 | { |
2125 | { |
2107 | int16_t nits; |
2126 | int16_t nits; |
|
|
2127 | int i = num_scr; |
2108 | int j; |
2128 | int j; |
2109 | int len, wlen; |
2129 | int len, wlen; |
2110 | dLocal (int, num_scr); |
2130 | dLocal (int, num_scr); |
2111 | |
2131 | |
2112 | j = nrow; |
2132 | j = nrow; |
2113 | wlen = len = -1; |
2133 | wlen = len = -1; |
2114 | row = i > 0 ? 0 : j - 1; |
2134 | row = i > 0 ? 0 : j - 1; |
|
|
2135 | |
2115 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2136 | for (; j-- >= 0; row += (i > 0 ? 1 : -1)) |
2116 | { |
2137 | { |
2117 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2138 | if (row + i >= 0 && row + i < nrow && row + i != ocrow) |
2118 | { |
2139 | { |
2119 | line_t s = ROW(view_start + row); |
2140 | line_t s = ROW(view_start + row); |
… | |
… | |
2140 | wlen = row; |
2161 | wlen = row; |
2141 | continue; |
2162 | continue; |
2142 | } |
2163 | } |
2143 | } |
2164 | } |
2144 | |
2165 | |
2145 | if (len != -1) |
2166 | if (len >= 0) |
2146 | { |
2167 | { |
2147 | /* also comes here at end if needed because of >= above */ |
2168 | /* also comes here at end if needed because of >= above */ |
2148 | if (wlen < len) |
2169 | if (wlen < len) |
2149 | ::swap (wlen, len); |
2170 | ::swap (wlen, len); |
2150 | |
2171 | |
|
|
2172 | XGCValues gcv; |
|
|
2173 | |
|
|
2174 | gcv.graphics_exposures = 1; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
2151 | XCopyArea (display->display, vt, vt, |
2175 | XCopyArea (dpy, vt, vt, |
2152 | gc, 0, Row2Pixel (len + i), |
2176 | gc, 0, Row2Pixel (len + i), |
2153 | (unsigned int)this->width, |
2177 | (unsigned int)this->width, |
2154 | (unsigned int)Height2Pixel (wlen - len + 1), |
2178 | (unsigned int)Height2Pixel (wlen - len + 1), |
2155 | 0, Row2Pixel (len)); |
2179 | 0, Row2Pixel (len)); |
|
|
2180 | gcv.graphics_exposures = 0; XChangeGC (dpy, gc, GCGraphicsExposures, &gcv); |
|
|
2181 | |
2156 | len = -1; |
2182 | len = -1; |
2157 | } |
2183 | } |
2158 | } |
2184 | } |
2159 | } |
2185 | } |
2160 | #endif |
2186 | #endif |
… | |
… | |
2184 | continue; |
2210 | continue; |
2185 | |
2211 | |
2186 | // redraw one or more characters |
2212 | // redraw one or more characters |
2187 | |
2213 | |
2188 | // seek to the beginning of wide characters |
2214 | // seek to the beginning of wide characters |
2189 | while (stp[col] == NOCHAR && col > 0) |
2215 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2190 | --col; |
2216 | --col; |
2191 | |
2217 | |
2192 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2218 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2193 | text_t *text = stp + col; |
2219 | text_t *text = stp + col; |
2194 | int count = 1; |
2220 | int count = 1; |
… | |
… | |
2216 | count++; |
2242 | count++; |
2217 | |
2243 | |
2218 | if (stp[col] != dtp[col] |
2244 | if (stp[col] != dtp[col] |
2219 | || !RS_SAME (srp[col], drp[col])) |
2245 | || !RS_SAME (srp[col], drp[col])) |
2220 | { |
2246 | { |
2221 | if (must_clear && (i++ > count / 2)) |
2247 | if (have_bg && (i++ > count / 2)) |
2222 | break; |
2248 | break; |
2223 | |
2249 | |
2224 | dtp[col] = stp[col]; |
2250 | dtp[col] = stp[col]; |
2225 | drp[col] = rend; |
2251 | drp[col] = rend; |
2226 | i = 0; |
2252 | i = 0; |
2227 | } |
2253 | } |
2228 | else if (must_clear || (stp[col] != ' ' && ++i >= 16)) |
2254 | else if (have_bg || (stp[col] != ' ' && ++i >= 16)) |
2229 | break; |
2255 | break; |
2230 | } |
2256 | } |
2231 | |
2257 | |
2232 | col--; /* went one too far. move back */ |
2258 | col--; /* went one too far. move back */ |
2233 | count -= i; /* dump any matching trailing chars */ |
2259 | count -= i; /* dump any matching trailing chars */ |
2234 | |
2260 | |
2235 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2261 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2236 | while (i && text[count] == NOCHAR) |
2262 | while (expect_false (i && text[count] == NOCHAR)) |
2237 | count++, i--; |
2263 | count++, i--; |
2238 | |
2264 | |
2239 | /* |
2265 | /* |
2240 | * Determine the attributes for the string |
2266 | * Determine the attributes for the string |
2241 | */ |
2267 | */ |
2242 | int fore = fgcolor_of (rend); // desired foreground |
2268 | int fore = fgcolor_of (rend); // desired foreground |
2243 | int back = bgcolor_of (rend); // desired background |
2269 | int back = bgcolor_of (rend); // desired background |
2244 | |
2270 | |
2245 | // only do special processing if any attributes are set, which is unlikely |
2271 | // 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)) |
2272 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2247 | { |
2273 | { |
2248 | #if ENABLE_STYLES |
|
|
2249 | // "careful" (too wide) character handling |
|
|
2250 | |
|
|
2251 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2252 | while (text > stp |
|
|
2253 | && srp[text - stp - 1] & RS_Careful |
|
|
2254 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2255 | text--, count++, xpixel -= fwidth; |
|
|
2256 | |
|
|
2257 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2258 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2259 | drp[col + i + 1] = ~srp[col + i + 1]; |
|
|
2260 | |
|
|
2261 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2262 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2263 | drp[text - stp - i - 1] = ~srp[text - stp - i - 1]; |
|
|
2264 | #endif |
|
|
2265 | |
|
|
2266 | bool invert = rend & RS_RVid; |
2274 | bool invert = rend & RS_RVid; |
2267 | |
2275 | |
2268 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2276 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2269 | if (rend & RS_Bold |
|
|
2270 | && fore == Color_fg) |
2277 | if (rend & RS_Bold && fore == Color_fg) |
2271 | { |
2278 | { |
2272 | if (ISSET_PIXCOLOR (Color_BD)) |
2279 | if (ISSET_PIXCOLOR (Color_BD)) |
2273 | fore = Color_BD; |
2280 | fore = Color_BD; |
2274 | # if !ENABLE_STYLES |
2281 | # if !ENABLE_STYLES |
2275 | else |
2282 | else |
2276 | invert = !invert; |
2283 | invert = !invert; |
2277 | # endif |
2284 | # endif |
2278 | } |
2285 | } |
2279 | |
2286 | |
2280 | if (rend & RS_Italic |
2287 | if (rend & RS_Italic && fore == Color_fg) |
2281 | && fore == Color_fg) |
|
|
2282 | { |
2288 | { |
2283 | if (ISSET_PIXCOLOR (Color_IT)) |
2289 | if (ISSET_PIXCOLOR (Color_IT)) |
2284 | fore = Color_IT; |
2290 | fore = Color_IT; |
2285 | # if !ENABLE_STYLES |
2291 | # if !ENABLE_STYLES |
2286 | else |
2292 | else |
2287 | invert = !invert; |
2293 | invert = !invert; |
2288 | # endif |
2294 | # endif |
2289 | } |
2295 | } |
2290 | |
2296 | |
2291 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
2297 | if (rend & RS_Uline && fore == Color_fg && ISSET_PIXCOLOR (Color_UL)) |
2292 | fore = Color_UL; |
2298 | fore = Color_UL; |
2293 | #endif |
2299 | #endif |
2294 | |
2300 | |
2295 | if (invert) |
2301 | if (invert) |
2296 | { |
2302 | { |
|
|
2303 | #ifdef OPTION_HC |
|
|
2304 | if ((showcursor && row == screen.cur.row && text - stp == screen.cur.col) |
|
|
2305 | || !ISSET_PIXCOLOR (Color_HC)) |
|
|
2306 | #endif |
|
|
2307 | /* invert the column if no highlightColor is set or it is the |
|
|
2308 | * current cursor column */ |
2297 | ::swap (fore, back); |
2309 | ::swap (fore, back); |
|
|
2310 | #ifdef OPTION_HC |
|
|
2311 | else if (ISSET_PIXCOLOR (Color_HC)) |
|
|
2312 | back = Color_HC; |
|
|
2313 | #endif |
2298 | |
2314 | |
2299 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2315 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2316 | # ifndef OPTION_HC |
2300 | if (ISSET_PIXCOLOR (Color_RV)) |
2317 | if (ISSET_PIXCOLOR (Color_RV)) |
2301 | back = Color_RV; |
2318 | back = Color_RV; |
2302 | |
2319 | # endif |
2303 | if (fore == back) |
2320 | if (fore == back) |
2304 | { |
2321 | { |
2305 | fore = Color_bg; |
2322 | fore = Color_bg; |
2306 | back = Color_fg; |
2323 | back = Color_fg; |
2307 | } |
2324 | } |
… | |
… | |
2309 | } |
2326 | } |
2310 | |
2327 | |
2311 | #ifdef TEXT_BLINK |
2328 | #ifdef TEXT_BLINK |
2312 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2329 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
2313 | { |
2330 | { |
2314 | if (!text_blink_ev.active) |
2331 | if (!text_blink_ev.is_active ()) |
2315 | { |
2332 | { |
2316 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
2333 | text_blink_ev.again (); |
2317 | hidden_text = 0; |
2334 | hidden_text = 0; |
2318 | } |
2335 | } |
2319 | else if (hidden_text) |
2336 | else if (hidden_text) |
2320 | fore = back; |
2337 | fore = back; |
2321 | } |
2338 | } |
2322 | #endif |
2339 | #endif |
|
|
2340 | |
|
|
2341 | #if ENABLE_STYLES |
|
|
2342 | // "careful" (too wide) character handling |
|
|
2343 | |
|
|
2344 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2345 | while (text > stp |
|
|
2346 | && srp[text - stp - 1] & RS_Careful |
|
|
2347 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2348 | text--, count++, xpixel -= fwidth; |
|
|
2349 | |
|
|
2350 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2351 | for (int i = 0; srp[col + i] & RS_Careful && col + i < ncol - 1; i++) |
|
|
2352 | drp[col + i + 1] = srp[col + i + 1] ^ RS_redraw; |
|
|
2353 | |
|
|
2354 | // force redraw before "careful" characters to avoid pixel droppings |
|
|
2355 | for (int i = 0; srp[text - stp - i] & RS_Careful && text - i > stp; i++) |
|
|
2356 | drp[text - stp - i - 1] = srp[text - stp - i - 1] ^ RS_redraw; |
|
|
2357 | #endif |
2323 | } |
2358 | } |
2324 | |
2359 | |
2325 | /* |
2360 | /* |
2326 | * Actually do the drawing of the string here |
2361 | * Actually do the drawing of the string here |
2327 | */ |
2362 | */ |
2328 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2363 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2329 | |
2364 | |
2330 | if (back == fore) |
2365 | if (expect_true (have_bg && back == Color_bg)) |
2331 | font->clear_rect (*drawable, xpixel, ypixel, |
|
|
2332 | fwidth * count, fheight, |
|
|
2333 | back); |
|
|
2334 | else if (back == Color_bg) |
|
|
2335 | { |
2366 | { |
2336 | if (must_clear) |
2367 | // this is very ugly, maybe push it into ->draw? |
2337 | { |
|
|
2338 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2339 | |
2368 | |
2340 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2369 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2341 | if (text[i] != ' ') |
2370 | if (text[i] != ' ') |
2342 | { |
2371 | { |
2343 | font->draw (*drawable, xpixel, ypixel, text, count, fore, -1); |
2372 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_transparent); |
2344 | break; |
2373 | goto did_clear; |
2345 | } |
|
|
2346 | } |
2374 | } |
2347 | else |
2375 | |
2348 | font->draw (*drawable, xpixel, ypixel, text, count, fore, Color_bg); |
2376 | CLEAR_CHARS (xpixel, ypixel, count); |
|
|
2377 | did_clear: ; |
2349 | } |
2378 | } |
2350 | else |
2379 | else |
2351 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2380 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2352 | |
2381 | |
2353 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2382 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2354 | { |
2383 | { |
2355 | #if ENABLE_FRILLS |
2384 | #if ENABLE_FRILLS |
2356 | if (ISSET_PIXCOLOR (Color_underline)) |
2385 | if (ISSET_PIXCOLOR (Color_underline)) |
2357 | XSetForeground (display->display, gc, pix_colors[Color_underline]); |
2386 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2358 | else |
2387 | else |
2359 | #endif |
2388 | #endif |
2360 | XSetForeground (display->display, gc, pix_colors[fore]); |
2389 | XSetForeground (dpy, gc, pix_colors[fore]); |
2361 | |
2390 | |
2362 | XDrawLine (display->display, drawBuffer, gc, |
2391 | XDrawLine (dpy, vt, gc, |
2363 | xpixel, ypixel + font->ascent + 1, |
2392 | xpixel, ypixel + font->ascent + 1, |
2364 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2393 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2365 | } |
2394 | } |
2366 | } /* for (col....) */ |
2395 | } /* for (col....) */ |
2367 | } /* for (row....) */ |
2396 | } /* for (row....) */ |
… | |
… | |
2376 | */ |
2405 | */ |
2377 | if (showcursor) |
2406 | if (showcursor) |
2378 | { |
2407 | { |
2379 | if (focus) |
2408 | if (focus) |
2380 | { |
2409 | { |
2381 | if (OPTION (Opt_cursorUnderline)) |
2410 | if (option (Opt_cursorUnderline)) |
2382 | *crp ^= RS_Uline; |
2411 | *crp ^= RS_Uline; |
2383 | else |
2412 | else |
2384 | { |
2413 | { |
2385 | *crp ^= RS_RVid; |
2414 | *crp ^= RS_RVid; |
2386 | #ifndef NO_CURSORCOLOR |
2415 | #ifndef NO_CURSORCOLOR |
… | |
… | |
2400 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2429 | && drawn_buf[oldcursor.row].t[col + cursorwidth] == NOCHAR) |
2401 | cursorwidth++; |
2430 | cursorwidth++; |
2402 | |
2431 | |
2403 | #ifndef NO_CURSORCOLOR |
2432 | #ifndef NO_CURSORCOLOR |
2404 | if (ISSET_PIXCOLOR (Color_cursor)) |
2433 | if (ISSET_PIXCOLOR (Color_cursor)) |
2405 | XSetForeground (display->display, gc, pix_colors[Color_cursor]); |
2434 | XSetForeground (dpy, gc, pix_colors[Color_cursor]); |
|
|
2435 | else |
2406 | #endif |
2436 | #endif |
|
|
2437 | XSetForeground (dpy, gc, pix_colors[ccol1]); |
2407 | |
2438 | |
2408 | XDrawRectangle (display->display, drawBuffer, gc, |
2439 | XDrawRectangle (dpy, vt, gc, |
2409 | Col2Pixel (col), |
2440 | Col2Pixel (col), |
2410 | Row2Pixel (oldcursor.row), |
2441 | Row2Pixel (oldcursor.row), |
2411 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2442 | (unsigned int) (Width2Pixel (cursorwidth) - 1), |
2412 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2443 | (unsigned int) (Height2Pixel (1) - lineSpace - 1)); |
2413 | } |
2444 | } |
… | |
… | |
2448 | } |
2479 | } |
2449 | |
2480 | |
2450 | void |
2481 | void |
2451 | rxvt_term::scr_recolour () NOTHROW |
2482 | rxvt_term::scr_recolour () NOTHROW |
2452 | { |
2483 | { |
2453 | if (1 |
2484 | #ifdef HAVE_BG_PIXMAP |
2454 | #if TRANSPARENT |
2485 | bgPixmap.apply (); |
2455 | && !am_transparent |
2486 | #else |
2456 | #endif |
2487 | |
2457 | #if XPM_BACKGROUND |
|
|
2458 | && !bgPixmap.pixmap |
|
|
2459 | #endif |
|
|
2460 | ) |
|
|
2461 | { |
|
|
2462 | XSetWindowBackground (display->display, parent[0], pix_colors[Color_border]); |
2488 | XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); |
2463 | XClearWindow (display->display, parent[0]); |
2489 | XClearWindow (dpy, parent[0]); |
2464 | XSetWindowBackground (display->display, vt, pix_colors[Color_bg]); |
2490 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2465 | #if HAVE_SCROLLBARS |
2491 | |
2466 | if (scrollBar.win) |
2492 | if (scrollBar.win) |
2467 | { |
2493 | { |
2468 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
2494 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2469 | scrollBar.setIdle (); |
2495 | scrollBar.state = STATE_IDLE; |
2470 | scrollbar_show (0); |
2496 | scrollBar.show (0); |
2471 | } |
|
|
2472 | #endif |
|
|
2473 | } |
2497 | } |
2474 | |
2498 | |
|
|
2499 | #endif |
|
|
2500 | |
|
|
2501 | /* bgPixmap.apply () does not do the following : */ |
2475 | scr_clear (); |
2502 | scr_clear (); |
2476 | scr_touch (true); |
2503 | scr_touch (true); |
2477 | want_refresh = 1; |
2504 | want_refresh = 1; |
2478 | } |
2505 | } |
2479 | |
2506 | |
… | |
… | |
2486 | |
2513 | |
2487 | num_scr_allow = 0; |
2514 | num_scr_allow = 0; |
2488 | want_refresh = 1; |
2515 | want_refresh = 1; |
2489 | |
2516 | |
2490 | if (really) |
2517 | if (really) |
2491 | XClearWindow (display->display, vt); |
2518 | XClearWindow (dpy, vt); |
2492 | } |
2519 | } |
2493 | |
2520 | |
2494 | void |
2521 | void |
2495 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
2522 | rxvt_term::scr_xor_rect (int beg_row, int beg_col, int end_row, int end_col, rend_t rstyle1, rend_t rstyle2) NOTHROW |
2496 | { |
2523 | { |
… | |
… | |
2545 | { |
2572 | { |
2546 | if (selection.op |
2573 | if (selection.op |
2547 | && current_screen == selection.screen |
2574 | && current_screen == selection.screen |
2548 | && selection.end.row >= view_start) |
2575 | && selection.end.row >= view_start) |
2549 | { |
2576 | { |
2550 | #if ENABLE_FRILLS |
2577 | #if !ENABLE_MINIMAL |
2551 | if (selection.rect) |
2578 | if (selection.rect) |
2552 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2579 | scr_xor_rect (selection.beg.row, selection.beg.col, |
2553 | selection.end.row, selection.end.col, |
2580 | selection.end.row, selection.end.col, |
2554 | RS_RVid, RS_RVid | RS_Uline); |
2581 | RS_RVid, RS_RVid | RS_Uline); |
2555 | else |
2582 | else |
… | |
… | |
2571 | { |
2598 | { |
2572 | int row, wrote; |
2599 | int row, wrote; |
2573 | unsigned int width, towrite; |
2600 | unsigned int width, towrite; |
2574 | char r1[] = "\n"; |
2601 | char r1[] = "\n"; |
2575 | |
2602 | |
2576 | for (row = saveLines - nsaved; |
2603 | for (row = saveLines + top_row; |
2577 | row < saveLines + nrow - 1; row++) |
2604 | row < saveLines + nrow - 1; row++) |
2578 | { |
2605 | { |
2579 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2606 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2580 | : ncol; |
2607 | : ncol; |
2581 | for (towrite = width; towrite; towrite -= wrote) |
2608 | for (towrite = width; towrite; towrite -= wrote) |
… | |
… | |
2632 | /* convert normal newline chars into common keyboard Return key sequence */ |
2659 | /* convert normal newline chars into common keyboard Return key sequence */ |
2633 | for (unsigned int i = 0; i < len; i++) |
2660 | for (unsigned int i = 0; i < len; i++) |
2634 | if (data[i] == C0_LF) |
2661 | if (data[i] == C0_LF) |
2635 | data[i] = C0_CR; |
2662 | data[i] = C0_CR; |
2636 | |
2663 | |
|
|
2664 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2665 | tt_printf ("\e[200~"); |
|
|
2666 | |
2637 | tt_write (data, len); |
2667 | tt_write (data, len); |
|
|
2668 | |
|
|
2669 | if (priv_modes & PrivMode_BracketPaste) |
|
|
2670 | tt_printf ("\e[201~"); |
2638 | } |
2671 | } |
2639 | |
2672 | |
2640 | /* ------------------------------------------------------------------------- */ |
2673 | /* ------------------------------------------------------------------------- */ |
2641 | /* |
2674 | /* |
2642 | * Respond to a notification that a primary selection has been sent |
2675 | * Respond to a notification that a primary selection has been sent |
… | |
… | |
2671 | } |
2704 | } |
2672 | |
2705 | |
2673 | unsigned long bytes_after; |
2706 | unsigned long bytes_after; |
2674 | XTextProperty ct; |
2707 | XTextProperty ct; |
2675 | |
2708 | |
2676 | if (XGetWindowProperty (display->display, win, prop, |
2709 | if (XGetWindowProperty (dpy, win, prop, |
2677 | 0, PROP_SIZE / 4, |
2710 | 0, PROP_SIZE / 4, |
2678 | delete_prop, AnyPropertyType, |
2711 | delete_prop, AnyPropertyType, |
2679 | &ct.encoding, &ct.format, |
2712 | &ct.encoding, &ct.format, |
2680 | &ct.nitems, &bytes_after, |
2713 | &ct.nitems, &bytes_after, |
2681 | &ct.value) != Success) |
2714 | &ct.value) != Success) |
… | |
… | |
2690 | if (bytes_after) |
2723 | if (bytes_after) |
2691 | { |
2724 | { |
2692 | // fetch and append remaining data |
2725 | // fetch and append remaining data |
2693 | XTextProperty ct2; |
2726 | XTextProperty ct2; |
2694 | |
2727 | |
2695 | if (XGetWindowProperty (display->display, win, prop, |
2728 | if (XGetWindowProperty (dpy, win, prop, |
2696 | ct.nitems / 4, (bytes_after + 3) / 4, |
2729 | ct.nitems / 4, (bytes_after + 3) / 4, |
2697 | delete_prop, AnyPropertyType, |
2730 | delete_prop, AnyPropertyType, |
2698 | &ct2.encoding, &ct2.format, |
2731 | &ct2.encoding, &ct2.format, |
2699 | &ct2.nitems, &bytes_after, |
2732 | &ct2.nitems, &bytes_after, |
2700 | &ct2.value) != Success) |
2733 | &ct2.value) != Success) |
… | |
… | |
2713 | |
2746 | |
2714 | if (ct.encoding == xa[XA_INCR]) |
2747 | if (ct.encoding == xa[XA_INCR]) |
2715 | { |
2748 | { |
2716 | // INCR selection, start handshake |
2749 | // INCR selection, start handshake |
2717 | if (!delete_prop) |
2750 | if (!delete_prop) |
2718 | XDeleteProperty (display->display, win, prop); |
2751 | XDeleteProperty (dpy, win, prop); |
2719 | |
2752 | |
2720 | selection_wait = Sel_incr; |
2753 | selection_wait = Sel_incr; |
2721 | incr_buf_fill = 0; |
2754 | incr_buf_fill = 0; |
2722 | incr_ev.start (NOW + 10); |
2755 | incr_ev.start (10); |
2723 | |
2756 | |
2724 | goto bailout; |
2757 | goto bailout; |
2725 | } |
2758 | } |
2726 | |
2759 | |
2727 | if (ct.nitems == 0) |
2760 | if (ct.nitems == 0) |
… | |
… | |
2736 | ct.nitems = incr_buf_fill; |
2769 | ct.nitems = incr_buf_fill; |
2737 | incr_buf = 0; |
2770 | incr_buf = 0; |
2738 | incr_buf_size = 0; |
2771 | incr_buf_size = 0; |
2739 | incr_ev.stop (); |
2772 | incr_ev.stop (); |
2740 | } |
2773 | } |
2741 | else |
2774 | else |
2742 | { |
2775 | { |
2743 | if (selection_wait == Sel_normal |
2776 | if (selection_wait == Sel_normal |
2744 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2777 | && (win != display->root || prop != XA_CUT_BUFFER0)) // avoid recursion |
2745 | { |
2778 | { |
2746 | /* |
2779 | /* |
… | |
… | |
2753 | goto bailout; |
2786 | goto bailout; |
2754 | } |
2787 | } |
2755 | } |
2788 | } |
2756 | else if (selection_wait == Sel_incr) |
2789 | else if (selection_wait == Sel_incr) |
2757 | { |
2790 | { |
2758 | incr_ev.start (NOW + 10); |
2791 | incr_ev.start (10); |
2759 | |
2792 | |
2760 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2793 | while (incr_buf_fill + ct.nitems > incr_buf_size) |
2761 | { |
2794 | { |
2762 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2795 | incr_buf_size = incr_buf_size ? incr_buf_size * 2 : 128*1024; |
2763 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
2796 | incr_buf = (char *)realloc (incr_buf, incr_buf_size); |
… | |
… | |
2770 | } |
2803 | } |
2771 | |
2804 | |
2772 | char **cl; |
2805 | char **cl; |
2773 | int cr; |
2806 | int cr; |
2774 | |
2807 | |
2775 | #if ENABLE_FRILLS |
2808 | #if !ENABLE_MINIMAL |
2776 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2809 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
2777 | // so recode it manually |
2810 | // so recode it manually |
2778 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2811 | if (ct.encoding == xa[XA_UTF8_STRING]) |
2779 | { |
2812 | { |
2780 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
2813 | wchar_t *w = rxvt_utf8towcs ((const char *)ct.value, ct.nitems); |
… | |
… | |
2784 | paste (s, strlen (s)); |
2817 | paste (s, strlen (s)); |
2785 | free (s); |
2818 | free (s); |
2786 | } |
2819 | } |
2787 | else |
2820 | else |
2788 | #endif |
2821 | #endif |
2789 | if (XmbTextPropertyToTextList (display->display, &ct, &cl, &cr) >= 0 |
2822 | if (XmbTextPropertyToTextList (dpy, &ct, &cl, &cr) >= 0 |
2790 | && cl) |
2823 | && cl) |
2791 | { |
2824 | { |
2792 | for (int i = 0; i < cr; i++) |
2825 | for (int i = 0; i < cr; i++) |
2793 | paste (cl[i], strlen (cl[i])); |
2826 | paste (cl[i], strlen (cl[i])); |
2794 | |
2827 | |
… | |
… | |
2803 | if (selection_wait == Sel_normal) |
2836 | if (selection_wait == Sel_normal) |
2804 | selection_wait = Sel_none; |
2837 | selection_wait = Sel_none; |
2805 | } |
2838 | } |
2806 | |
2839 | |
2807 | void |
2840 | void |
2808 | rxvt_term::incr_cb (time_watcher &w) NOTHROW |
2841 | rxvt_term::incr_cb (ev::timer &w, int revents) NOTHROW |
2809 | { |
2842 | { |
2810 | selection_wait = Sel_none; |
2843 | selection_wait = Sel_none; |
2811 | |
2844 | |
2812 | incr_buf_size = 0; |
2845 | incr_buf_size = 0; |
2813 | free (incr_buf); |
2846 | free (incr_buf); |
… | |
… | |
2824 | selection_paste (win, prop, true); |
2857 | selection_paste (win, prop, true); |
2825 | } |
2858 | } |
2826 | |
2859 | |
2827 | /* ------------------------------------------------------------------------- */ |
2860 | /* ------------------------------------------------------------------------- */ |
2828 | /* |
2861 | /* |
2829 | * Request the current selection: |
2862 | * Request the current selection: |
2830 | * Order: > internal selection if available |
2863 | * Order: > internal selection if available |
2831 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2864 | * > PRIMARY, SECONDARY, CLIPBOARD if ownership is claimed (+) |
2832 | * > CUT_BUFFER0 |
2865 | * > CUT_BUFFER0 |
2833 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2866 | * (+) if ownership is claimed but property is empty, rxvt_selection_paste () |
2834 | * will auto fallback to CUT_BUFFER0 |
2867 | * will auto fallback to CUT_BUFFER0 |
… | |
… | |
2836 | */ |
2869 | */ |
2837 | void |
2870 | void |
2838 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2871 | rxvt_term::selection_request (Time tm, int selnum) NOTHROW |
2839 | { |
2872 | { |
2840 | if (selection.text && selnum == Sel_Primary) |
2873 | if (selection.text && selnum == Sel_Primary) |
|
|
2874 | { |
2841 | { /* internal selection */ |
2875 | /* internal selection */ |
2842 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2876 | char *str = rxvt_wcstombs (selection.text, selection.len); |
2843 | paste (str, strlen (str)); |
2877 | paste (str, strlen (str)); |
2844 | free (str); |
2878 | free (str); |
2845 | return; |
2879 | return; |
2846 | } |
2880 | } |
… | |
… | |
2876 | else if (selnum == Sel_Secondary) |
2910 | else if (selnum == Sel_Secondary) |
2877 | sel = XA_SECONDARY; |
2911 | sel = XA_SECONDARY; |
2878 | else |
2912 | else |
2879 | sel = xa[XA_CLIPBOARD]; |
2913 | sel = xa[XA_CLIPBOARD]; |
2880 | |
2914 | |
2881 | if (XGetSelectionOwner (display->display, sel) != None) |
2915 | if (XGetSelectionOwner (dpy, sel) != None) |
2882 | { |
2916 | { |
2883 | XConvertSelection (display->display, sel, target, xa[XA_VT_SELECTION], |
2917 | XConvertSelection (dpy, sel, target, xa[XA_VT_SELECTION], |
2884 | vt, selection_request_time); |
2918 | vt, selection_request_time); |
2885 | return 1; |
2919 | return 1; |
2886 | } |
2920 | } |
2887 | |
2921 | |
2888 | return 0; |
2922 | return 0; |
… | |
… | |
2951 | |
2985 | |
2952 | int end_col; |
2986 | int end_col; |
2953 | |
2987 | |
2954 | for (; row <= selection.end.row; row++, col = 0) |
2988 | for (; row <= selection.end.row; row++, col = 0) |
2955 | { |
2989 | { |
2956 | #if ENABLE_FRILLS |
2990 | #if !ENABLE_MINIMAL |
2957 | if (selection.rect) |
2991 | if (selection.rect) |
2958 | { |
2992 | { |
2959 | col = selection.beg.col; |
2993 | col = selection.beg.col; |
2960 | end_col = ncol + 1; |
2994 | end_col = ncol + 1; |
2961 | } |
2995 | } |
… | |
… | |
2964 | end_col = ROW(row).l; |
2998 | end_col = ROW(row).l; |
2965 | |
2999 | |
2966 | col = max (col, 0); |
3000 | col = max (col, 0); |
2967 | |
3001 | |
2968 | if (row == selection.end.row |
3002 | if (row == selection.end.row |
2969 | #if ENABLE_FRILLS |
3003 | #if !ENABLE_MINIMAL |
2970 | || selection.rect |
3004 | || selection.rect |
2971 | #endif |
3005 | #endif |
2972 | ) |
3006 | ) |
2973 | min_it (end_col, selection.end.col); |
3007 | min_it (end_col, selection.end.col); |
2974 | |
3008 | |
… | |
… | |
2997 | #endif |
3031 | #endif |
2998 | else |
3032 | else |
2999 | new_selection_text[ofs++] = *t++; |
3033 | new_selection_text[ofs++] = *t++; |
3000 | } |
3034 | } |
3001 | |
3035 | |
3002 | #if ENABLE_FRILLS |
3036 | #if !ENABLE_MINIMAL |
3003 | if (selection.rect) |
3037 | if (selection.rect) |
3004 | { |
3038 | { |
3005 | while (ofs |
3039 | while (ofs |
3006 | && new_selection_text[ofs - 1] != C0_LF |
3040 | && new_selection_text[ofs - 1] != C0_LF |
3007 | && unicode::is_space (new_selection_text[ofs - 1])) |
3041 | && unicode::is_space (new_selection_text[ofs - 1])) |
… | |
… | |
3041 | bool |
3075 | bool |
3042 | rxvt_term::selection_grab (Time tm) NOTHROW |
3076 | rxvt_term::selection_grab (Time tm) NOTHROW |
3043 | { |
3077 | { |
3044 | selection_time = tm; |
3078 | selection_time = tm; |
3045 | |
3079 | |
3046 | XSetSelectionOwner (display->display, XA_PRIMARY, vt, tm); |
3080 | XSetSelectionOwner (dpy, XA_PRIMARY, vt, tm); |
3047 | if (XGetSelectionOwner (display->display, XA_PRIMARY) == vt) |
3081 | if (XGetSelectionOwner (dpy, XA_PRIMARY) == vt) |
3048 | { |
3082 | { |
3049 | display->set_selection_owner (this); |
3083 | display->set_selection_owner (this); |
3050 | return true; |
3084 | return true; |
3051 | } |
3085 | } |
3052 | else |
3086 | else |
… | |
… | |
3056 | } |
3090 | } |
3057 | |
3091 | |
3058 | #if 0 |
3092 | #if 0 |
3059 | XTextProperty ct; |
3093 | XTextProperty ct; |
3060 | |
3094 | |
3061 | if (XwcTextListToTextProperty (display->display, &selection.text, 1, XStringStyle, &ct) >= 0) |
3095 | if (XwcTextListToTextProperty (dpy, &selection.text, 1, XStringStyle, &ct) >= 0) |
3062 | { |
3096 | { |
3063 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3097 | set_string_property (XA_CUT_BUFFER0, ct.value, ct.nitems); |
3064 | XFree (ct.value); |
3098 | XFree (ct.value); |
3065 | } |
3099 | } |
3066 | #endif |
3100 | #endif |
… | |
… | |
3112 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3146 | selection.mark.col = clamp (selection.mark.col, 0, ncol - 1); |
3113 | |
3147 | |
3114 | while (selection.mark.col > 0 |
3148 | while (selection.mark.col > 0 |
3115 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3149 | && ROW(selection.mark.row).t[selection.mark.col] == NOCHAR) |
3116 | --selection.mark.col; |
3150 | --selection.mark.col; |
3117 | |
3151 | |
3118 | if (selection.op) |
3152 | if (selection.op) |
|
|
3153 | { |
3119 | { /* clear the old selection */ |
3154 | /* clear the old selection */ |
3120 | selection.beg.row = selection.end.row = selection.mark.row; |
3155 | selection.beg.row = selection.end.row = selection.mark.row; |
3121 | selection.beg.col = selection.end.col = selection.mark.col; |
3156 | selection.beg.col = selection.end.col = selection.mark.col; |
3122 | } |
3157 | } |
3123 | |
3158 | |
3124 | selection.op = SELECTION_INIT; |
3159 | selection.op = SELECTION_INIT; |
… | |
… | |
3313 | * a point/word/line which is either the start or end of the selection |
3348 | * a point/word/line which is either the start or end of the selection |
3314 | * and it was decided by whichever point/word/line was `fixed' at the |
3349 | * and it was decided by whichever point/word/line was `fixed' at the |
3315 | * time of the most recent button3 press |
3350 | * time of the most recent button3 press |
3316 | */ |
3351 | */ |
3317 | if (button3 && buttonpress) |
3352 | if (button3 && buttonpress) |
|
|
3353 | { |
3318 | { /* button3 press */ |
3354 | /* button3 press */ |
3319 | /* |
3355 | /* |
3320 | * first determine which edge of the selection we are closest to |
3356 | * first determine which edge of the selection we are closest to |
3321 | */ |
3357 | */ |
3322 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3358 | if (ROWCOL_IS_BEFORE (pos, selection.beg) |
3323 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
3359 | || (!ROWCOL_IS_AFTER (pos, selection.end) |
… | |
… | |
3341 | selection.mark.row = selection.beg.row; |
3377 | selection.mark.row = selection.beg.row; |
3342 | selection.mark.col = selection.beg.col; |
3378 | selection.mark.col = selection.beg.col; |
3343 | } |
3379 | } |
3344 | } |
3380 | } |
3345 | else |
3381 | else |
|
|
3382 | { |
3346 | { /* button1 drag or button3 drag */ |
3383 | /* button1 drag or button3 drag */ |
3347 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3384 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3348 | { |
3385 | { |
3349 | if (selection.mark.row == selection.end.row |
3386 | if (selection.mark.row == selection.end.row |
3350 | && selection.mark.col == selection.end.col |
3387 | && selection.mark.col == selection.end.col |
3351 | && clickchange |
3388 | && clickchange |
… | |
… | |
3368 | |
3405 | |
3369 | if (selection.clicks == 1) |
3406 | if (selection.clicks == 1) |
3370 | { |
3407 | { |
3371 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3408 | if (selection.beg.col > ROW(selection.beg.row).l //TODO//FIXME//LEN |
3372 | && !ROW(selection.beg.row).is_longer () |
3409 | && !ROW(selection.beg.row).is_longer () |
3373 | #if ENABLE_FRILLS |
3410 | #if !ENABLE_MINIMAL |
3374 | && !selection.rect |
3411 | && !selection.rect |
3375 | #endif |
3412 | #endif |
3376 | ) |
3413 | ) |
3377 | selection.beg.col = ncol; |
3414 | selection.beg.col = ncol; |
3378 | |
3415 | |
3379 | if ( |
3416 | if ( |
3380 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3417 | selection.end.col > ROW(selection.end.row).l //TODO//FIXME//LEN |
3381 | && !ROW(selection.end.row).is_longer () |
3418 | && !ROW(selection.end.row).is_longer () |
3382 | #if ENABLE_FRILLS |
3419 | #if !ENABLE_MINIMAL |
3383 | && !selection.rect |
3420 | && !selection.rect |
3384 | #endif |
3421 | #endif |
3385 | ) |
3422 | ) |
3386 | selection.end.col = ncol; |
3423 | selection.end.col = ncol; |
3387 | } |
3424 | } |
… | |
… | |
3394 | selection_delimit_word (DN, &selection.end, &selection.end); |
3431 | selection_delimit_word (DN, &selection.end, &selection.end); |
3395 | } |
3432 | } |
3396 | else if (selection.clicks == 3) |
3433 | else if (selection.clicks == 3) |
3397 | { |
3434 | { |
3398 | #if ENABLE_FRILLS |
3435 | #if ENABLE_FRILLS |
3399 | if (OPTION (Opt_tripleclickwords)) |
3436 | if (option (Opt_tripleclickwords)) |
3400 | { |
3437 | { |
3401 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3438 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
3402 | |
3439 | |
3403 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3440 | for (int end_row = selection.mark.row; end_row < nrow; end_row++) |
3404 | { |
3441 | { |
3405 | if (!ROW(end_row).is_longer ()) |
3442 | if (!ROW(end_row).is_longer ()) |
3406 | { |
3443 | { |
3407 | selection.end.row = end_row; |
3444 | selection.end.row = end_row; |
3408 | selection.end.col = ROW(end_row).l; |
3445 | selection.end.col = ROW(end_row).l; |
|
|
3446 | # if !ENABLE_MINIMAL |
3409 | selection_remove_trailing_spaces (); |
3447 | selection_remove_trailing_spaces (); |
|
|
3448 | # endif |
3410 | break; |
3449 | break; |
3411 | } |
3450 | } |
3412 | } |
3451 | } |
3413 | } |
3452 | } |
3414 | else |
3453 | else |
… | |
… | |
3430 | selection.end.row++; |
3469 | selection.end.row++; |
3431 | } |
3470 | } |
3432 | } |
3471 | } |
3433 | |
3472 | |
3434 | if (button3 && buttonpress) |
3473 | if (button3 && buttonpress) |
|
|
3474 | { |
3435 | { /* mark may need to be changed */ |
3475 | /* mark may need to be changed */ |
3436 | if (closeto == LEFT) |
3476 | if (closeto == LEFT) |
3437 | { |
3477 | { |
3438 | selection.mark.row = selection.end.row; |
3478 | selection.mark.row = selection.end.row; |
3439 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3479 | selection.mark.col = selection.end.col - (selection.clicks == 2); |
3440 | } |
3480 | } |
… | |
… | |
3443 | selection.mark.row = selection.beg.row; |
3483 | selection.mark.row = selection.beg.row; |
3444 | selection.mark.col = selection.beg.col; |
3484 | selection.mark.col = selection.beg.col; |
3445 | } |
3485 | } |
3446 | } |
3486 | } |
3447 | |
3487 | |
3448 | #if ENABLE_FRILLS |
3488 | #if !ENABLE_MINIMAL |
3449 | if (selection.rect && selection.beg.col > selection.end.col) |
3489 | if (selection.rect && selection.beg.col > selection.end.col) |
3450 | ::swap (selection.beg.col, selection.end.col); |
3490 | ::swap (selection.beg.col, selection.end.col); |
3451 | #endif |
3491 | #endif |
3452 | } |
3492 | } |
3453 | |
3493 | |
3454 | #if ENABLE_FRILLS |
3494 | #if !ENABLE_MINIMAL |
3455 | void |
3495 | void |
3456 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3496 | rxvt_term::selection_remove_trailing_spaces () NOTHROW |
3457 | { |
3497 | { |
3458 | int32_t end_col, end_row; |
3498 | int32_t end_col, end_row; |
3459 | text_t *stp; |
3499 | text_t *stp; |
… | |
… | |
3514 | */ |
3554 | */ |
3515 | void |
3555 | void |
3516 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3556 | rxvt_term::selection_send (const XSelectionRequestEvent &rq) NOTHROW |
3517 | { |
3557 | { |
3518 | XSelectionEvent ev; |
3558 | XSelectionEvent ev; |
3519 | dDisp; |
|
|
3520 | |
3559 | |
3521 | ev.type = SelectionNotify; |
3560 | ev.type = SelectionNotify; |
3522 | ev.property = None; |
3561 | ev.property = None; |
3523 | ev.display = rq.display; |
3562 | ev.display = rq.display; |
3524 | ev.requestor = rq.requestor; |
3563 | ev.requestor = rq.requestor; |
… | |
… | |
3538 | *target++ = xa[XA_COMPOUND_TEXT]; |
3577 | *target++ = xa[XA_COMPOUND_TEXT]; |
3539 | #if X_HAVE_UTF8_STRING |
3578 | #if X_HAVE_UTF8_STRING |
3540 | *target++ = xa[XA_UTF8_STRING]; |
3579 | *target++ = xa[XA_UTF8_STRING]; |
3541 | #endif |
3580 | #endif |
3542 | |
3581 | |
3543 | XChangeProperty (disp, rq.requestor, rq.property, XA_ATOM, |
3582 | XChangeProperty (dpy, rq.requestor, rq.property, XA_ATOM, |
3544 | 32, PropModeReplace, |
3583 | 32, PropModeReplace, |
3545 | (unsigned char *)target_list, target - target_list); |
3584 | (unsigned char *)target_list, target - target_list); |
3546 | ev.property = rq.property; |
3585 | ev.property = rq.property; |
3547 | } |
3586 | } |
3548 | #if TODO // TODO |
3587 | #if TODO // TODO |
… | |
… | |
3551 | /* TODO: Handle MULTIPLE */ |
3590 | /* TODO: Handle MULTIPLE */ |
3552 | } |
3591 | } |
3553 | #endif |
3592 | #endif |
3554 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3593 | else if (rq.target == xa[XA_TIMESTAMP] && selection.text) |
3555 | { |
3594 | { |
3556 | XChangeProperty (disp, rq.requestor, rq.property, rq.target, |
3595 | XChangeProperty (dpy, rq.requestor, rq.property, rq.target, |
3557 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3596 | 32, PropModeReplace, (unsigned char *)&selection_time, 1); |
3558 | ev.property = rq.property; |
3597 | ev.property = rq.property; |
3559 | } |
3598 | } |
3560 | else if (rq.target == XA_STRING |
3599 | else if (rq.target == XA_STRING |
3561 | || rq.target == xa[XA_TEXT] |
3600 | || rq.target == xa[XA_TEXT] |
… | |
… | |
3585 | style = enc_string; |
3624 | style = enc_string; |
3586 | else if (target == xa[XA_TEXT]) |
3625 | else if (target == xa[XA_TEXT]) |
3587 | style = enc_text; |
3626 | style = enc_text; |
3588 | else if (target == xa[XA_COMPOUND_TEXT]) |
3627 | else if (target == xa[XA_COMPOUND_TEXT]) |
3589 | style = enc_compound_text; |
3628 | style = enc_compound_text; |
3590 | #if ENABLE_FRILLS |
3629 | #if !ENABLE_MINIMAL |
3591 | else if (target == xa[XA_UTF8_STRING]) |
3630 | else if (target == xa[XA_UTF8_STRING]) |
3592 | style = enc_utf8; |
3631 | style = enc_utf8; |
3593 | #endif |
3632 | #endif |
3594 | else |
3633 | else |
3595 | { |
3634 | { |
… | |
… | |
3606 | { |
3645 | { |
3607 | cl = L""; |
3646 | cl = L""; |
3608 | selectlen = 0; |
3647 | selectlen = 0; |
3609 | } |
3648 | } |
3610 | |
3649 | |
3611 | #if ENABLE_FRILLS |
3650 | #if !ENABLE_MINIMAL |
3612 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3651 | // xlib is horribly broken with respect to UTF8_STRING, and nobody cares to fix it |
3613 | // so recode it manually |
3652 | // so recode it manually |
3614 | if (style == enc_utf8) |
3653 | if (style == enc_utf8) |
3615 | { |
3654 | { |
3616 | freect = 1; |
3655 | freect = 1; |
… | |
… | |
3619 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3658 | ct.value = (unsigned char *)rxvt_wcstoutf8 (cl, selectlen); |
3620 | ct.nitems = strlen ((char *)ct.value); |
3659 | ct.nitems = strlen ((char *)ct.value); |
3621 | } |
3660 | } |
3622 | else |
3661 | else |
3623 | #endif |
3662 | #endif |
3624 | if (XwcTextListToTextProperty (disp, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3663 | if (XwcTextListToTextProperty (dpy, &cl, 1, (XICCEncodingStyle) style, &ct) >= 0) |
3625 | freect = 1; |
3664 | freect = 1; |
3626 | else |
3665 | else |
3627 | { |
3666 | { |
3628 | /* if we failed to convert then send it raw */ |
3667 | /* if we failed to convert then send it raw */ |
3629 | ct.value = (unsigned char *)cl; |
3668 | ct.value = (unsigned char *)cl; |
3630 | ct.nitems = selectlen; |
3669 | ct.nitems = selectlen; |
3631 | ct.encoding = target; |
3670 | ct.encoding = target; |
3632 | } |
3671 | } |
3633 | |
3672 | |
3634 | XChangeProperty (disp, rq.requestor, rq.property, |
3673 | XChangeProperty (dpy, rq.requestor, rq.property, |
3635 | ct.encoding, 8, PropModeReplace, |
3674 | ct.encoding, 8, PropModeReplace, |
3636 | ct.value, (int)ct.nitems); |
3675 | ct.value, (int)ct.nitems); |
3637 | ev.property = rq.property; |
3676 | ev.property = rq.property; |
3638 | |
3677 | |
3639 | if (freect) |
3678 | if (freect) |
3640 | XFree (ct.value); |
3679 | XFree (ct.value); |
3641 | } |
3680 | } |
3642 | |
3681 | |
3643 | XSendEvent (disp, rq.requestor, False, 0L, (XEvent *)&ev); |
3682 | XSendEvent (dpy, rq.requestor, False, 0L, (XEvent *)&ev); |
3644 | } |
|
|
3645 | |
|
|
3646 | /* ------------------------------------------------------------------------- * |
|
|
3647 | * MOUSE ROUTINES * |
|
|
3648 | * ------------------------------------------------------------------------- */ |
|
|
3649 | |
|
|
3650 | /* |
|
|
3651 | * return col/row values corresponding to x/y pixel values |
|
|
3652 | */ |
|
|
3653 | void |
|
|
3654 | rxvt_term::pixel_position (int *x, int *y) NOTHROW |
|
|
3655 | { |
|
|
3656 | *x = Pixel2Col (*x); |
|
|
3657 | /* max_it (*x, 0); min_it (*x, (int)ncol - 1); */ |
|
|
3658 | *y = Pixel2Row (*y); |
|
|
3659 | /* max_it (*y, 0); min_it (*y, (int)nrow - 1); */ |
|
|
3660 | } |
3683 | } |
3661 | |
3684 | |
3662 | /* ------------------------------------------------------------------------- */ |
3685 | /* ------------------------------------------------------------------------- */ |
3663 | #ifdef USE_XIM |
3686 | #ifdef USE_XIM |
3664 | void |
3687 | void |
3665 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3688 | rxvt_term::im_set_position (XPoint &pos) NOTHROW |
3666 | { |
3689 | { |
3667 | XWindowAttributes xwa; |
3690 | XWindowAttributes xwa; |
3668 | |
3691 | |
3669 | XGetWindowAttributes (display->display, vt, &xwa); |
3692 | XGetWindowAttributes (dpy, vt, &xwa); |
3670 | |
3693 | |
3671 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3694 | pos.x = xwa.x + Col2Pixel (screen.cur.col); |
3672 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3695 | pos.y = xwa.y + Height2Pixel (screen.cur.row) + fbase; |
3673 | } |
3696 | } |
3674 | #endif |
3697 | #endif |