… | |
… | |
771 | |
771 | |
772 | while (str < strend) |
772 | while (str < strend) |
773 | { |
773 | { |
774 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
774 | c = (unicode_t)*str++; // convert to rxvt-unicodes representation |
775 | |
775 | |
776 | if (c < 0x20) |
776 | if (expect_false (c < 0x20)) |
777 | if (c == C0_LF) |
777 | if (c == C0_LF) |
778 | { |
778 | { |
779 | max_it (line->l, screen.cur.col); |
779 | max_it (line->l, screen.cur.col); |
780 | |
780 | |
781 | screen.flags &= ~Screen_WrapNext; |
781 | screen.flags &= ~Screen_WrapNext; |
… | |
… | |
800 | { |
800 | { |
801 | scr_tab (1, true); |
801 | scr_tab (1, true); |
802 | continue; |
802 | continue; |
803 | } |
803 | } |
804 | |
804 | |
|
|
805 | if (expect_false ( |
805 | if (checksel /* see if we're writing within selection */ |
806 | checksel /* see if we're writing within selection */ |
806 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
807 | && !ROWCOL_IS_BEFORE (screen.cur, selection.beg) |
807 | && ROWCOL_IS_BEFORE (screen.cur, selection.end)) |
808 | && ROWCOL_IS_BEFORE (screen.cur, selection.end) |
|
|
809 | )) |
808 | { |
810 | { |
809 | checksel = 0; |
811 | checksel = 0; |
810 | /* |
812 | /* |
811 | * If we wrote anywhere in the selected area, kill the selection |
813 | * If we wrote anywhere in the selected area, kill the selection |
812 | * XXX: should we kill the mark too? Possibly, but maybe that |
814 | * XXX: should we kill the mark too? Possibly, but maybe that |
813 | * should be a similar check. |
815 | * should be a similar check. |
814 | */ |
816 | */ |
815 | CLEAR_SELECTION (); |
817 | CLEAR_SELECTION (); |
816 | } |
818 | } |
817 | |
819 | |
818 | if (screen.flags & Screen_WrapNext) |
820 | if (expect_false (screen.flags & Screen_WrapNext)) |
819 | { |
821 | { |
820 | scr_do_wrap (); |
822 | scr_do_wrap (); |
821 | |
823 | |
822 | line->l = ncol; |
824 | line->l = ncol; |
823 | line->is_longer (1); |
825 | line->is_longer (1); |
… | |
… | |
825 | row = screen.cur.row; |
827 | row = screen.cur.row; |
826 | line = &ROW(row); /* _must_ refresh */ |
828 | line = &ROW(row); /* _must_ refresh */ |
827 | } |
829 | } |
828 | |
830 | |
829 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
831 | // some utf-8 decoders "decode" surrogate characters: let's fix this. |
830 | if (IN_RANGE_INC (c, 0xd800, 0xdfff)) |
832 | if (expect_false (IN_RANGE_INC (c, 0xd800, 0xdfff))) |
831 | c = 0xfffd; |
833 | c = 0xfffd; |
832 | |
834 | |
833 | // 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 |
834 | // further replacements, as wcwidth might return -1 for the line |
836 | // further replacements, as wcwidth might return -1 for the line |
835 | // drawing characters below as they might be invalid in the current |
837 | // drawing characters below as they might be invalid in the current |
836 | // locale. |
838 | // locale. |
837 | int width = WCWIDTH (c); |
839 | int width = WCWIDTH (c); |
838 | |
840 | |
839 | if (charsets [screen.charset] == '0') // DEC SPECIAL |
841 | if (expect_false (charsets [screen.charset] == '0')) // DEC SPECIAL |
840 | { |
842 | { |
841 | // vt100 special graphics and line drawing |
843 | // vt100 special graphics and line drawing |
842 | // 5f-7e standard vt100 |
844 | // 5f-7e standard vt100 |
843 | // 40-5e rxvt extension for extra curses acs chars |
845 | // 40-5e rxvt extension for extra curses acs chars |
844 | static uint16_t vt100_0[62] = { // 41 .. 7e |
846 | static uint16_t vt100_0[62] = { // 41 .. 7e |
… | |
… | |
857 | c = vt100_0[c - 0x41]; |
859 | c = vt100_0[c - 0x41]; |
858 | width = 1; // vt100 line drawing characters are always single-width |
860 | width = 1; // vt100 line drawing characters are always single-width |
859 | } |
861 | } |
860 | } |
862 | } |
861 | |
863 | |
862 | if (screen.flags & Screen_Insert) |
864 | if (expect_false (screen.flags & Screen_Insert)) |
863 | scr_insdel_chars (width, INSERT); |
865 | scr_insdel_chars (width, INSERT); |
864 | |
866 | |
865 | if (width != 0) |
867 | if (width != 0) |
866 | { |
868 | { |
867 | #if !UNICODE_3 |
869 | #if !UNICODE_3 |
… | |
… | |
873 | c = 0xfffd; |
875 | c = 0xfffd; |
874 | # endif |
876 | # endif |
875 | #endif |
877 | #endif |
876 | |
878 | |
877 | // nuke the character at this position, if required |
879 | // nuke the character at this position, if required |
|
|
880 | if (expect_false ( |
878 | if (line->t[screen.cur.col] == NOCHAR |
881 | line->t[screen.cur.col] == NOCHAR |
879 | || (screen.cur.col < ncol - 1 |
882 | || (screen.cur.col < ncol - 1 |
880 | && line->t[screen.cur.col + 1] == NOCHAR)) |
883 | && line->t[screen.cur.col + 1] == NOCHAR) |
|
|
884 | )) |
881 | { |
885 | { |
882 | int col = screen.cur.col; |
886 | int col = screen.cur.col; |
883 | |
887 | |
884 | // find begin |
888 | // find begin |
885 | while (col > 0 && line->t[col] == NOCHAR) |
889 | while (col > 0 && line->t[col] == NOCHAR) |
… | |
… | |
896 | } |
900 | } |
897 | |
901 | |
898 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
902 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
899 | |
903 | |
900 | // if the character doesn't fit into the remaining columns... |
904 | // if the character doesn't fit into the remaining columns... |
901 | if (screen.cur.col > ncol - width && ncol >= width) |
905 | if (expect_false (screen.cur.col > ncol - width && ncol >= width)) |
902 | { |
906 | { |
903 | // ...output spaces |
907 | // ...output spaces |
904 | c = ' '; |
908 | c = ' '; |
905 | // and try the same character next loop iteration |
909 | // and try the same character next loop iteration |
906 | --str; |
910 | --str; |
… | |
… | |
911 | do |
915 | do |
912 | { |
916 | { |
913 | line->t[screen.cur.col] = c; |
917 | line->t[screen.cur.col] = c; |
914 | line->r[screen.cur.col] = rend; |
918 | line->r[screen.cur.col] = rend; |
915 | |
919 | |
916 | if (screen.cur.col < ncol - 1) |
920 | if (expect_true (screen.cur.col < ncol - 1)) |
917 | screen.cur.col++; |
921 | screen.cur.col++; |
918 | else |
922 | else |
919 | { |
923 | { |
920 | line->l = ncol; |
924 | line->l = ncol; |
921 | if (screen.flags & Screen_Autowrap) |
925 | if (screen.flags & Screen_Autowrap) |
… | |
… | |
923 | break; |
927 | break; |
924 | } |
928 | } |
925 | |
929 | |
926 | c = NOCHAR; |
930 | c = NOCHAR; |
927 | } |
931 | } |
928 | while (--width > 0); |
932 | while (expect_false (--width > 0)); |
929 | |
933 | |
930 | // pad with spaces when overwriting wide character with smaller one |
934 | // pad with spaces when overwriting wide character with smaller one |
931 | if (!width) |
935 | if (expect_false (!width)) |
932 | { |
936 | { |
933 | line->touch (); |
937 | line->touch (); |
934 | |
938 | |
935 | 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++) |
936 | { |
940 | { |
937 | line->t[c] = ' '; |
941 | line->t[c] = ' '; |
938 | line->r[c] = rend; |
942 | line->r[c] = rend; |
939 | } |
943 | } |
940 | } |
944 | } |
941 | } |
945 | } |
|
|
946 | #if ENABLE_COMBINING |
942 | else // width == 0 |
947 | else // width == 0 |
943 | { |
948 | { |
944 | #if ENABLE_COMBINING |
949 | if (c != 0xfeff) // ignore BOM |
945 | // handle combining characters |
|
|
946 | // we just tag the accent on the previous on-screen character. |
|
|
947 | // this is arguably not correct, but also arguably not wrong. |
|
|
948 | // we don't handle double-width characters nicely yet. |
|
|
949 | line_t *linep; |
|
|
950 | text_t *tp; |
|
|
951 | rend_t *rp; |
|
|
952 | |
|
|
953 | if (screen.cur.col > 0) |
|
|
954 | { |
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 | { |
955 | linep = line; |
961 | linep = line; |
956 | tp = line->t + screen.cur.col - 1; |
962 | tp = line->t + screen.cur.col - 1; |
957 | 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)); |
958 | } |
987 | } |
959 | else if (screen.cur.row > 0 |
|
|
960 | && ROW(screen.cur.row - 1).is_longer ()) |
|
|
961 | { |
|
|
962 | linep = &ROW(screen.cur.row - 1); |
|
|
963 | tp = line->t + ncol - 1; |
|
|
964 | rp = line->r + ncol - 1; |
|
|
965 | } |
988 | } |
966 | else |
|
|
967 | continue; |
|
|
968 | |
|
|
969 | linep->touch (); |
|
|
970 | |
|
|
971 | while (*tp == NOCHAR && tp > linep->t) |
|
|
972 | tp--, rp--; |
|
|
973 | |
|
|
974 | // first try to find a precomposed character |
|
|
975 | unicode_t n = rxvt_compose (*tp, c); |
|
|
976 | if (n == NOCHAR) |
|
|
977 | n = rxvt_composite.compose (*tp, c); |
|
|
978 | |
|
|
979 | *tp = n; |
|
|
980 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
|
|
981 | #endif |
989 | #endif |
982 | } |
|
|
983 | } |
990 | } |
984 | |
991 | |
985 | max_it (line->l, screen.cur.col); |
992 | max_it (line->l, screen.cur.col); |
986 | |
993 | |
987 | #ifdef DEBUG_STRICT |
994 | #ifdef DEBUG_STRICT |
… | |
… | |
1490 | case ERASE: |
1497 | case ERASE: |
1491 | screen.cur.col += count; /* don't worry if > ncol */ |
1498 | screen.cur.col += count; /* don't worry if > ncol */ |
1492 | selection_check (1); |
1499 | selection_check (1); |
1493 | screen.cur.col -= count; |
1500 | screen.cur.col -= count; |
1494 | |
1501 | |
1495 | line->l = max (line->l - count, 0); |
|
|
1496 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1502 | scr_blank_line (*line, screen.cur.col, count, rstyle); |
1497 | break; |
1503 | break; |
1498 | |
1504 | |
1499 | case DELETE: |
1505 | case DELETE: |
1500 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1506 | tr = line->r[ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
… | |
… | |
1892 | XMapWindow (dpy, parent[0]); |
1898 | XMapWindow (dpy, parent[0]); |
1893 | # endif |
1899 | # endif |
1894 | |
1900 | |
1895 | # if ENABLE_FRILLS |
1901 | # if ENABLE_FRILLS |
1896 | if (option (Opt_urgentOnBell)) |
1902 | if (option (Opt_urgentOnBell)) |
1897 | { |
1903 | set_urgency (1); |
1898 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1899 | { |
|
|
1900 | h->flags |= XUrgencyHint; |
|
|
1901 | XSetWMHints (dpy, parent[0], h); |
|
|
1902 | } |
|
|
1903 | } |
|
|
1904 | # endif |
1904 | # endif |
1905 | |
1905 | |
1906 | if (option (Opt_visualBell)) |
1906 | if (option (Opt_visualBell)) |
1907 | { |
1907 | { |
1908 | rvideo_bell = true; |
1908 | rvideo_bell = true; |
… | |
… | |
1921 | void |
1921 | void |
1922 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1922 | rxvt_term::scr_printscreen (int fullhist) NOTHROW |
1923 | { |
1923 | { |
1924 | #ifdef PRINTPIPE |
1924 | #ifdef PRINTPIPE |
1925 | int nrows, row_start; |
1925 | int nrows, row_start; |
1926 | FILE *fd; |
1926 | FILE *fd = popen_printer (); |
1927 | |
1927 | |
1928 | if ((fd = popen_printer ()) == NULL) |
1928 | if (!fd) |
1929 | return; |
1929 | return; |
1930 | |
1930 | |
1931 | if (fullhist) |
1931 | if (fullhist) |
1932 | { |
1932 | { |
1933 | nrows = nrow - top_row; |
1933 | nrows = nrow - top_row; |
… | |
… | |
2203 | continue; |
2203 | continue; |
2204 | |
2204 | |
2205 | // redraw one or more characters |
2205 | // redraw one or more characters |
2206 | |
2206 | |
2207 | // seek to the beginning of wide characters |
2207 | // seek to the beginning of wide characters |
2208 | while (stp[col] == NOCHAR && col > 0) |
2208 | while (expect_false (stp[col] == NOCHAR && col > 0)) |
2209 | --col; |
2209 | --col; |
2210 | |
2210 | |
2211 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2211 | rend_t rend = srp[col]; /* screen rendition (target rendtion) */ |
2212 | text_t *text = stp + col; |
2212 | text_t *text = stp + col; |
2213 | int count = 1; |
2213 | int count = 1; |
… | |
… | |
2250 | |
2250 | |
2251 | col--; /* went one too far. move back */ |
2251 | col--; /* went one too far. move back */ |
2252 | count -= i; /* dump any matching trailing chars */ |
2252 | count -= i; /* dump any matching trailing chars */ |
2253 | |
2253 | |
2254 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2254 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2255 | while (i && text[count] == NOCHAR) |
2255 | while (expect_false (i && text[count] == NOCHAR)) |
2256 | count++, i--; |
2256 | count++, i--; |
2257 | |
2257 | |
2258 | /* |
2258 | /* |
2259 | * Determine the attributes for the string |
2259 | * Determine the attributes for the string |
2260 | */ |
2260 | */ |
2261 | int fore = fgcolor_of (rend); // desired foreground |
2261 | int fore = fgcolor_of (rend); // desired foreground |
2262 | int back = bgcolor_of (rend); // desired background |
2262 | int back = bgcolor_of (rend); // desired background |
2263 | |
2263 | |
2264 | // only do special processing if any attributes are set, which is unlikely |
2264 | // only do special processing if any attributes are set, which is unlikely |
2265 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful)) |
2265 | if (expect_false (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink | RS_Careful))) |
2266 | { |
2266 | { |
2267 | bool invert = rend & RS_RVid; |
2267 | bool invert = rend & RS_RVid; |
2268 | |
2268 | |
2269 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2269 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2270 | if (rend & RS_Bold && fore == Color_fg) |
2270 | if (rend & RS_Bold && fore == Color_fg) |
… | |
… | |
2353 | /* |
2353 | /* |
2354 | * Actually do the drawing of the string here |
2354 | * Actually do the drawing of the string here |
2355 | */ |
2355 | */ |
2356 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2356 | rxvt_font *font = (*fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2357 | |
2357 | |
2358 | if (have_bg && back == Color_bg) |
2358 | if (expect_true (have_bg && back == Color_bg)) |
2359 | { |
2359 | { |
2360 | // this is very ugly, maybe push it into ->draw? |
2360 | // this is very ugly, maybe push it into ->draw? |
2361 | |
2361 | |
2362 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2362 | for (i = 0; i < count; i++) /* don't draw empty strings */ |
2363 | if (text[i] != ' ') |
2363 | if (text[i] != ' ') |
… | |
… | |
2370 | did_clear: ; |
2370 | did_clear: ; |
2371 | } |
2371 | } |
2372 | else |
2372 | else |
2373 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2373 | font->draw (*drawable, xpixel, ypixel, text, count, fore, back); |
2374 | |
2374 | |
2375 | if (rend & RS_Uline && font->descent > 1 && fore != back) |
2375 | if (expect_false (rend & RS_Uline && font->descent > 1 && fore != back)) |
2376 | { |
2376 | { |
2377 | #if ENABLE_FRILLS |
2377 | #if ENABLE_FRILLS |
2378 | if (ISSET_PIXCOLOR (Color_underline)) |
2378 | if (ISSET_PIXCOLOR (Color_underline)) |
2379 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2379 | XSetForeground (dpy, gc, pix_colors[Color_underline]); |
2380 | else |
2380 | else |