… | |
… | |
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. */ |
… | |
… | |
144 | { |
130 | { |
145 | scr_blank_line (l, 0, ncol, efs); |
131 | scr_blank_line (l, 0, ncol, efs); |
146 | |
132 | |
147 | l.l = 0; |
133 | l.l = 0; |
148 | l.f = 0; |
134 | l.f = 0; |
|
|
135 | } |
|
|
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); |
149 | } |
154 | } |
150 | |
155 | |
151 | /* ------------------------------------------------------------------------- * |
156 | /* ------------------------------------------------------------------------- * |
152 | * SCREEN INITIALISATION * |
157 | * SCREEN INITIALISATION * |
153 | * ------------------------------------------------------------------------- */ |
158 | * ------------------------------------------------------------------------- */ |
… | |
… | |
785 | |
790 | |
786 | while (str < strend) |
791 | while (str < strend) |
787 | { |
792 | { |
788 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
793 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
789 | |
794 | |
790 | if (c < 0x20) |
795 | if (expect_false (c < 0x20)) |
791 | if (c == C0_LF) |
796 | if (c == C0_LF) |
792 | { |
797 | { |
793 | max_it (line->l, screen.cur.col); |
798 | max_it (line->l, screen.cur.col); |
794 | |
799 | |
795 | screen.flags &= ~Screen_WrapNext; |
800 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
814 | { |
819 | { |
815 | scr_tab (1, true); |
820 | scr_tab (1, true); |
816 | continue; |
821 | continue; |
817 | } |
822 | } |
818 | |
823 | |
|
|
824 | if (expect_false ( |
819 | if (checksel /* see if we're writing within selection */ |
825 | checksel /* see if we're writing within selection */ |
820 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
826 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
821 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
827 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
|
|
828 | )) |
822 | { |
829 | { |
823 | checksel = 0; |
830 | checksel = 0; |
824 | /* |
831 | /* |
825 | * If we wrote anywhere in the selected area, kill the selection |
832 | * If we wrote anywhere in the selected area, kill the selection |
826 | * XXX: should we kill the mark too? Possibly, but maybe that |
833 | * XXX: should we kill the mark too? Possibly, but maybe that |
827 | * should be a similar check. |
834 | * should be a similar check. |
828 | */ |
835 | */ |
829 | CLEAR_SELECTION (); |
836 | CLEAR_SELECTION (); |
830 | } |
837 | } |
831 | |
838 | |
832 | if (screen.flags & Screen_WrapNext) |
839 | if (expect_false (screen.flags & Screen_WrapNext)) |
833 | { |
840 | { |
834 | scr_do_wrap (); |
841 | scr_do_wrap (); |
835 | |
842 | |
836 | line->l = ncol; |
843 | line->l = ncol; |
837 | line->is_longer (1); |
844 | line->is_longer (1); |
… | |
… | |
839 | row = screen.cur.row; |
846 | row = screen.cur.row; |
840 | line = &ROW(row); /* _must_ refresh */ |
847 | line = &ROW(row); /* _must_ refresh */ |
841 | } |
848 | } |
842 | |
849 | |
843 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
850 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
844 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
851 | if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
845 | c = 0xfffd; |
852 | c = 0xfffd; |
846 | |
853 | |
847 | // rely on wcwidth to tell us the character width, do wcwidth before |
854 | // rely on wcwidth to tell us the character width, do wcwidth before |
848 | // further replacements, as wcwidth might return -1 for the line |
855 | // further replacements, as wcwidth might return -1 for the line |
849 | // drawing characters below as they might be invalid in the current |
856 | // drawing characters below as they might be invalid in the current |
850 | // locale. |
857 | // locale. |
851 | int width = WCWIDTH (c); |
858 | int width = WCWIDTH (c); |
852 | |
859 | |
853 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
860 | if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL |
854 | { |
861 | { |
855 | // vt100 special graphics and line drawing |
862 | // vt100 special graphics and line drawing |
856 | // 5f-7e standard vt100 |
863 | // 5f-7e standard vt100 |
857 | // 40-5e rxvt extension for extra curses acs chars |
864 | // 40-5e rxvt extension for extra curses acs chars |
858 | static uint16_t vt100_0[62] = { // 41 .. 7e |
865 | static uint16_t vt100_0[62] = { // 41 .. 7e |
… | |
… | |
871 | c = vt100_0[c - 0x41]; |
878 | c = vt100_0[c - 0x41]; |
872 | width = 1; // vt100 line drawing characters are always single-width |
879 | width = 1; // vt100 line drawing characters are always single-width |
873 | } |
880 | } |
874 | } |
881 | } |
875 | |
882 | |
876 | if (screen.flags & Screen_Insert) |
883 | if (expect_false (screen.flags & Screen_Insert)) |
877 | scr_insdel_chars (width, INSERT); |
884 | scr_insdel_chars (width, INSERT); |
878 | |
885 | |
879 | if (width != 0) |
886 | if (width != 0) |
880 | { |
887 | { |
881 | #if !UNICODE_3 |
888 | #if !UNICODE_3 |
… | |
… | |
887 | c = 0xfffd; |
894 | c = 0xfffd; |
888 | # endif |
895 | # endif |
889 | #endif |
896 | #endif |
890 | |
897 | |
891 | // nuke the character at this position, if required |
898 | // nuke the character at this position, if required |
|
|
899 | if (expect_false ( |
892 | if (line->t[screen.cur.col] == NOCHAR |
900 | line->t[screen.cur.col] == NOCHAR |
893 | || (screen.cur.col < ncol - 1 |
901 | || (screen.cur.col < ncol - 1 |
894 | && line->t[screen.cur.col + 1] == NOCHAR)) |
902 | && line->t[screen.cur.col + 1] == NOCHAR) |
|
|
903 | )) |
|
|
904 | scr_kill_char (*line, screen.cur.col); |
|
|
905 | |
|
|
906 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
|
|
907 | |
|
|
908 | // if the character doesn't fit into the remaining columns... |
|
|
909 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
895 | { |
910 | { |
896 | int col = screen.cur.col; |
911 | // ... 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 = ' '; |
912 | c = NOCHAR; |
919 | // and try the same character next loop iteration |
913 | // and try the same character next loop iteration |
920 | --str; |
914 | --str; |
921 | } |
915 | } |
922 | |
916 | |
923 | line->touch (); |
917 | line->touch (); |
… | |
… | |
925 | do |
919 | do |
926 | { |
920 | { |
927 | line->t[screen.cur.col] = c; |
921 | line->t[screen.cur.col] = c; |
928 | line->r[screen.cur.col] = rend; |
922 | line->r[screen.cur.col] = rend; |
929 | |
923 | |
930 | if (screen.cur.col < ncol - 1) |
924 | if (expect_true (screen.cur.col < ncol - 1)) |
931 | screen.cur.col++; |
925 | screen.cur.col++; |
932 | else |
926 | else |
933 | { |
927 | { |
934 | line->l = ncol; |
928 | line->l = ncol; |
935 | if (screen.flags & Screen_Autowrap) |
929 | if (screen.flags & Screen_Autowrap) |
… | |
… | |
937 | break; |
931 | break; |
938 | } |
932 | } |
939 | |
933 | |
940 | c = NOCHAR; |
934 | c = NOCHAR; |
941 | } |
935 | } |
942 | while (--width > 0); |
936 | while (expect_false (--width > 0)); |
943 | |
937 | |
944 | // pad with spaces when overwriting wide character with smaller one |
938 | // pad with spaces when overwriting wide character with smaller one |
945 | if (!width) |
939 | if (expect_false (!width)) |
946 | { |
940 | { |
947 | line->touch (); |
941 | line->touch (); |
948 | |
942 | |
949 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
943 | for (int c = screen.cur.col; c < ncol && line->t[c] == NOCHAR; c++) |
950 | { |
944 | { |
951 | line->t[c] = ' '; |
945 | line->t[c] = ' '; |
952 | line->r[c] = rend; |
946 | line->r[c] = rend; |
953 | } |
947 | } |
954 | } |
948 | } |
955 | } |
949 | } |
|
|
950 | #if ENABLE_COMBINING |
956 | else // width == 0 |
951 | else // width == 0 |
957 | { |
952 | { |
958 | #if ENABLE_COMBINING |
953 | 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 | { |
954 | { |
|
|
955 | // handle combining characters |
|
|
956 | // we just tag the accent on the previous on-screen character. |
|
|
957 | // this is arguably not correct, but also arguably not wrong. |
|
|
958 | // we don't handle double-width characters nicely yet. |
|
|
959 | line_t *linep; |
|
|
960 | text_t *tp; |
|
|
961 | rend_t *rp; |
|
|
962 | |
|
|
963 | if (screen.cur.col > 0) |
|
|
964 | { |
969 | linep = line; |
965 | linep = line; |
970 | tp = line->t + screen.cur.col - 1; |
966 | tp = line->t + screen.cur.col - 1; |
971 | rp = line->r + screen.cur.col - 1; |
967 | rp = line->r + screen.cur.col - 1; |
|
|
968 | } |
|
|
969 | else if (screen.cur.row > 0 |
|
|
970 | && ROW(screen.cur.row - 1).is_longer ()) |
|
|
971 | { |
|
|
972 | linep = &ROW(screen.cur.row - 1); |
|
|
973 | tp = line->t + ncol - 1; |
|
|
974 | rp = line->r + ncol - 1; |
|
|
975 | } |
|
|
976 | else |
|
|
977 | continue; |
|
|
978 | |
|
|
979 | linep->touch (); |
|
|
980 | |
|
|
981 | while (*tp == NOCHAR && tp > linep->t) |
|
|
982 | tp--, rp--; |
|
|
983 | |
|
|
984 | // first try to find a precomposed character |
|
|
985 | unicode_t n = rxvt_compose (*tp, c); |
|
|
986 | if (n == NOCHAR) |
|
|
987 | n = rxvt_composite.compose (*tp, c); |
|
|
988 | |
|
|
989 | *tp = n; |
|
|
990 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
972 | } |
991 | } |
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 | } |
992 | } |
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 |
993 | #endif |
996 | } |
|
|
997 | } |
994 | } |
998 | |
995 | |
999 | max_it (line->l, screen.cur.col); |
996 | max_it (line->l, screen.cur.col); |
1000 | |
997 | |
1001 | #ifdef DEBUG_STRICT |
998 | #ifdef DEBUG_STRICT |
… | |
… | |
1225 | /* |
1222 | /* |
1226 | * Erase part or whole of a line |
1223 | * Erase part or whole of a line |
1227 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1224 | * XTERM_SEQ: Clear line to right: ESC [ 0 K |
1228 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1225 | * XTERM_SEQ: Clear line to left : ESC [ 1 K |
1229 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
1226 | * XTERM_SEQ: Clear whole line : ESC [ 2 K |
|
|
1227 | * extension: clear to right unless wrapped: ESC [ 3 K |
1230 | */ |
1228 | */ |
1231 | void |
1229 | void |
1232 | rxvt_term::scr_erase_line (int mode) NOTHROW |
1230 | rxvt_term::scr_erase_line (int mode) NOTHROW |
1233 | { |
1231 | { |
1234 | unsigned int col, num; |
1232 | unsigned int col, num; |
… | |
… | |
1243 | line.touch (); |
1241 | line.touch (); |
1244 | line.is_longer (0); |
1242 | line.is_longer (0); |
1245 | |
1243 | |
1246 | switch (mode) |
1244 | switch (mode) |
1247 | { |
1245 | { |
|
|
1246 | case 3: |
|
|
1247 | if (screen.flags & Screen_WrapNext) |
|
|
1248 | return; |
|
|
1249 | |
|
|
1250 | /* fall through */ |
|
|
1251 | |
1248 | case 0: /* erase to end of line */ |
1252 | case 0: /* erase to end of line */ |
1249 | col = screen.cur.col; |
1253 | col = screen.cur.col; |
1250 | num = ncol - col; |
1254 | num = ncol - col; |
1251 | min_it (line.l, col); |
1255 | min_it (line.l, col); |
|
|
1256 | |
1252 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1257 | if (ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur) |
1253 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1258 | || ROWCOL_IN_ROW_AT_OR_AFTER (selection.end, screen.cur)) |
1254 | CLEAR_SELECTION (); |
1259 | CLEAR_SELECTION (); |
1255 | break; |
1260 | break; |
|
|
1261 | |
1256 | case 1: /* erase to beginning of line */ |
1262 | case 1: /* erase to beginning of line */ |
1257 | col = 0; |
1263 | col = 0; |
1258 | num = screen.cur.col + 1; |
1264 | num = screen.cur.col + 1; |
|
|
1265 | |
1259 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1266 | if (ROWCOL_IN_ROW_AT_OR_BEFORE (selection.beg, screen.cur) |
1260 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1267 | || ROWCOL_IN_ROW_AT_OR_BEFORE (selection.end, screen.cur)) |
1261 | CLEAR_SELECTION (); |
1268 | CLEAR_SELECTION (); |
1262 | break; |
1269 | break; |
|
|
1270 | |
1263 | case 2: /* erase whole line */ |
1271 | case 2: /* erase whole line */ |
1264 | col = 0; |
1272 | col = 0; |
1265 | num = ncol; |
1273 | num = ncol; |
1266 | line.l = 0; |
1274 | line.l = 0; |
1267 | if (selection.beg.row <= screen.cur.row |
1275 | if (selection.beg.row <= screen.cur.row |
… | |
… | |
1325 | if (row >= nrow) /* Out Of Bounds */ |
1333 | if (row >= nrow) /* Out Of Bounds */ |
1326 | return; |
1334 | return; |
1327 | |
1335 | |
1328 | min_it (num, nrow - row); |
1336 | min_it (num, nrow - row); |
1329 | |
1337 | |
|
|
1338 | /*TODO: the xlceararea/xfillrectangle below don't take scroll offste into account, ask mikachu for details */ |
1330 | if (rstyle & (RS_RVid | RS_Uline)) |
1339 | if (rstyle & (RS_RVid | RS_Uline)) |
1331 | ren = (rend_t) ~RS_None; |
1340 | ren = (rend_t) ~RS_None; |
1332 | else if (GET_BASEBG (rstyle) == Color_bg) |
1341 | else if (GET_BASEBG (rstyle) == Color_bg) |
1333 | { |
1342 | { |
1334 | ren = DEFAULT_RSTYLE; |
1343 | ren = DEFAULT_RSTYLE; |
1335 | CLEAR_ROWS (row, num); |
1344 | |
|
|
1345 | if (mapped) |
|
|
1346 | XClearArea (dpy, vt, 0, |
|
|
1347 | Row2Pixel (row), (unsigned int)width, |
|
|
1348 | (unsigned int)Height2Pixel (num), False); |
1336 | } |
1349 | } |
1337 | else |
1350 | else |
1338 | { |
1351 | { |
1339 | ren = rstyle & (RS_fgMask | RS_bgMask); |
1352 | ren = rstyle & (RS_fgMask | RS_bgMask); |
|
|
1353 | |
1340 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1354 | gcvalue.foreground = pix_colors[bgcolor_of (rstyle)]; |
1341 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1355 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1342 | ERASE_ROWS (row, num); |
1356 | XFillRectangle (dpy, vt, gc, |
|
|
1357 | 0, Row2Pixel (row), |
|
|
1358 | (unsigned int)width, |
|
|
1359 | (unsigned int)Height2Pixel (num)); |
1343 | gcvalue.foreground = pix_colors[Color_fg]; |
1360 | gcvalue.foreground = pix_colors[Color_fg]; |
1344 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1361 | XChangeGC (dpy, gc, GCForeground, &gcvalue); |
1345 | } |
1362 | } |
1346 | |
1363 | |
1347 | for (; num--; row++) |
1364 | for (; num--; row++) |
… | |
… | |
1429 | * Insert/Delete <count> characters from the current position |
1446 | * Insert/Delete <count> characters from the current position |
1430 | */ |
1447 | */ |
1431 | void |
1448 | void |
1432 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1449 | rxvt_term::scr_insdel_chars (int count, int insdel) NOTHROW |
1433 | { |
1450 | { |
1434 | int col, row; |
|
|
1435 | rend_t tr; |
|
|
1436 | |
|
|
1437 | want_refresh = 1; |
1451 | want_refresh = 1; |
1438 | ZERO_SCROLLBACK (); |
1452 | ZERO_SCROLLBACK (); |
1439 | |
1453 | |
1440 | if (count <= 0) |
1454 | if (count <= 0) |
1441 | return; |
1455 | return; |
… | |
… | |
1443 | scr_do_wrap (); |
1457 | scr_do_wrap (); |
1444 | |
1458 | |
1445 | selection_check (1); |
1459 | selection_check (1); |
1446 | min_it (count, ncol - screen.cur.col); |
1460 | min_it (count, ncol - screen.cur.col); |
1447 | |
1461 | |
1448 | row = screen.cur.row; |
1462 | int row = screen.cur.row; |
1449 | |
1463 | |
1450 | line_t *line = &ROW(row); |
1464 | line_t *line = &ROW(row); |
1451 | |
1465 | |
1452 | line->touch (); |
1466 | line->touch (); |
1453 | line->is_longer (0); |
1467 | line->is_longer (0); |
1454 | |
1468 | |
|
|
1469 | // nuke wide spanning the start |
|
|
1470 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1471 | scr_kill_char (*line, screen.cur.col); |
|
|
1472 | |
1455 | switch (insdel) |
1473 | switch (insdel) |
1456 | { |
1474 | { |
1457 | case INSERT: |
1475 | case INSERT: |
1458 | for (col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1476 | line->l = min (line->l + count, ncol); |
|
|
1477 | |
|
|
1478 | if (line->t[screen.cur.col] == NOCHAR) |
|
|
1479 | scr_kill_char (*line, screen.cur.col); |
|
|
1480 | |
|
|
1481 | for (int col = ncol - 1; (col - count) >= screen.cur.col; col--) |
1459 | { |
1482 | { |
1460 | line->t[col] = line->t[col - count]; |
1483 | line->t[col] = line->t[col - count]; |
1461 | line->r[col] = line->r[col - count]; |
1484 | line->r[col] = line->r[col - count]; |
1462 | } |
1485 | } |
1463 | |
|
|
1464 | line->l = min (line->l + count, ncol); |
|
|
1465 | |
1486 | |
1466 | if (selection.op && current_screen == selection.screen |
1487 | if (selection.op && current_screen == selection.screen |
1467 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1488 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1468 | { |
1489 | { |
1469 | if (selection.end.row != screen.cur.row |
1490 | if (selection.end.row != screen.cur.row |
… | |
… | |
1484 | case ERASE: |
1505 | case ERASE: |
1485 | screen.cur.col += count; /* don't worry if > ncol */ |
1506 | screen.cur.col += count; /* don't worry if > ncol */ |
1486 | selection_check (1); |
1507 | selection_check (1); |
1487 | screen.cur.col -= count; |
1508 | screen.cur.col -= count; |
1488 | |
1509 | |
1489 | line->l = max (line->l - count, 0); |
1510 | // nuke wide char after the end |
|
|
1511 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1512 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1513 | |
1490 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1514 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1491 | break; |
1515 | break; |
1492 | |
1516 | |
1493 | case DELETE: |
1517 | case DELETE: |
1494 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1518 | line->l = max (line->l - count, 0); |
1495 | |
1519 | |
|
|
1520 | // nuke wide char spanning the end |
|
|
1521 | if (screen.cur.col + count < ncol && line->t[screen.cur.col + count] == NOCHAR) |
|
|
1522 | scr_kill_char (*line, screen.cur.col + count); |
|
|
1523 | |
1496 | for (col = screen.cur.col; (col + count) < ncol; col++) |
1524 | for (int col = screen.cur.col; (col + count) < ncol; col++) |
1497 | { |
1525 | { |
1498 | line->t[col] = line->t[col + count]; |
1526 | line->t[col] = line->t[col + count]; |
1499 | line->r[col] = line->r[col + count]; |
1527 | line->r[col] = line->r[col + count]; |
1500 | } |
1528 | } |
1501 | |
1529 | |
1502 | line->l = max (line->l - count, 0); |
|
|
1503 | scr_blank_line (*line, ncol - count, count, tr); |
1530 | scr_blank_line (*line, ncol - count, count, |
|
|
1531 | line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask)); |
1504 | |
1532 | |
1505 | if (selection.op && current_screen == selection.screen |
1533 | if (selection.op && current_screen == selection.screen |
1506 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1534 | && ROWCOL_IN_ROW_AT_OR_AFTER (selection.beg, screen.cur)) |
1507 | { |
1535 | { |
1508 | if (selection.end.row != screen.cur.row |
1536 | if (selection.end.row != screen.cur.row |
… | |
… | |
1886 | XMapWindow (dpy, parent[0]); |
1914 | XMapWindow (dpy, parent[0]); |
1887 | # endif |
1915 | # endif |
1888 | |
1916 | |
1889 | # if ENABLE_FRILLS |
1917 | # if ENABLE_FRILLS |
1890 | if (option (Opt_urgentOnBell)) |
1918 | if (option (Opt_urgentOnBell)) |
1891 | { |
1919 | set_urgency (1); |
1892 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1893 | { |
|
|
1894 | h->flags |= XUrgencyHint; |
|
|
1895 | XSetWMHints (dpy, parent[0], h); |
|
|
1896 | } |
|
|
1897 | } |
|
|
1898 | # endif |
1920 | # endif |
1899 | |
1921 | |
1900 | if (option (Opt_visualBell)) |
1922 | if (option (Opt_visualBell)) |
1901 | { |
1923 | { |
1902 | rvideo_bell = true; |
1924 | rvideo_bell = true; |
… | |
… | |
1915 | void |
1937 | void |
1916 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1938 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1917 | { |
1939 | { |
1918 | #ifdef PRINTPIPE |
1940 | #ifdef PRINTPIPE |
1919 | int nrows, row_start; |
1941 | int nrows, row_start; |
1920 | FILE *fd; |
1942 | FILE *fd = popen_printer (); |
1921 | |
1943 | |
1922 | if ((fd = popen_printer ()) == NULL) |
1944 | if (!fd) |
1923 | return; |
1945 | return; |
1924 | |
1946 | |
1925 | if (fullhist) |
1947 | if (fullhist) |
1926 | { |
1948 | { |
1927 | nrows = nrow - top_row; |
1949 | nrows = nrow - top_row; |
… | |
… | |
1992 | return; |
2014 | return; |
1993 | |
2015 | |
1994 | /* |
2016 | /* |
1995 | * A: set up vars |
2017 | * A: set up vars |
1996 | */ |
2018 | */ |
|
|
2019 | refresh_count = 0; |
|
|
2020 | |
1997 | have_bg = 0; |
2021 | have_bg = 0; |
1998 | refresh_count = 0; |
|
|
1999 | |
|
|
2000 | #ifdef HAVE_BG_PIXMAP |
2022 | #ifdef HAVE_BG_PIXMAP |
2001 | have_bg |= bgPixmap.pixmap != None; |
2023 | have_bg = bgPixmap.pixmap != None; |
2002 | #endif |
2024 | #endif |
2003 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2025 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2004 | |
2026 | |
2005 | /* |
2027 | /* |
2006 | * B: reverse any characters which are selected |
2028 | * B: reverse any characters which are selected |
… | |
… | |
2197 | continue; |
2219 | continue; |
2198 | |
2220 | |
2199 | // redraw one or more characters |
2221 | // redraw one or more characters |
2200 | |
2222 | |
2201 | // seek to the beginning of wide characters |
2223 | // seek to the beginning of wide characters |
2202 | while (stp[col] == NOCHAR && col > 0) |
2224 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2203 | --col; |
2225 | --col; |
2204 | |
2226 | |
2205 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2227 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2206 | text_t *text = stp + col; |
2228 | text_t *text = stp + col; |
2207 | int count = 1; |
2229 | int count = 1; |
… | |
… | |
2244 | |
2266 | |
2245 | col--; /* went one too far. move back */ |
2267 | col--; /* went one too far. move back */ |
2246 | count -= i; /* dump any matching trailing chars */ |
2268 | count -= i; /* dump any matching trailing chars */ |
2247 | |
2269 | |
2248 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2270 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2249 | while (i && text[count] == NOCHAR) |
2271 | while (expect_false (i && text[count] == NOCHAR)) |
2250 | count++, i--; |
2272 | count++, i--; |
2251 | |
2273 | |
2252 | /* |
2274 | /* |
2253 | * Determine the attributes for the string |
2275 | * Determine the attributes for the string |
2254 | */ |
2276 | */ |
2255 | int fore = fgcolor_of (rend); // desired foreground |
2277 | int fore = fgcolor_of (rend); // desired foreground |
2256 | int back = bgcolor_of (rend); // desired background |
2278 | int back = bgcolor_of (rend); // desired background |
2257 | |
2279 | |
2258 | // only do special processing if any attributes are set, which is unlikely |
2280 | // only do special processing if any attributes are set, which is unlikely |
2259 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2281 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2260 | { |
2282 | { |
2261 | bool invert = rend & RS_RVid; |
2283 | bool invert = rend & RS_RVid; |
2262 | |
2284 | |
2263 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2285 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2264 | if (rend & RS_Bold && fore == Color_fg) |
2286 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2347 | /* |
2369 | /* |
2348 | * Actually do the drawing of the string here |
2370 | * Actually do the drawing of the string here |
2349 | */ |
2371 | */ |
2350 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2372 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2351 | |
2373 | |
2352 | if (have_bg && back == Color_bg) |
2374 | if (expect_true (have_bg && back == Color_bg)) |
2353 | { |
2375 | { |
2354 | // this is very ugly, maybe push it into ->draw? |
2376 | // this is very ugly, maybe push it into ->draw? |
2355 | |
2377 | |
2356 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2378 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2357 | if (text[i] != ' ') |
2379 | if (text[i] != ' ') |
… | |
… | |
2364 | did_clear: ; |
2386 | did_clear: ; |
2365 | } |
2387 | } |
2366 | else |
2388 | else |
2367 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2389 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2368 | |
2390 | |
2369 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2391 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2370 | { |
2392 | { |
2371 | #if ENABLE_FRILLS |
2393 | #if ENABLE_FRILLS |
2372 | if (ISSET_PIXCOLOR (Color_underline)) |
2394 | if (ISSET_PIXCOLOR (Color_underline)) |
2373 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2395 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2374 | else |
2396 | else |
… | |
… | |
2474 | |
2496 | |
2475 | XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); |
2497 | XSetWindowBackground (dpy, parent[0], pix_colors[Color_border]); |
2476 | XClearWindow (dpy, parent[0]); |
2498 | XClearWindow (dpy, parent[0]); |
2477 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2499 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
2478 | |
2500 | |
2479 | # if HAVE_SCROLLBARS |
|
|
2480 | if (scrollBar.win) |
2501 | if (scrollBar.win) |
2481 | { |
2502 | { |
2482 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2503 | XSetWindowBackground (dpy, scrollBar.win, pix_colors[Color_border]); |
2483 | scrollBar.setIdle (); |
2504 | scrollBar.state = STATE_IDLE; |
2484 | scrollbar_show (0); |
2505 | scrollBar.show (0); |
2485 | } |
2506 | } |
|
|
2507 | |
2486 | # endif |
2508 | #endif |
2487 | |
2509 | |
|
|
2510 | /* bgPixmap.apply () does not do the following : */ |
2488 | scr_clear (); |
2511 | scr_clear (); |
2489 | scr_touch (true); |
2512 | scr_touch (true); |
2490 | want_refresh = 1; |
2513 | want_refresh = 1; |
2491 | |
|
|
2492 | #endif |
|
|
2493 | } |
2514 | } |
2494 | |
2515 | |
2495 | /* ------------------------------------------------------------------------- */ |
2516 | /* ------------------------------------------------------------------------- */ |
2496 | void |
2517 | void |
2497 | rxvt_term::scr_clear (bool really) NOTHROW |
2518 | rxvt_term::scr_clear (bool really) NOTHROW |
… | |
… | |
2586 | { |
2607 | { |
2587 | int row, wrote; |
2608 | int row, wrote; |
2588 | unsigned int width, towrite; |
2609 | unsigned int width, towrite; |
2589 | char r1[] = "\n"; |
2610 | char r1[] = "\n"; |
2590 | |
2611 | |
2591 | for (row = saveLines - nsaved; |
2612 | for (row = saveLines + top_row; |
2592 | row < saveLines + nrow - 1; row++) |
2613 | row < saveLines + nrow - 1; row++) |
2593 | { |
2614 | { |
2594 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2615 | width = row_buf[row].l >= 0 ? row_buf[row].l |
2595 | : ncol; |
2616 | : ncol; |
2596 | for (towrite = width; towrite; towrite -= wrote) |
2617 | for (towrite = width; towrite; towrite -= wrote) |