… | |
… | |
83 | 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) |
84 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
84 | #define ROWCOL_IN_ROW_AT_OR_BEFORE(X, Y) \ |
85 | 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) |
86 | |
86 | |
87 | /* |
87 | /* |
88 | * CLEAR_ROWS : clear <num> rows starting from row <row> |
|
|
89 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
88 | * CLEAR_CHARS: clear <num> chars starting from pixel position <x,y> |
90 | * ERASE_ROWS : set <num> rows starting from row <row> to the foreground colour |
|
|
91 | */ |
89 | */ |
92 | #define CLEAR_ROWS(row, num) \ |
|
|
93 | if (mapped) \ |
|
|
94 | XClearArea (dpy, vt, 0, \ |
|
|
95 | Row2Pixel (row), (unsigned int)width, \ |
|
|
96 | (unsigned int)Height2Pixel (num), False) |
|
|
97 | |
|
|
98 | #define CLEAR_CHARS(x, y, num) \ |
90 | #define CLEAR_CHARS(x, y, num) \ |
99 | if (mapped) \ |
91 | if (mapped) \ |
100 | XClearArea (dpy, vt, x, y, \ |
92 | XClearArea (dpy, vt, x, y, \ |
101 | (unsigned int)Width2Pixel (num), \ |
93 | (unsigned int)Width2Pixel (num), \ |
102 | (unsigned int)Height2Pixel (1), False) |
94 | (unsigned int)Height2Pixel (1), False) |
103 | |
95 | |
104 | #define ERASE_ROWS(row, num) \ |
|
|
105 | XFillRectangle (dpy, vt, gc, \ |
|
|
106 | 0, Row2Pixel (row), \ |
|
|
107 | (unsigned int)width, \ |
|
|
108 | (unsigned int)Height2Pixel (num)) |
|
|
109 | |
|
|
110 | /* ------------------------------------------------------------------------- * |
96 | /* ------------------------------------------------------------------------- * |
111 | * SCREEN `COMMON' ROUTINES * |
97 | * SCREEN `COMMON' ROUTINES * |
112 | * ------------------------------------------------------------------------- */ |
98 | * ------------------------------------------------------------------------- */ |
113 | |
99 | |
114 | /* Fill part/all of a line with blanks. */ |
100 | /* Fill part/all of a line with blanks. */ |
… | |
… | |
146 | |
132 | |
147 | l.l = 0; |
133 | l.l = 0; |
148 | l.f = 0; |
134 | l.f = 0; |
149 | } |
135 | } |
150 | |
136 | |
|
|
137 | // nuke a single wide character at the given column |
|
|
138 | void |
|
|
139 | rxvt_term::scr_kill_char (line_t &l, int col) const NOTHROW |
|
|
140 | { |
|
|
141 | // find begin |
|
|
142 | while (col > 0 && l.t[col] == NOCHAR) |
|
|
143 | col--; |
|
|
144 | |
|
|
145 | rend_t rend = l.r[col] & ~RS_baseattrMask; |
|
|
146 | rend = SET_FONT (rend, FONTSET (rend)->find_font (' ')); |
|
|
147 | |
|
|
148 | // found start, nuke |
|
|
149 | do { |
|
|
150 | l.t[col] = ' '; |
|
|
151 | l.r[col] = rend; |
|
|
152 | col++; |
|
|
153 | } while (col < ncol && l.t[col] == NOCHAR); |
|
|
154 | } |
|
|
155 | |
151 | /* ------------------------------------------------------------------------- * |
156 | /* ------------------------------------------------------------------------- * |
152 | * SCREEN INITIALISATION * |
157 | * SCREEN INITIALISATION * |
153 | * ------------------------------------------------------------------------- */ |
158 | * ------------------------------------------------------------------------- */ |
154 | |
159 | |
155 | void |
160 | void |
156 | rxvt_term::scr_reset () |
161 | rxvt_term::scr_reset () |
157 | { |
162 | { |
158 | #if ENABLE_OVERLAY |
163 | scr_soft_reset (); |
159 | scr_overlay_off (); |
|
|
160 | #endif |
|
|
161 | |
|
|
162 | rvideo_mode = false; |
|
|
163 | view_start = 0; |
164 | view_start = 0; |
|
|
165 | |
164 | num_scr = 0; |
166 | num_scr = 0; |
165 | |
167 | |
166 | if (ncol == 0) |
168 | if (ncol == 0) |
167 | ncol = 80; |
169 | ncol = 80; |
168 | |
170 | |
169 | if (nrow == 0) |
171 | if (nrow == 0) |
170 | nrow = 24; |
172 | nrow = 24; |
171 | |
173 | |
172 | if (ncol == prev_ncol && nrow == prev_nrow) |
174 | if (ncol == prev_ncol && nrow == prev_nrow) |
173 | return; |
175 | return; |
174 | |
|
|
175 | if (current_screen != PRIMARY) |
|
|
176 | scr_swap_screen (); |
|
|
177 | |
176 | |
178 | // we need at least two lines for wrapping to work correctly |
177 | // we need at least two lines for wrapping to work correctly |
179 | while (nrow + saveLines < 2) |
178 | while (nrow + saveLines < 2) |
180 | { |
179 | { |
181 | //TODO//FIXME |
180 | //TODO//FIXME |
… | |
… | |
394 | delete old_ta; |
393 | delete old_ta; |
395 | delete old_ra; |
394 | delete old_ra; |
396 | |
395 | |
397 | clamp_it (screen.cur.row, 0, nrow - 1); |
396 | clamp_it (screen.cur.row, 0, nrow - 1); |
398 | clamp_it (screen.cur.col, 0, ncol - 1); |
397 | clamp_it (screen.cur.col, 0, ncol - 1); |
399 | |
|
|
400 | free (tabs); |
|
|
401 | } |
398 | } |
402 | |
399 | |
403 | CLEAR_ALL_SELECTION (); |
400 | CLEAR_ALL_SELECTION (); |
404 | |
401 | |
405 | prev_nrow = nrow; |
402 | prev_nrow = nrow; |
406 | prev_ncol = ncol; |
403 | prev_ncol = ncol; |
407 | |
|
|
408 | tabs = (char *)rxvt_malloc (ncol); |
|
|
409 | |
|
|
410 | for (int col = ncol; --col; ) |
|
|
411 | tabs [col] = col % TABSIZE == 0; |
|
|
412 | |
|
|
413 | if (current_screen != PRIMARY) |
|
|
414 | scr_swap_screen (); |
|
|
415 | |
404 | |
416 | tt_winch (); |
405 | tt_winch (); |
417 | |
406 | |
418 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
407 | HOOK_INVOKE ((this, HOOK_RESET, DT_END)); |
419 | } |
408 | } |
… | |
… | |
431 | delete ralloc; ralloc = 0; |
420 | delete ralloc; ralloc = 0; |
432 | |
421 | |
433 | free (row_buf); |
422 | free (row_buf); |
434 | free (swap_buf); |
423 | free (swap_buf); |
435 | free (drawn_buf); |
424 | free (drawn_buf); |
|
|
425 | row_buf = 0; // signal that we freed all the arrays above |
|
|
426 | |
436 | free (tabs); |
427 | free (tabs); |
437 | |
428 | tabs = 0; |
438 | row_buf = 0; // signal that we freed all the arrays |
|
|
439 | } |
429 | } |
440 | } |
430 | } |
441 | |
431 | |
442 | /* ------------------------------------------------------------------------- */ |
432 | /* ------------------------------------------------------------------------- */ |
443 | /* |
433 | /* |
444 | * Hard reset |
434 | * Hard/Soft reset |
445 | */ |
435 | */ |
446 | void |
436 | void |
447 | rxvt_term::scr_poweron () |
437 | rxvt_term::scr_poweron () |
448 | { |
438 | { |
449 | scr_release (); |
439 | scr_release (); |
450 | prev_nrow = prev_ncol = 0; |
440 | prev_nrow = prev_ncol = 0; |
451 | scr_reset (); |
441 | scr_reset (); |
452 | |
442 | |
453 | scr_clear (true); |
443 | scr_clear (true); |
454 | scr_refresh (); |
444 | scr_refresh (); |
|
|
445 | } |
|
|
446 | |
|
|
447 | void |
|
|
448 | rxvt_term::scr_soft_reset () |
|
|
449 | { |
|
|
450 | /* only affects modes, nothing drastic such as clearing the screen */ |
|
|
451 | #if ENABLE_OVERLAY |
|
|
452 | scr_overlay_off (); |
|
|
453 | #endif |
|
|
454 | |
|
|
455 | rvideo_mode = false; |
|
|
456 | |
|
|
457 | if (current_screen != PRIMARY) |
|
|
458 | scr_swap_screen (); |
|
|
459 | |
|
|
460 | free (tabs); |
|
|
461 | tabs = (char *)rxvt_malloc (ncol); |
|
|
462 | |
|
|
463 | for (int col = ncol; --col; ) |
|
|
464 | tabs [col] = col % TABSIZE == 0; |
|
|
465 | |
|
|
466 | scr_scroll_region (0, MAX_ROWS - 1); |
|
|
467 | scr_rendition (0, ~RS_None); |
|
|
468 | scr_insert_mode (0); |
455 | } |
469 | } |
456 | |
470 | |
457 | /* ------------------------------------------------------------------------- * |
471 | /* ------------------------------------------------------------------------- * |
458 | * PROCESS SCREEN COMMANDS * |
472 | * PROCESS SCREEN COMMANDS * |
459 | * ------------------------------------------------------------------------- */ |
473 | * ------------------------------------------------------------------------- */ |
… | |
… | |
785 | |
799 | |
786 | while (str < strend) |
800 | while (str < strend) |
787 | { |
801 | { |
788 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
802 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
789 | |
803 | |
790 | if (c < 0x20) |
804 | if (expect_false (c < 0x20)) |
791 | if (c == C0_LF) |
805 | if (c == C0_LF) |
792 | { |
806 | { |
793 | max_it (line->l, screen.cur.col); |
807 | max_it (line->l, screen.cur.col); |
794 | |
808 | |
795 | screen.flags &= ~Screen_WrapNext; |
809 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
814 | { |
828 | { |
815 | scr_tab (1, true); |
829 | scr_tab (1, true); |
816 | continue; |
830 | continue; |
817 | } |
831 | } |
818 | |
832 | |
|
|
833 | if (expect_false ( |
819 | if (checksel /* see if we're writing within selection */ |
834 | checksel /* see if we're writing within selection */ |
820 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
835 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
821 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
836 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
|
|
837 | )) |
822 | { |
838 | { |
823 | checksel = 0; |
839 | checksel = 0; |
824 | /* |
840 | /* |
825 | * If we wrote anywhere in the selected area, kill the selection |
841 | * If we wrote anywhere in the selected area, kill the selection |
826 | * XXX: should we kill the mark too? Possibly, but maybe that |
842 | * XXX: should we kill the mark too? Possibly, but maybe that |
827 | * should be a similar check. |
843 | * should be a similar check. |
828 | */ |
844 | */ |
829 | CLEAR_SELECTION (); |
845 | CLEAR_SELECTION (); |
830 | } |
846 | } |
831 | |
847 | |
832 | if (screen.flags & Screen_WrapNext) |
848 | if (expect_false (screen.flags & Screen_WrapNext)) |
833 | { |
849 | { |
834 | scr_do_wrap (); |
850 | scr_do_wrap (); |
835 | |
851 | |
836 | line->l = ncol; |
852 | line->l = ncol; |
837 | line->is_longer (1); |
853 | line->is_longer (1); |
… | |
… | |
839 | row = screen.cur.row; |
855 | row = screen.cur.row; |
840 | line = &ROW(row); /* _must_ refresh */ |
856 | line = &ROW(row); /* _must_ refresh */ |
841 | } |
857 | } |
842 | |
858 | |
843 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
859 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
844 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
860 | if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
845 | c = 0xfffd; |
861 | c = 0xfffd; |
846 | |
862 | |
847 | // rely on wcwidth to tell us the character width, do wcwidth before |
863 | // rely on wcwidth to tell us the character width, do wcwidth before |
848 | // further replacements, as wcwidth might return -1 for the line |
864 | // further replacements, as wcwidth might return -1 for the line |
849 | // drawing characters below as they might be invalid in the current |
865 | // drawing characters below as they might be invalid in the current |
850 | // locale. |
866 | // locale. |
851 | int width = WCWIDTH (c); |
867 | int width = WCWIDTH (c); |
852 | |
868 | |
853 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
869 | if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL |
854 | { |
870 | { |
855 | // vt100 special graphics and line drawing |
871 | // vt100 special graphics and line drawing |
856 | // 5f-7e standard vt100 |
872 | // 5f-7e standard vt100 |
857 | // 40-5e rxvt extension for extra curses acs chars |
873 | // 40-5e rxvt extension for extra curses acs chars |
858 | static uint16_t vt100_0[62] = { // 41 .. 7e |
874 | static uint16_t vt100_0[62] = { // 41 .. 7e |
… | |
… | |
871 | c = vt100_0[c - 0x41]; |
887 | c = vt100_0[c - 0x41]; |
872 | width = 1; // vt100 line drawing characters are always single-width |
888 | width = 1; // vt100 line drawing characters are always single-width |
873 | } |
889 | } |
874 | } |
890 | } |
875 | |
891 | |
876 | if (screen.flags & Screen_Insert) |
892 | if (expect_false (screen.flags & Screen_Insert)) |
877 | scr_insdel_chars (width, INSERT); |
893 | scr_insdel_chars (width, INSERT); |
878 | |
894 | |
879 | if (width != 0) |
895 | if (width != 0) |
880 | { |
896 | { |
881 | #if !UNICODE_3 |
897 | #if !UNICODE_3 |
… | |
… | |
887 | c = 0xfffd; |
903 | c = 0xfffd; |
888 | # endif |
904 | # endif |
889 | #endif |
905 | #endif |
890 | |
906 | |
891 | // nuke the character at this position, if required |
907 | // nuke the character at this position, if required |
|
|
908 | if (expect_false ( |
892 | if (line->t[screen.cur.col] == NOCHAR |
909 | line->t[screen.cur.col] == NOCHAR |
893 | || (screen.cur.col < ncol - 1 |
910 | || (screen.cur.col < ncol - 1 |
894 | && line->t[screen.cur.col + 1] == NOCHAR)) |
911 | && line->t[screen.cur.col + 1] == NOCHAR) |
|
|
912 | )) |
|
|
913 | scr_kill_char (*line, screen.cur.col); |
|
|
914 | |
|
|
915 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
|
|
916 | |
|
|
917 | // if the character doesn't fit into the remaining columns... |
|
|
918 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
895 | { |
919 | { |
896 | int col = screen.cur.col; |
920 | // ... artificially enlargen the previous one |
897 | |
|
|
898 | // find begin |
|
|
899 | while (col > 0 && line->t[col] == NOCHAR) |
|
|
900 | col--; |
|
|
901 | |
|
|
902 | rend_t rend = SET_FONT (line->r[col], FONTSET (line->r[col])->find_font (' ')); |
|
|
903 | |
|
|
904 | // found begin, nuke |
|
|
905 | do { |
|
|
906 | line->t[col] = ' '; |
|
|
907 | line->r[col] = rend; |
|
|
908 | col++; |
|
|
909 | } while (col < ncol && line->t[col] == NOCHAR); |
|
|
910 | } |
|
|
911 | |
|
|
912 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
|
|
913 | |
|
|
914 | // if the character doesn't fit into the remaining columns... |
|
|
915 | if (screen.cur.col > ncol - width && ncol >= width) |
|
|
916 | { |
|
|
917 | // ...output spaces |
|
|
918 | c = ' '; |
921 | c = NOCHAR; |
919 | // and try the same character next loop iteration |
922 | // and try the same character next loop iteration |
920 | --str; |
923 | --str; |
921 | } |
924 | } |
922 | |
925 | |
923 | line->touch (); |
926 | line->touch (); |
… | |
… | |
925 | do |
928 | do |
926 | { |
929 | { |
927 | line->t[screen.cur.col] = c; |
930 | line->t[screen.cur.col] = c; |
928 | line->r[screen.cur.col] = rend; |
931 | line->r[screen.cur.col] = rend; |
929 | |
932 | |
930 | if (screen.cur.col < ncol - 1) |
933 | if (expect_true (screen.cur.col < ncol - 1)) |
931 | screen.cur.col++; |
934 | screen.cur.col++; |
932 | else |
935 | else |
933 | { |
936 | { |
934 | line->l = ncol; |
937 | line->l = ncol; |
935 | if (screen.flags & Screen_Autowrap) |
938 | if (screen.flags & Screen_Autowrap) |
… | |
… | |
937 | break; |
940 | break; |
938 | } |
941 | } |
939 | |
942 | |
940 | c = NOCHAR; |
943 | c = NOCHAR; |
941 | } |
944 | } |
942 | while (--width > 0); |
945 | while (expect_false (--width > 0)); |
943 | |
946 | |
944 | // pad with spaces when overwriting wide character with smaller one |
947 | // pad with spaces when overwriting wide character with smaller one |
945 | if (!width) |
948 | if (expect_false (!width)) |
946 | { |
949 | { |
947 | line->touch (); |
950 | line->touch (); |
948 | |
951 | |
949 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
952 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
950 | { |
953 | { |
951 | line->t[c] = ' '; |
954 | line->t[c] = ' '; |
952 | line->r[c] = rend; |
955 | line->r[c] = rend; |
953 | } |
956 | } |
954 | } |
957 | } |
955 | } |
958 | } |
|
|
959 | #if ENABLE_COMBINING |
956 | else // width == 0 |
960 | else // width == 0 |
957 | { |
961 | { |
958 | #if ENABLE_COMBINING |
962 | 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 | { |
963 | { |
|
|
964 | // handle combining characters |
|
|
965 | // we just tag the accent on the previous on-screen character. |
|
|
966 | // this is arguably not correct, but also arguably not wrong. |
|
|
967 | // we don't handle double-width characters nicely yet. |
|
|
968 | line_t *linep; |
|
|
969 | text_t *tp; |
|
|
970 | rend_t *rp; |
|
|
971 | |
|
|
972 | if (screen.cur.col > 0) |
|
|
973 | { |
969 | linep = line; |
974 | linep = line; |
970 | tp = line->t + screen.cur.col - 1; |
975 | tp = line->t + screen.cur.col - 1; |
971 | rp = line->r + screen.cur.col - 1; |
976 | rp = line->r + screen.cur.col - 1; |
|
|
977 | } |
|
|
978 | else if (screen.cur.row > 0 |
|
|
979 | && ROW(screen.cur.row - 1).is_longer ()) |
|
|
980 | { |
|
|
981 | linep = &ROW(screen.cur.row - 1); |
|
|
982 | tp = line->t + ncol - 1; |
|
|
983 | rp = line->r + ncol - 1; |
|
|
984 | } |
|
|
985 | else |
|
|
986 | continue; |
|
|
987 | |
|
|
988 | linep->touch (); |
|
|
989 | |
|
|
990 | while (*tp == NOCHAR && tp > linep->t) |
|
|
991 | tp--, rp--; |
|
|
992 | |
|
|
993 | // first try to find a precomposed character |
|
|
994 | unicode_t n = rxvt_compose (*tp, c); |
|
|
995 | if (n == NOCHAR) |
|
|
996 | n = rxvt_composite.compose (*tp, c); |
|
|
997 | |
|
|
998 | *tp = n; |
|
|
999 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
972 | } |
1000 | } |
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 | } |
1001 | } |
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 |
1002 | #endif |
996 | } |
|
|
997 | } |
1003 | } |
998 | |
1004 | |
999 | max_it (line->l, screen.cur.col); |
1005 | max_it (line->l, screen.cur.col); |
1000 | |
1006 | |
1001 | #ifdef DEBUG_STRICT |
1007 | #ifdef DEBUG_STRICT |
… | |
… | |
1336 | if (row >= nrow) /* Out Of Bounds */ |
1342 | if (row >= nrow) /* Out Of Bounds */ |
1337 | return; |
1343 | return; |
1338 | |
1344 | |
1339 | min_it (num, nrow - row); |
1345 | min_it (num, nrow - row); |
1340 | |
1346 | |
|
|
1347 | /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ |
1341 | if (rstyle & (RS_RVid | RS_Uline)) |
1348 | if (rstyle & (RS_RVid | RS_Uline)) |
1342 | ren = (rend_t) ~RS_None; |
1349 | ren = (rend_t) ~RS_None; |
1343 | else if (GET_BASEBG (rstyle) == Color_bg) |
1350 | else if (GET_BASEBG (rstyle) == Color_bg) |
1344 | { |
1351 | { |
1345 | ren = DEFAULT_RSTYLE; |
1352 | ren = DEFAULT_RSTYLE; |
1346 | CLEAR_ROWS (row, num); |
1353 | |
|
|
1354 | if (mapped) |
|
|
1355 | XClearArea (dpy, vt, 0, |
|
|
1356 | Row2Pixel (row), (unsigned int)width, |
|
|
1357 | (unsigned int)Height2Pixel (num), False); |
1347 | } |
1358 | } |
1348 | else |
1359 | else |
1349 | { |
1360 | { |
1350 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1361 | ren = rstyle & (RS_fgMask | RS_bgMask); |
|
|
1362 | |
1351 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1363 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1352 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1364 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1353 | ERASE_ROWS (row, num); |
1365 | XFillRectangle (dpy, vt, gc, |
|
|
1366 | 0, Row2Pixel (row), |
|
|
1367 | (unsigned int)width, |
|
|
1368 | (unsigned int)Height2Pixel (num)); |
1354 | gcvalue.foreground = pix_colors[Color_fg]; |
1369 | gcvalue.foreground = pix_colors[Color_fg]; |
1355 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1370 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1356 | } |
1371 | } |
1357 | |
1372 | |
1358 | for (; num--; row++) |
1373 | for (; num--; row++) |
… | |
… | |
1440 | * Insert/Delete <count> characters from the current position |
1455 | * Insert/Delete <count> characters from the current position |
1441 | */ |
1456 | */ |
1442 | void |
1457 | void |
1443 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1458 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1444 | { |
1459 | { |
1445 | int col, row; |
|
|
1446 | rend_t tr; |
|
|
1447 | |
|
|
1448 | want_refresh = 1; |
1460 | want_refresh = 1; |
1449 | ZERO_SCROLLBACK (); |
1461 | ZERO_SCROLLBACK (); |
1450 | |
1462 | |
1451 | if (count <= 0) |
1463 | if (count <= 0) |
1452 | return; |
1464 | return; |
… | |
… | |
1454 | scr_do_wrap (); |
1466 | scr_do_wrap (); |
1455 | |
1467 | |
1456 | selection_check (1); |
1468 | selection_check (1); |
1457 | min_it (count, ncol - screen.cur.col); |
1469 | min_it (count, ncol - screen.cur.col); |
1458 | |
1470 | |
1459 | row = screen.cur.row; |
1471 | int row = screen.cur.row; |
1460 | |
1472 | |
1461 | line_t *line = &ROW(row); |
1473 | line_t *line = &ROW(row); |
1462 | |
1474 | |
1463 | line->touch (); |
1475 | line->touch (); |
1464 | line->is_longer (0); |
1476 | line->is_longer (0); |
1465 | |
1477 | |
|
|
1478 | // nuke wide spanning the start |
|
|
1479 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1480 | scr_kill_char (*line, screen.cur.col); |
|
|
1481 | |
1466 | switch (insdel) |
1482 | switch (insdel) |
1467 | { |
1483 | { |
1468 | case INSERT: |
1484 | case INSERT: |
1469 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1485 | line->l = min (line->l + count, ncol); |
|
|
1486 | |
|
|
1487 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1488 | scr_kill_char (*line, screen.cur.col); |
|
|
1489 | |
|
|
1490 | for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1470 | { |
1491 | { |
1471 | line->t[col] = line->t[col - count]; |
1492 | line->t[col] = line->t[col - count]; |
1472 | line->r[col] = line->r[col - count]; |
1493 | line->r[col] = line->r[col - count]; |
1473 | } |
1494 | } |
1474 | |
|
|
1475 | line->l = min (line->l + count, ncol); |
|
|
1476 | |
1495 | |
1477 | if (selection.op && current_screen == selection.screen |
1496 | if (selection.op && current_screen == selection.screen |
1478 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1497 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1479 | { |
1498 | { |
1480 | if (selection.end.row != screen.cur.row |
1499 | if (selection.end.row != screen.cur.row |
… | |
… | |
1495 | case ERASE: |
1514 | case ERASE: |
1496 | screen.cur.col += count; /* don't worry if > ncol */ |
1515 | screen.cur.col += count; /* don't worry if > ncol */ |
1497 | selection_check (1); |
1516 | selection_check (1); |
1498 | screen.cur.col -= count; |
1517 | screen.cur.col -= count; |
1499 | |
1518 | |
1500 | line->l = max (line->l - count, 0); |
1519 | // nuke wide char after the end |
|
|
1520 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1521 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1522 | |
1501 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1523 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1502 | break; |
1524 | break; |
1503 | |
1525 | |
1504 | case DELETE: |
1526 | case DELETE: |
1505 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1527 | line->l = max (line->l - count, 0); |
1506 | |
1528 | |
|
|
1529 | // nuke wide char spanning the end |
|
|
1530 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1531 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1532 | |
1507 | for (col = screen.cur.col; (col + count) < ncol; col++) |
1533 | for (int col = screen.cur.col; (col + count) < ncol; col++) |
1508 | { |
1534 | { |
1509 | line->t[col] = line->t[col + count]; |
1535 | line->t[col] = line->t[col + count]; |
1510 | line->r[col] = line->r[col + count]; |
1536 | line->r[col] = line->r[col + count]; |
1511 | } |
1537 | } |
1512 | |
1538 | |
1513 | line->l = max (line->l - count, 0); |
|
|
1514 | scr_blank_line (*line, ncol - count, count, tr); |
1539 | scr_blank_line (*line, ncol - count, count, |
|
|
1540 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
1515 | |
1541 | |
1516 | if (selection.op && current_screen == selection.screen |
1542 | if (selection.op && current_screen == selection.screen |
1517 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1543 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1518 | { |
1544 | { |
1519 | if (selection.end.row != screen.cur.row |
1545 | if (selection.end.row != screen.cur.row |
… | |
… | |
1897 | XMapWindow (dpy, parent[0]); |
1923 | XMapWindow (dpy, parent[0]); |
1898 | # endif |
1924 | # endif |
1899 | |
1925 | |
1900 | # if ENABLE_FRILLS |
1926 | # if ENABLE_FRILLS |
1901 | if (option (Opt_urgentOnBell)) |
1927 | if (option (Opt_urgentOnBell)) |
1902 | { |
1928 | set_urgency (1); |
1903 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1904 | { |
|
|
1905 | h->flags |= XUrgencyHint; |
|
|
1906 | XSetWMHints (dpy, parent[0], h); |
|
|
1907 | } |
|
|
1908 | } |
|
|
1909 | # endif |
1929 | # endif |
1910 | |
1930 | |
1911 | if (option (Opt_visualBell)) |
1931 | if (option (Opt_visualBell)) |
1912 | { |
1932 | { |
1913 | rvideo_bell = true; |
1933 | rvideo_bell = true; |
… | |
… | |
1926 | void |
1946 | void |
1927 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1947 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1928 | { |
1948 | { |
1929 | #ifdef PRINTPIPE |
1949 | #ifdef PRINTPIPE |
1930 | int nrows, row_start; |
1950 | int nrows, row_start; |
1931 | FILE *fd; |
1951 | FILE *fd = popen_printer (); |
1932 | |
1952 | |
1933 | if ((fd = popen_printer ()) == NULL) |
1953 | if (!fd) |
1934 | return; |
1954 | return; |
1935 | |
1955 | |
1936 | if (fullhist) |
1956 | if (fullhist) |
1937 | { |
1957 | { |
1938 | nrows = nrow - top_row; |
1958 | nrows = nrow - top_row; |
… | |
… | |
2208 | continue; |
2228 | continue; |
2209 | |
2229 | |
2210 | // redraw one or more characters |
2230 | // redraw one or more characters |
2211 | |
2231 | |
2212 | // seek to the beginning of wide characters |
2232 | // seek to the beginning of wide characters |
2213 | while (stp[col] == NOCHAR && col > 0) |
2233 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2214 | --col; |
2234 | --col; |
2215 | |
2235 | |
2216 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2236 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2217 | text_t *text = stp + col; |
2237 | text_t *text = stp + col; |
2218 | int count = 1; |
2238 | int count = 1; |
… | |
… | |
2255 | |
2275 | |
2256 | col--; /* went one too far. move back */ |
2276 | col--; /* went one too far. move back */ |
2257 | count -= i; /* dump any matching trailing chars */ |
2277 | count -= i; /* dump any matching trailing chars */ |
2258 | |
2278 | |
2259 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2279 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2260 | while (i && text[count] == NOCHAR) |
2280 | while (expect_false (i && text[count] == NOCHAR)) |
2261 | count++, i--; |
2281 | count++, i--; |
2262 | |
2282 | |
2263 | /* |
2283 | /* |
2264 | * Determine the attributes for the string |
2284 | * Determine the attributes for the string |
2265 | */ |
2285 | */ |
2266 | int fore = fgcolor_of (rend); // desired foreground |
2286 | int fore = fgcolor_of (rend); // desired foreground |
2267 | int back = bgcolor_of (rend); // desired background |
2287 | int back = bgcolor_of (rend); // desired background |
2268 | |
2288 | |
2269 | // only do special processing if any attributes are set, which is unlikely |
2289 | // only do special processing if any attributes are set, which is unlikely |
2270 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2290 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2271 | { |
2291 | { |
2272 | bool invert = rend & RS_RVid; |
2292 | bool invert = rend & RS_RVid; |
2273 | |
2293 | |
2274 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2294 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2275 | if (rend & RS_Bold && fore == Color_fg) |
2295 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2358 | /* |
2378 | /* |
2359 | * Actually do the drawing of the string here |
2379 | * Actually do the drawing of the string here |
2360 | */ |
2380 | */ |
2361 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2381 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2362 | |
2382 | |
2363 | if (have_bg && back == Color_bg) |
2383 | if (expect_true (have_bg && back == Color_bg)) |
2364 | { |
2384 | { |
2365 | // this is very ugly, maybe push it into ->draw? |
2385 | // this is very ugly, maybe push it into ->draw? |
2366 | |
2386 | |
2367 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2387 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2368 | if (text[i] != ' ') |
2388 | if (text[i] != ' ') |
… | |
… | |
2375 | did_clear: ; |
2395 | did_clear: ; |
2376 | } |
2396 | } |
2377 | else |
2397 | else |
2378 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2398 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2379 | |
2399 | |
2380 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2400 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2381 | { |
2401 | { |
2382 | #if ENABLE_FRILLS |
2402 | #if ENABLE_FRILLS |
2383 | if (ISSET_PIXCOLOR (Color_underline)) |
2403 | if (ISSET_PIXCOLOR (Color_underline)) |
2384 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2404 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2385 | else |
2405 | else |