… | |
… | |
23 | /* |
23 | /* |
24 | * This file handles _all_ screen updates and selections |
24 | * This file handles _all_ screen updates and selections |
25 | */ |
25 | */ |
26 | |
26 | |
27 | #include "../config.h" /* NECESSARY */ |
27 | #include "../config.h" /* NECESSARY */ |
28 | #define INTERN_SCREEN |
|
|
29 | #include "rxvt.h" /* NECESSARY */ |
28 | #include "rxvt.h" /* NECESSARY */ |
30 | |
29 | |
31 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
30 | #include <X11/Xmd.h> /* get the typedef for CARD32 */ |
32 | |
31 | |
33 | #include <inttypes.h> |
32 | #include <inttypes.h> |
… | |
… | |
112 | (unsigned int)Height2Pixel (num)) |
111 | (unsigned int)Height2Pixel (num)) |
113 | |
112 | |
114 | /* ------------------------------------------------------------------------- * |
113 | /* ------------------------------------------------------------------------- * |
115 | * SCREEN `COMMON' ROUTINES * |
114 | * SCREEN `COMMON' ROUTINES * |
116 | * ------------------------------------------------------------------------- */ |
115 | * ------------------------------------------------------------------------- */ |
|
|
116 | |
117 | /* Fill part/all of a line with blanks. */ |
117 | /* Fill part/all of a line with blanks. */ |
118 | void |
118 | void |
119 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
119 | rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) |
120 | { |
120 | { |
121 | efs &= ~RS_baseattrMask; |
121 | efs &= ~RS_baseattrMask; |
122 | efs = SET_FONT (efs, TermWin.ascii_map [' ' - 0x20]); |
122 | efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); |
123 | |
123 | |
124 | while (width--) |
124 | while (width--) |
125 | { |
125 | { |
126 | *et++ = ' '; |
126 | *et++ = ' '; |
127 | *er++ = efs; |
127 | *er++ = efs; |
… | |
… | |
417 | } |
417 | } |
418 | |
418 | |
419 | void |
419 | void |
420 | rxvt_term::scr_reset_realloc () |
420 | rxvt_term::scr_reset_realloc () |
421 | { |
421 | { |
422 | uint16_t total_rows, nrow; |
422 | unsigned int total_rows, nrow; |
423 | |
423 | |
424 | nrow = TermWin.nrow; |
424 | nrow = TermWin.nrow; |
425 | total_rows = nrow + TermWin.saveLines; |
425 | total_rows = nrow + TermWin.saveLines; |
426 | /* *INDENT-OFF* */ |
426 | /* *INDENT-OFF* */ |
427 | screen.text = (text_t **)rxvt_realloc (screen.text, total_rows * sizeof (text_t *)); |
427 | screen.text = (text_t **)rxvt_realloc (screen.text, total_rows * sizeof (text_t *)); |
… | |
… | |
444 | * Free everything. That way malloc debugging can find leakage. |
444 | * Free everything. That way malloc debugging can find leakage. |
445 | */ |
445 | */ |
446 | void |
446 | void |
447 | rxvt_term::scr_release () |
447 | rxvt_term::scr_release () |
448 | { |
448 | { |
449 | uint16_t total_rows; |
449 | unsigned int total_rows; |
450 | int i; |
450 | int i; |
451 | |
451 | |
452 | total_rows = TermWin.nrow + TermWin.saveLines; |
452 | total_rows = TermWin.nrow + TermWin.saveLines; |
453 | |
453 | |
454 | delete talloc; talloc = 0; |
454 | delete talloc; talloc = 0; |
… | |
… | |
511 | s = &screen; |
511 | s = &screen; |
512 | |
512 | |
513 | switch (mode) |
513 | switch (mode) |
514 | { |
514 | { |
515 | case SAVE: |
515 | case SAVE: |
516 | s->s_cur.row = s->cur.row; |
516 | s->s_cur.row = screen.cur.row; |
517 | s->s_cur.col = s->cur.col; |
517 | s->s_cur.col = screen.cur.col; |
518 | s->s_rstyle = rstyle; |
518 | s->s_rstyle = rstyle; |
519 | s->s_charset = s->charset; |
519 | s->s_charset = screen.charset; |
520 | s->s_charset_char = charsets[s->charset]; |
520 | s->s_charset_char = charsets[screen.charset]; |
521 | break; |
521 | break; |
522 | |
522 | |
523 | case RESTORE: |
523 | case RESTORE: |
524 | want_refresh = 1; |
524 | want_refresh = 1; |
525 | s->cur.row = s->s_cur.row; |
525 | screen.cur.row = s->s_cur.row; |
526 | s->cur.col = s->s_cur.col; |
526 | screen.cur.col = s->s_cur.col; |
527 | s->flags &= ~Screen_WrapNext; |
527 | screen.flags &= ~Screen_WrapNext; |
528 | rstyle = s->s_rstyle; |
528 | rstyle = s->s_rstyle; |
529 | s->charset = s->s_charset; |
529 | screen.charset = s->s_charset; |
530 | charsets[s->charset] = s->s_charset_char; |
530 | charsets[screen.charset] = s->s_charset_char; |
531 | set_font_style (); |
531 | set_font_style (); |
532 | break; |
532 | break; |
533 | } |
533 | } |
534 | |
534 | |
535 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
535 | /* boundary check in case screen size changed between SAVE and RESTORE */ |
… | |
… | |
625 | * Change the colour for following text |
625 | * Change the colour for following text |
626 | */ |
626 | */ |
627 | void |
627 | void |
628 | rxvt_term::scr_color (unsigned int color, int fgbg) |
628 | rxvt_term::scr_color (unsigned int color, int fgbg) |
629 | { |
629 | { |
630 | color &= RS_fgMask; |
630 | if (color > maxTermCOLOR) |
|
|
631 | color = fgbg; |
|
|
632 | |
631 | if (fgbg == Color_fg) |
633 | if (fgbg == Color_fg) |
632 | rstyle = SET_FGCOLOR (rstyle, color); |
634 | rstyle = SET_FGCOLOR (rstyle, color); |
633 | else |
635 | else |
634 | rstyle = SET_BGCOLOR (rstyle, color); |
636 | rstyle = SET_BGCOLOR (rstyle, color); |
635 | } |
637 | } |
… | |
… | |
673 | nscrolled = (long)TermWin.nscrolled + (long)count; |
675 | nscrolled = (long)TermWin.nscrolled + (long)count; |
674 | |
676 | |
675 | if (nscrolled > (long)TermWin.saveLines) |
677 | if (nscrolled > (long)TermWin.saveLines) |
676 | TermWin.nscrolled = TermWin.saveLines; |
678 | TermWin.nscrolled = TermWin.saveLines; |
677 | else |
679 | else |
678 | TermWin.nscrolled = (uint16_t)nscrolled; |
680 | TermWin.nscrolled = (unsigned int)nscrolled; |
679 | |
681 | |
680 | if ((options & Opt_scrollWithBuffer) |
682 | if ((options & Opt_scrollWithBuffer) |
681 | && TermWin.view_start != 0 |
683 | && TermWin.view_start != 0 |
682 | && TermWin.view_start != TermWin.saveLines) |
684 | && TermWin.view_start != TermWin.saveLines) |
683 | scr_page (UP, count); |
685 | scr_page (UP, count); |
… | |
… | |
826 | |
828 | |
827 | if (c < 0x20) |
829 | if (c < 0x20) |
828 | switch (c) |
830 | switch (c) |
829 | { |
831 | { |
830 | case C0_HT: |
832 | case C0_HT: |
831 | scr_tab (1); |
833 | scr_tab (1, true); |
832 | continue; |
834 | continue; |
833 | |
835 | |
834 | case C0_LF: |
836 | case C0_LF: |
835 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
837 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
836 | MAX_IT (screen.tlen[row], screen.cur.col); |
838 | MAX_IT (screen.tlen[row], screen.cur.col); |
… | |
… | |
887 | int width = c < 0x100 ? 1 : wcwidth (c); |
889 | int width = c < 0x100 ? 1 : wcwidth (c); |
888 | |
890 | |
889 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
891 | if (charsets[screen.charset] == '0') // DEC SPECIAL |
890 | { |
892 | { |
891 | // vt100 special graphics and line drawing |
893 | // vt100 special graphics and line drawing |
|
|
894 | // 5f-7e standard vt100 |
|
|
895 | // 40-5e rxvt extension for extra curses acs chars |
892 | static uint16_t vt100_0[32] = { // 5f .. 7e |
896 | static uint16_t vt100_0[63] = { // 5f .. 7e |
|
|
897 | 0x0000, 0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603, // 40-47 hi mr. snowman! |
|
|
898 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 48-4f |
|
|
899 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50-57 |
|
|
900 | 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, // 58-5f |
893 | 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
901 | 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, // 60-67 |
894 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
902 | 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, // 68-6f |
895 | 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, |
903 | 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, // 70-77 |
896 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, |
904 | 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, // 78-7e |
897 | }; |
905 | }; |
898 | |
906 | |
899 | if (c >= 0x5f && c <= 0x7e) |
907 | if (c >= 0x40 && c <= 0x7e && vt100_0[c - 0x40]) |
900 | { |
908 | { |
901 | c = vt100_0[c - 0x5f]; |
909 | c = vt100_0[c - 0x40]; |
902 | width = 1; |
910 | width = 1; |
903 | } |
911 | } |
904 | } |
912 | } |
905 | |
913 | |
906 | if (width != 0) |
914 | if (width != 0) |
907 | { |
915 | { |
|
|
916 | // some utf-8 decoders decode surrogate characters. |
|
|
917 | if (0xd800 <= c && c <= 0xdfff) |
|
|
918 | c = 0xfffd; |
|
|
919 | |
908 | #if !UNICODE_3 |
920 | #if !UNICODE_3 |
909 | // trim characters we can't store directly :( |
921 | // trim characters we can't store directly :( |
910 | if (c >= 0x10000) |
922 | if (c >= 0x10000) |
911 | # if ENABLE_COMBINING |
923 | # if ENABLE_COMBINING |
912 | c = rxvt_composite.compose (c); // map to lower 16 bits |
924 | c = rxvt_composite.compose (c); // map to lower 16 bits |
913 | # else |
925 | # else |
914 | c = 0xfffd; |
926 | c = 0xfffd; |
915 | # endif |
927 | # endif |
916 | #endif |
928 | #endif |
917 | bool bold = (options & Opt_realBold) && ((rstyle & RS_Bold) != 0); |
929 | |
918 | rend_t rend = SET_FONT (rstyle, |
930 | // nuke the character at this position, if required |
919 | c > 0x7f || bold || c < 0x20 |
931 | if (stp[screen.cur.col] == NOCHAR |
920 | ? TermWin.fontset->find_font (c, bold) |
932 | || (screen.cur.col < TermWin.ncol - 1 |
921 | : TermWin.ascii_map [c - 0x20]); |
933 | && stp[screen.cur.col + 1] == NOCHAR)) |
|
|
934 | { |
|
|
935 | int col = screen.cur.col; |
|
|
936 | |
|
|
937 | // find begin |
|
|
938 | while (col > 0 && stp[col] == NOCHAR) |
|
|
939 | col--; |
|
|
940 | |
|
|
941 | rend_t rend = SET_FONT (srp[col], FONTSET (srp[col])->find_font (' ')); |
|
|
942 | |
|
|
943 | // found begin, nuke |
|
|
944 | do { |
|
|
945 | stp[col] = ' '; |
|
|
946 | srp[col] = rend; |
|
|
947 | col++; |
|
|
948 | } while (col < TermWin.ncol && stp[col] == NOCHAR); |
|
|
949 | } |
|
|
950 | |
|
|
951 | rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); |
922 | |
952 | |
923 | do |
953 | do |
924 | { |
954 | { |
925 | stp[screen.cur.col] = c; |
955 | stp[screen.cur.col] = c; |
926 | srp[screen.cur.col] = rend; |
956 | srp[screen.cur.col] = rend; |
… | |
… | |
971 | else |
1001 | else |
972 | continue; |
1002 | continue; |
973 | |
1003 | |
974 | // handle double-width-chars by making them look extremely ugly |
1004 | // handle double-width-chars by making them look extremely ugly |
975 | if (*tp == NOCHAR) |
1005 | if (*tp == NOCHAR) |
|
|
1006 | { |
976 | *tp = ' '; // hack //D //TODO //--tp, --rp; |
1007 | // hack //D //TODO //--tp, --rp; |
|
|
1008 | *tp = ' '; |
|
|
1009 | *rp &= ~RS_baseattrMask; |
|
|
1010 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
|
|
1011 | } |
977 | |
1012 | |
978 | // first try to find a precomposed character |
1013 | // first try to find a precomposed character |
979 | unicode_t n = rxvt_compose (*tp, c); |
1014 | unicode_t n = rxvt_compose (*tp, c); |
980 | if (n == NOCHAR) |
1015 | if (n == NOCHAR) |
981 | n = rxvt_composite.compose (*tp, c); |
1016 | n = rxvt_composite.compose (*tp, c); |
982 | |
1017 | |
983 | *tp = n; |
1018 | *tp = n; |
984 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
1019 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
985 | #endif |
1020 | #endif |
986 | } |
1021 | } |
987 | } |
1022 | } |
988 | |
1023 | |
989 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
1024 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
… | |
… | |
1028 | * Process Horizontal Tab |
1063 | * Process Horizontal Tab |
1029 | * count: +ve = forward; -ve = backwards |
1064 | * count: +ve = forward; -ve = backwards |
1030 | * XTERM_SEQ: CTRL-I |
1065 | * XTERM_SEQ: CTRL-I |
1031 | */ |
1066 | */ |
1032 | void |
1067 | void |
1033 | rxvt_term::scr_tab (int count) |
1068 | rxvt_term::scr_tab (int count, bool ht) |
1034 | { |
1069 | { |
1035 | int i, x; |
1070 | int i, x; |
1036 | |
1071 | |
1037 | want_refresh = 1; |
1072 | want_refresh = 1; |
1038 | i = x = screen.cur.col; |
1073 | i = x = screen.cur.col; |
1039 | |
1074 | |
1040 | if (count == 0) |
1075 | if (count == 0) |
1041 | return; |
1076 | return; |
1042 | else if (count > 0) |
1077 | else if (count > 0) |
1043 | { |
1078 | { |
|
|
1079 | int row = TermWin.saveLines + screen.cur.row; |
|
|
1080 | text_t *tp = screen.text[row]; |
|
|
1081 | rend_t *rp = screen.rend[row]; |
|
|
1082 | rend_t base_rend = rp[i]; |
|
|
1083 | ht &= tp[i] == ' '; |
|
|
1084 | |
1044 | for (; ++i < TermWin.ncol; ) |
1085 | for (; ++i < TermWin.ncol; ) |
1045 | if (tabs[i]) |
1086 | if (tabs[i]) |
1046 | { |
1087 | { |
1047 | x = i; |
1088 | x = i; |
1048 | if (!--count) |
1089 | if (!--count) |
1049 | break; |
1090 | break; |
1050 | } |
1091 | } |
|
|
1092 | else |
|
|
1093 | ht &= tp[i] == ' ' |
|
|
1094 | && RS_SAME (rp[i], base_rend); |
1051 | |
1095 | |
1052 | if (count) |
1096 | if (count) |
1053 | x = TermWin.ncol - 1; |
1097 | x = TermWin.ncol - 1; |
|
|
1098 | |
|
|
1099 | // store horizontal tab commands as characters inside the text |
|
|
1100 | // buffer so they can be selected and pasted. |
|
|
1101 | if (ht) |
|
|
1102 | { |
|
|
1103 | base_rend = SET_FONT (base_rend, 0); |
|
|
1104 | |
|
|
1105 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
|
|
1106 | MAX_IT (screen.tlen[row], x); |
|
|
1107 | |
|
|
1108 | i = screen.cur.col; |
|
|
1109 | |
|
|
1110 | tp[i] = '\t'; |
|
|
1111 | rp[i] = base_rend; |
|
|
1112 | |
|
|
1113 | while (++i < x) |
|
|
1114 | { |
|
|
1115 | tp[i] = NOCHAR; |
|
|
1116 | rp[i] = base_rend; |
|
|
1117 | } |
|
|
1118 | } |
1054 | } |
1119 | } |
1055 | else /* if (count < 0) */ |
1120 | else /* if (count < 0) */ |
1056 | { |
1121 | { |
1057 | for (; --i >= 0; ) |
1122 | for (; --i >= 0; ) |
1058 | if (tabs[i]) |
1123 | if (tabs[i]) |
… | |
… | |
1349 | ZERO_SCROLLBACK (); |
1414 | ZERO_SCROLLBACK (); |
1350 | |
1415 | |
1351 | num_scr_allow = 0; |
1416 | num_scr_allow = 0; |
1352 | selection_check (3); |
1417 | selection_check (3); |
1353 | |
1418 | |
1354 | fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E')); |
1419 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1355 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1420 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1356 | { |
1421 | { |
1357 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1422 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1358 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1423 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1359 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
1424 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
… | |
… | |
1568 | { |
1633 | { |
1569 | if (mode) |
1634 | if (mode) |
1570 | screen.flags |= Screen_Relative; |
1635 | screen.flags |= Screen_Relative; |
1571 | else |
1636 | else |
1572 | screen.flags &= ~Screen_Relative; |
1637 | screen.flags &= ~Screen_Relative; |
|
|
1638 | |
1573 | scr_gotorc (0, 0, 0); |
1639 | scr_gotorc (0, 0, 0); |
1574 | } |
1640 | } |
1575 | |
1641 | |
1576 | /* ------------------------------------------------------------------------- */ |
1642 | /* ------------------------------------------------------------------------- */ |
1577 | /* |
1643 | /* |
… | |
… | |
1617 | |
1683 | |
1618 | if (rvideo != mode) |
1684 | if (rvideo != mode) |
1619 | { |
1685 | { |
1620 | rvideo = mode; |
1686 | rvideo = mode; |
1621 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1687 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1622 | #if defined(XPM_BACKGROUND) |
1688 | #if XPM_BACKGROUND |
1623 | if (bgPixmap.pixmap == None) |
1689 | if (bgPixmap.pixmap == None) |
1624 | #endif |
1690 | #endif |
1625 | #if defined(TRANSPARENT) |
1691 | #if TRANSPARENT |
1626 | if (! (options & Opt_transparent) || am_transparent == 0) |
1692 | if (! (options & Opt_transparent) || am_transparent == 0) |
1627 | #endif |
1693 | #endif |
1628 | XSetWindowBackground (display->display, TermWin.vt, |
1694 | XSetWindowBackground (display->display, TermWin.vt, |
1629 | pix_colors[Color_bg]); |
1695 | pix_colors[Color_bg]); |
1630 | |
1696 | |
… | |
… | |
1808 | */ |
1874 | */ |
1809 | int |
1875 | int |
1810 | rxvt_term::scr_move_to (int y, int len) |
1876 | rxvt_term::scr_move_to (int y, int len) |
1811 | { |
1877 | { |
1812 | long p = 0; |
1878 | long p = 0; |
1813 | uint16_t oldviewstart; |
1879 | unsigned int oldviewstart; |
1814 | |
1880 | |
1815 | oldviewstart = TermWin.view_start; |
1881 | oldviewstart = TermWin.view_start; |
1816 | |
1882 | |
1817 | if (y < len) |
1883 | if (y < len) |
1818 | { |
1884 | { |
1819 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1885 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1820 | p -= (long) (TermWin.nrow - 1); |
1886 | p -= (long) (TermWin.nrow - 1); |
1821 | p = max (p, 0); |
1887 | p = max (p, 0); |
1822 | } |
1888 | } |
1823 | |
1889 | |
1824 | TermWin.view_start = (uint16_t)min (p, TermWin.nscrolled); |
1890 | TermWin.view_start = (unsigned int)min (p, TermWin.nscrolled); |
1825 | |
1891 | |
1826 | return scr_changeview (oldviewstart); |
1892 | return scr_changeview (oldviewstart); |
1827 | } |
1893 | } |
1828 | |
1894 | |
1829 | /* ------------------------------------------------------------------------- */ |
1895 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1833 | */ |
1899 | */ |
1834 | int |
1900 | int |
1835 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1901 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1836 | { |
1902 | { |
1837 | int n; |
1903 | int n; |
1838 | uint16_t oldviewstart; |
1904 | unsigned int oldviewstart; |
1839 | |
1905 | |
1840 | #ifdef DEBUG_STRICT |
1906 | #ifdef DEBUG_STRICT |
1841 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1907 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1842 | #endif |
1908 | #endif |
1843 | oldviewstart = TermWin.view_start; |
1909 | oldviewstart = TermWin.view_start; |
… | |
… | |
1853 | } |
1919 | } |
1854 | return scr_changeview (oldviewstart); |
1920 | return scr_changeview (oldviewstart); |
1855 | } |
1921 | } |
1856 | |
1922 | |
1857 | int |
1923 | int |
1858 | rxvt_term::scr_changeview (uint16_t oldviewstart) |
1924 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1859 | { |
1925 | { |
1860 | if (TermWin.view_start != oldviewstart) |
1926 | if (TermWin.view_start != oldviewstart) |
1861 | { |
1927 | { |
1862 | want_refresh = 1; |
1928 | want_refresh = 1; |
1863 | num_scr -= (TermWin.view_start - oldviewstart); |
1929 | num_scr -= (TermWin.view_start - oldviewstart); |
… | |
… | |
1960 | |
2026 | |
1961 | void |
2027 | void |
1962 | rxvt_term::scr_refresh (unsigned char refresh_type) |
2028 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1963 | { |
2029 | { |
1964 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2030 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1965 | rvid, /* reverse video this position */ |
|
|
1966 | showcursor; /* show the cursor */ |
2031 | showcursor; /* show the cursor */ |
1967 | int16_t col, row, /* column/row we're processing */ |
2032 | int16_t col, row, /* column/row we're processing */ |
1968 | ocrow; /* old cursor row */ |
2033 | ocrow; /* old cursor row */ |
1969 | int i, /* tmp */ |
2034 | int i, /* tmp */ |
1970 | row_offset; /* basic offset in screen structure */ |
2035 | row_offset; /* basic offset in screen structure */ |
… | |
… | |
1982 | must_clear = 0; |
2047 | must_clear = 0; |
1983 | refresh_count = 0; |
2048 | refresh_count = 0; |
1984 | |
2049 | |
1985 | row_offset = TermWin.saveLines - TermWin.view_start; |
2050 | row_offset = TermWin.saveLines - TermWin.view_start; |
1986 | |
2051 | |
1987 | #ifdef XPM_BACKGROUND |
2052 | #if XPM_BACKGROUND |
1988 | must_clear |= (bgPixmap.pixmap != None); |
2053 | must_clear |= (bgPixmap.pixmap != None); |
1989 | #endif |
2054 | #endif |
1990 | #ifdef TRANSPARENT |
2055 | #if TRANSPARENT |
1991 | must_clear |= ((options & Opt_transparent) && am_transparent); |
2056 | must_clear |= ((options & Opt_transparent) && am_transparent); |
1992 | #endif |
2057 | #endif |
1993 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2058 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1994 | |
2059 | |
1995 | /* |
2060 | /* |
1996 | * B: reverse any characters which are selected |
2061 | * B: reverse any characters which are selected |
1997 | */ |
2062 | */ |
1998 | scr_reverse_selection (); |
2063 | scr_reverse_selection (); |
1999 | #if ENABLE_OVERLAY |
|
|
2000 | scr_swap_overlay (); |
|
|
2001 | #endif |
|
|
2002 | |
2064 | |
2003 | /* |
2065 | /* |
2004 | * C: set the cursor character (s) |
2066 | * C: set the cursor character (s) |
2005 | */ |
2067 | */ |
2006 | { |
2068 | { |
… | |
… | |
2080 | oldcursor.col = screen.cur.col; |
2142 | oldcursor.col = screen.cur.col; |
2081 | } |
2143 | } |
2082 | } |
2144 | } |
2083 | } |
2145 | } |
2084 | |
2146 | |
|
|
2147 | #if ENABLE_OVERLAY |
|
|
2148 | scr_swap_overlay (); |
|
|
2149 | #endif |
|
|
2150 | |
2085 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
2151 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
2086 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
2152 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
|
|
2153 | |
2087 | #ifndef NO_SLOW_LINK_SUPPORT |
2154 | #ifndef NO_SLOW_LINK_SUPPORT |
2088 | /* |
2155 | /* |
2089 | * D: CopyArea pass - very useful for slower links |
2156 | * D: CopyArea pass - very useful for slower links |
2090 | * This has been deliberately kept simple. |
2157 | * This has been deliberately kept simple. |
2091 | */ |
2158 | */ |
… | |
… | |
2168 | |
2235 | |
2169 | for (col = 0; col < TermWin.ncol; col++) |
2236 | for (col = 0; col < TermWin.ncol; col++) |
2170 | { |
2237 | { |
2171 | /* compare new text with old - if exactly the same then continue */ |
2238 | /* compare new text with old - if exactly the same then continue */ |
2172 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2239 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2173 | && (srp[col] == drp[col] /* Either rendition the same or */ |
2240 | && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ |
2174 | || (stp[col] == ' ' /* space w/ no background change */ |
2241 | || (stp[col] == ' ' /* space w/ no background change */ |
2175 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2242 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2176 | continue; |
2243 | continue; |
2177 | |
2244 | |
2178 | // redraw one or more characters |
2245 | // redraw one or more characters |
… | |
… | |
2188 | dtp[col] = stp[col]; |
2255 | dtp[col] = stp[col]; |
2189 | drp[col] = rend; |
2256 | drp[col] = rend; |
2190 | |
2257 | |
2191 | int xpixel = Col2Pixel (col); |
2258 | int xpixel = Col2Pixel (col); |
2192 | |
2259 | |
2193 | // this loop looks very messy, it can probably be optimized |
|
|
2194 | // and cleaned a bit by you? |
|
|
2195 | for (i = 0; ++col < TermWin.ncol; ) |
2260 | for (i = 0; ++col < TermWin.ncol; ) |
2196 | { |
2261 | { |
2197 | if (stp[col] == NOCHAR) |
2262 | if (stp[col] == NOCHAR) |
2198 | { |
2263 | { |
2199 | dtp[col] = stp[col]; |
2264 | dtp[col] = stp[col]; |
… | |
… | |
2202 | i++; |
2267 | i++; |
2203 | |
2268 | |
2204 | continue; |
2269 | continue; |
2205 | } |
2270 | } |
2206 | |
2271 | |
2207 | if (rend != srp[col]) |
2272 | if (!RS_SAME (rend, srp[col])) |
2208 | break; |
2273 | break; |
2209 | |
2274 | |
2210 | count++; |
2275 | count++; |
2211 | |
2276 | |
2212 | if (stp[col] != dtp[col] |
2277 | if (stp[col] != dtp[col] |
2213 | || srp[col] != drp[col]) |
2278 | || !RS_SAME (srp[col], drp[col])) |
2214 | { |
2279 | { |
2215 | if (must_clear && (i++ > count / 2)) |
2280 | if (must_clear && (i++ > count / 2)) |
2216 | break; |
2281 | break; |
2217 | |
2282 | |
2218 | dtp[col] = stp[col]; |
2283 | dtp[col] = stp[col]; |
… | |
… | |
2228 | |
2293 | |
2229 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2294 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2230 | while (i && text[count] == NOCHAR) |
2295 | while (i && text[count] == NOCHAR) |
2231 | count++, i--; |
2296 | count++, i--; |
2232 | |
2297 | |
|
|
2298 | #if ENABLE_STYLES |
|
|
2299 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2300 | if (srp[col] & RS_Careful && col < TermWin.ncol - 1 && 0) |
|
|
2301 | drp[col + 1] = ~srp[col + 1]; |
|
|
2302 | |
|
|
2303 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2304 | while (text > stp |
|
|
2305 | && srp[text - stp - 1] & RS_Careful |
|
|
2306 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2307 | text--, count++, xpixel -= TermWin.fwidth; |
|
|
2308 | #endif |
|
|
2309 | |
2233 | /* |
2310 | /* |
2234 | * Determine the attributes for the string |
2311 | * Determine the attributes for the string |
2235 | */ |
2312 | */ |
2236 | int fid = GET_FONT (rend); |
|
|
2237 | int fore = GET_FGCOLOR (rend); // desired foreground |
2313 | int fore = GET_FGCOLOR (rend); // desired foreground |
2238 | int back = GET_BGCOLOR (rend); // desired background |
2314 | int back = GET_BGCOLOR (rend); // desired background |
2239 | |
2315 | |
2240 | rend = GET_ATTR (rend); |
2316 | // only do special processing if ana attributes are set, which is rare |
2241 | |
2317 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink)) |
2242 | rvid = !!(rend & RS_RVid); |
2318 | { |
|
|
2319 | bool invert = rend & RS_RVid; |
2243 | |
2320 | |
2244 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2321 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2245 | if (rend & RS_Bold && fore == Color_fg && !(options & Opt_realBold)) |
2322 | if (rend & RS_Bold |
|
|
2323 | && fore == Color_fg) |
2246 | { |
2324 | { |
2247 | if (ISSET_PIXCOLOR (Color_BD)) |
2325 | if (ISSET_PIXCOLOR (Color_BD)) |
2248 | fore = Color_BD; |
2326 | fore = Color_BD; |
|
|
2327 | # if !ENABLE_STYLES |
2249 | else |
2328 | else |
2250 | rvid = !rvid; |
2329 | invert = !invert; |
|
|
2330 | # endif |
|
|
2331 | } |
|
|
2332 | |
|
|
2333 | if (rend & RS_Italic |
|
|
2334 | && fore == Color_fg) |
|
|
2335 | { |
|
|
2336 | if (ISSET_PIXCOLOR (Color_IT)) |
|
|
2337 | fore = Color_IT; |
|
|
2338 | # if !ENABLE_STYLES |
|
|
2339 | else |
|
|
2340 | invert = !invert; |
|
|
2341 | # endif |
|
|
2342 | } |
|
|
2343 | |
|
|
2344 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
|
|
2345 | fore = Color_UL; |
|
|
2346 | #endif |
|
|
2347 | |
|
|
2348 | if (invert) |
|
|
2349 | { |
|
|
2350 | SWAP_IT (fore, back, int); |
|
|
2351 | |
|
|
2352 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2353 | if (ISSET_PIXCOLOR (Color_RV)) |
|
|
2354 | back = Color_RV; |
|
|
2355 | #endif |
|
|
2356 | } |
|
|
2357 | |
|
|
2358 | #ifdef TEXT_BLINK |
|
|
2359 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
|
|
2360 | { |
|
|
2361 | if (!text_blink_ev.active) |
|
|
2362 | { |
|
|
2363 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2364 | hidden_text = 0; |
|
|
2365 | } |
|
|
2366 | else if (hidden_text) |
|
|
2367 | fore = back; |
|
|
2368 | } |
|
|
2369 | #endif |
2251 | } |
2370 | } |
2252 | |
|
|
2253 | if (rend & RS_Uline) |
|
|
2254 | if (ISSET_PIXCOLOR (Color_UL)) |
|
|
2255 | fore = Color_UL; |
|
|
2256 | #endif |
|
|
2257 | |
|
|
2258 | if (rvid) |
|
|
2259 | { |
|
|
2260 | SWAP_IT (fore, back, int); |
|
|
2261 | |
|
|
2262 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2263 | if (ISSET_PIXCOLOR (Color_RV) |
|
|
2264 | # ifndef NO_CURSORCOLOR |
|
|
2265 | && !ISSET_PIXCOLOR (Color_cursor) |
|
|
2266 | # endif |
|
|
2267 | ) |
|
|
2268 | back = Color_RV; |
|
|
2269 | #endif |
|
|
2270 | } |
|
|
2271 | |
|
|
2272 | #ifdef TEXT_BLINK |
|
|
2273 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
|
|
2274 | { |
|
|
2275 | if (!text_blink_ev.active) |
|
|
2276 | { |
|
|
2277 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2278 | hidden_text = 0; |
|
|
2279 | } |
|
|
2280 | else if (hidden_text) |
|
|
2281 | fore = back; |
|
|
2282 | } |
|
|
2283 | #endif |
|
|
2284 | |
2371 | |
2285 | /* |
2372 | /* |
2286 | * Actually do the drawing of the string here |
2373 | * Actually do the drawing of the string here |
2287 | */ |
2374 | */ |
2288 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2375 | rxvt_font *font = (*TermWin.fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2289 | |
2376 | |
2290 | if (back == fore) |
2377 | if (back == fore) |
2291 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2378 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2292 | TermWin.fwidth * count, TermWin.fheight, |
2379 | TermWin.fwidth * count, TermWin.fheight, |
2293 | back); |
2380 | back); |
… | |
… | |
2315 | xpixel, ypixel + font->ascent + 1, |
2402 | xpixel, ypixel + font->ascent + 1, |
2316 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2403 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2317 | } /* for (col....) */ |
2404 | } /* for (col....) */ |
2318 | } /* for (row....) */ |
2405 | } /* for (row....) */ |
2319 | |
2406 | |
|
|
2407 | #if ENABLE_OVERLAY |
|
|
2408 | scr_swap_overlay (); |
|
|
2409 | #endif |
|
|
2410 | |
2320 | /* |
2411 | /* |
2321 | * G: cleanup cursor and display outline cursor if necessary |
2412 | * G: cleanup cursor and display outline cursor if necessary |
2322 | */ |
2413 | */ |
2323 | if (showcursor) |
2414 | if (showcursor) |
2324 | { |
2415 | { |
… | |
… | |
2349 | } |
2440 | } |
2350 | |
2441 | |
2351 | /* |
2442 | /* |
2352 | * H: cleanup selection |
2443 | * H: cleanup selection |
2353 | */ |
2444 | */ |
2354 | #if ENABLE_OVERLAY |
|
|
2355 | scr_swap_overlay (); |
|
|
2356 | #endif |
|
|
2357 | scr_reverse_selection (); |
2445 | scr_reverse_selection (); |
2358 | |
2446 | |
2359 | if (refresh_type & SMOOTH_REFRESH) |
2447 | if (refresh_type & SMOOTH_REFRESH) |
2360 | XFlush (display->display); |
2448 | XFlush (display->display); |
2361 | |
2449 | |
… | |
… | |
2369 | { |
2457 | { |
2370 | if (!rp || !tp) |
2458 | if (!rp || !tp) |
2371 | return; |
2459 | return; |
2372 | |
2460 | |
2373 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2461 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2374 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
2462 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
2375 | } |
2463 | } |
2376 | |
2464 | |
2377 | void |
2465 | void |
2378 | rxvt_term::scr_remap_chars () |
2466 | rxvt_term::scr_remap_chars () |
2379 | { |
2467 | { |
… | |
… | |
2385 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2473 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2386 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2474 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2387 | } |
2475 | } |
2388 | } |
2476 | } |
2389 | |
2477 | |
|
|
2478 | void |
|
|
2479 | rxvt_term::scr_recolour () |
|
|
2480 | { |
|
|
2481 | if (1 |
|
|
2482 | #if TRANSPARENT |
|
|
2483 | && !am_transparent |
|
|
2484 | #endif |
|
|
2485 | #if XPM_BACKGROUND |
|
|
2486 | && !bgPixmap.pixmap |
|
|
2487 | #endif |
|
|
2488 | ) |
|
|
2489 | { |
|
|
2490 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors[Color_border]); |
|
|
2491 | XClearWindow (display->display, TermWin.parent[0]); |
|
|
2492 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
|
|
2493 | #if HAVE_SCROLLBARS |
|
|
2494 | if (scrollBar.win) |
|
|
2495 | { |
|
|
2496 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
|
|
2497 | scrollBar.setIdle (); |
|
|
2498 | scrollbar_show (0); |
|
|
2499 | } |
|
|
2500 | #endif |
|
|
2501 | } |
|
|
2502 | |
|
|
2503 | scr_clear (); |
|
|
2504 | scr_touch (true); |
|
|
2505 | want_refresh = 1; |
|
|
2506 | } |
|
|
2507 | |
2390 | /* ------------------------------------------------------------------------- */ |
2508 | /* ------------------------------------------------------------------------- */ |
2391 | void |
2509 | void |
2392 | rxvt_term::scr_clear (bool really) |
2510 | rxvt_term::scr_clear (bool really) |
2393 | { |
2511 | { |
2394 | if (!TermWin.mapped) |
2512 | if (!TermWin.mapped) |
2395 | return; |
2513 | return; |
2396 | |
2514 | |
2397 | num_scr_allow = 0; |
2515 | num_scr_allow = 0; |
2398 | want_refresh = 1; |
2516 | want_refresh = 1; |
2399 | |
2517 | |
2400 | #ifdef TRANSPARENT |
2518 | #if TRANSPARENT |
2401 | if ((options & Opt_transparent) && (am_pixmap_trans == 0)) |
2519 | if ((options & Opt_transparent) && (am_pixmap_trans == 0)) |
2402 | { |
2520 | { |
2403 | int i; |
2521 | int i; |
2404 | |
2522 | |
2405 | if (! (options & Opt_transparent_all)) |
2523 | if (!(options & Opt_transparent_all)) |
2406 | i = 0; |
2524 | i = 0; |
2407 | else |
2525 | else |
2408 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2526 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2409 | |
2527 | |
2410 | while (i--) |
2528 | while (i--) |
… | |
… | |
3507 | { |
3625 | { |
3508 | text_t *tp = ov_text[y] = new text_t[w]; |
3626 | text_t *tp = ov_text[y] = new text_t[w]; |
3509 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3627 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3510 | |
3628 | |
3511 | text_t t0, t1, t2; |
3629 | text_t t0, t1, t2; |
3512 | rend_t r = SET_BGCOLOR (SET_FGCOLOR (RS_None, Color_bg), Color_fg); |
3630 | rend_t r = OVERLAY_RSTYLE; |
3513 | |
3631 | |
3514 | if (y == 0) |
3632 | if (y == 0) |
3515 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
3633 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
3516 | else if (y < h - 1) |
3634 | else if (y < h - 1) |
3517 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
3635 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
… | |
… | |
3551 | } |
3669 | } |
3552 | |
3670 | |
3553 | void |
3671 | void |
3554 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3672 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3555 | { |
3673 | { |
3556 | if (!ov_text || x >= ov_w - 2 || y >= ov_h) |
3674 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3557 | return; |
3675 | return; |
3558 | |
3676 | |
3559 | x++, y++; |
3677 | x++, y++; |
3560 | |
3678 | |
3561 | ov_text[y][x] = text; |
3679 | ov_text[y][x] = text; |
… | |
… | |
3587 | rend_t *r2 = screen.rend[y + row_offset] + ov_x; |
3705 | rend_t *r2 = screen.rend[y + row_offset] + ov_x; |
3588 | |
3706 | |
3589 | for (int x = ov_w; x--; ) |
3707 | for (int x = ov_w; x--; ) |
3590 | { |
3708 | { |
3591 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3709 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3592 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, TermWin.fontset->find_font (t, false)); |
3710 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3593 | } |
3711 | } |
3594 | } |
3712 | } |
3595 | } |
3713 | } |
3596 | |
3714 | |
3597 | #endif |
3715 | #endif |