… | |
… | |
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; |
… | |
… | |
959 | |
989 | |
960 | if (screen.cur.col > 0) |
990 | if (screen.cur.col > 0) |
961 | { |
991 | { |
962 | tp = stp + screen.cur.col - 1; |
992 | tp = stp + screen.cur.col - 1; |
963 | rp = srp + screen.cur.col - 1; |
993 | rp = srp + screen.cur.col - 1; |
|
|
994 | |
|
|
995 | while (*tp == NOCHAR && tp > stp) |
|
|
996 | tp--, rp--; |
964 | } |
997 | } |
965 | else if (screen.cur.row > 0 |
998 | else if (screen.cur.row > 0 |
966 | && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1) |
999 | && screen.tlen [screen.cur.row - 1 + TermWin.saveLines] == -1) |
967 | { |
1000 | { |
968 | tp = screen.text[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; |
1001 | int line = screen.cur.row - 1 + TermWin.saveLines; |
969 | rp = screen.rend[screen.cur.row - 1 + TermWin.saveLines] + last_col - 1; |
1002 | |
|
|
1003 | tp = screen.text[line] + last_col - 1; |
|
|
1004 | rp = screen.rend[line] + last_col - 1; |
|
|
1005 | |
|
|
1006 | while (*tp == NOCHAR && tp > screen.text[line]) |
|
|
1007 | tp--, rp--; |
970 | } |
1008 | } |
971 | else |
1009 | else |
972 | continue; |
1010 | continue; |
973 | |
|
|
974 | // handle double-width-chars by making them look extremely ugly |
|
|
975 | if (*tp == NOCHAR) |
|
|
976 | *tp = ' '; // hack //D //TODO //--tp, --rp; |
|
|
977 | |
1011 | |
978 | // first try to find a precomposed character |
1012 | // first try to find a precomposed character |
979 | unicode_t n = rxvt_compose (*tp, c); |
1013 | unicode_t n = rxvt_compose (*tp, c); |
980 | if (n == NOCHAR) |
1014 | if (n == NOCHAR) |
981 | n = rxvt_composite.compose (*tp, c); |
1015 | n = rxvt_composite.compose (*tp, c); |
982 | |
1016 | |
983 | *tp = n; |
1017 | *tp = n; |
984 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
1018 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
985 | #endif |
1019 | #endif |
986 | } |
1020 | } |
987 | } |
1021 | } |
988 | |
1022 | |
989 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
1023 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
… | |
… | |
1028 | * Process Horizontal Tab |
1062 | * Process Horizontal Tab |
1029 | * count: +ve = forward; -ve = backwards |
1063 | * count: +ve = forward; -ve = backwards |
1030 | * XTERM_SEQ: CTRL-I |
1064 | * XTERM_SEQ: CTRL-I |
1031 | */ |
1065 | */ |
1032 | void |
1066 | void |
1033 | rxvt_term::scr_tab (int count) |
1067 | rxvt_term::scr_tab (int count, bool ht) |
1034 | { |
1068 | { |
1035 | int i, x; |
1069 | int i, x; |
1036 | |
1070 | |
1037 | want_refresh = 1; |
1071 | want_refresh = 1; |
1038 | i = x = screen.cur.col; |
1072 | i = x = screen.cur.col; |
1039 | |
1073 | |
1040 | if (count == 0) |
1074 | if (count == 0) |
1041 | return; |
1075 | return; |
1042 | else if (count > 0) |
1076 | else if (count > 0) |
1043 | { |
1077 | { |
|
|
1078 | int row = TermWin.saveLines + screen.cur.row; |
|
|
1079 | text_t *tp = screen.text[row]; |
|
|
1080 | rend_t *rp = screen.rend[row]; |
|
|
1081 | rend_t base_rend = rp[i]; |
|
|
1082 | ht &= tp[i] == ' '; |
|
|
1083 | |
1044 | for (; ++i < TermWin.ncol; ) |
1084 | for (; ++i < TermWin.ncol; ) |
1045 | if (tabs[i]) |
1085 | if (tabs[i]) |
1046 | { |
1086 | { |
1047 | x = i; |
1087 | x = i; |
1048 | if (!--count) |
1088 | if (!--count) |
1049 | break; |
1089 | break; |
1050 | } |
1090 | } |
|
|
1091 | else |
|
|
1092 | ht &= tp[i] == ' ' |
|
|
1093 | && RS_SAME (rp[i], base_rend); |
1051 | |
1094 | |
1052 | if (count) |
1095 | if (count) |
1053 | x = TermWin.ncol - 1; |
1096 | x = TermWin.ncol - 1; |
|
|
1097 | |
|
|
1098 | // store horizontal tab commands as characters inside the text |
|
|
1099 | // buffer so they can be selected and pasted. |
|
|
1100 | if (ht) |
|
|
1101 | { |
|
|
1102 | base_rend = SET_FONT (base_rend, 0); |
|
|
1103 | |
|
|
1104 | if (screen.tlen[row] != -1) /* XXX: think about this */ |
|
|
1105 | MAX_IT (screen.tlen[row], x); |
|
|
1106 | |
|
|
1107 | i = screen.cur.col; |
|
|
1108 | |
|
|
1109 | tp[i] = '\t'; |
|
|
1110 | rp[i] = base_rend; |
|
|
1111 | |
|
|
1112 | while (++i < x) |
|
|
1113 | { |
|
|
1114 | tp[i] = NOCHAR; |
|
|
1115 | rp[i] = base_rend; |
|
|
1116 | } |
|
|
1117 | } |
1054 | } |
1118 | } |
1055 | else /* if (count < 0) */ |
1119 | else /* if (count < 0) */ |
1056 | { |
1120 | { |
1057 | for (; --i >= 0; ) |
1121 | for (; --i >= 0; ) |
1058 | if (tabs[i]) |
1122 | if (tabs[i]) |
… | |
… | |
1349 | ZERO_SCROLLBACK (); |
1413 | ZERO_SCROLLBACK (); |
1350 | |
1414 | |
1351 | num_scr_allow = 0; |
1415 | num_scr_allow = 0; |
1352 | selection_check (3); |
1416 | selection_check (3); |
1353 | |
1417 | |
1354 | fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E')); |
1418 | fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); |
1355 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1419 | for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) |
1356 | { |
1420 | { |
1357 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1421 | screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ |
1358 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1422 | fill_text (screen.text[k], 'E', TermWin.ncol); |
1359 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
1423 | for (r1 = screen.rend[k], j = TermWin.ncol; j--; ) |
… | |
… | |
1422 | slp = &screen.tlen[row]; |
1486 | slp = &screen.tlen[row]; |
1423 | |
1487 | |
1424 | switch (insdel) |
1488 | switch (insdel) |
1425 | { |
1489 | { |
1426 | case INSERT: |
1490 | case INSERT: |
1427 | for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; |
1491 | for (col = TermWin.ncol - 1; (col - count) >= screen.cur.col; col--) |
1428 | col--) |
|
|
1429 | { |
1492 | { |
1430 | stp[col] = stp[col - count]; |
1493 | stp[col] = stp[col - count]; |
1431 | srp[col] = srp[col - count]; |
1494 | srp[col] = srp[col - count]; |
1432 | } |
1495 | } |
1433 | |
1496 | |
… | |
… | |
1443 | if (selection.end.row != screen.cur.row |
1506 | if (selection.end.row != screen.cur.row |
1444 | || (selection.end.col + count >= TermWin.ncol)) |
1507 | || (selection.end.col + count >= TermWin.ncol)) |
1445 | CLEAR_SELECTION (); |
1508 | CLEAR_SELECTION (); |
1446 | else |
1509 | else |
1447 | { /* shift selection */ |
1510 | { /* shift selection */ |
1448 | selection.beg.col += count; |
1511 | selection.beg.col += count; |
1449 | selection.mark.col += count; /* XXX: yes? */ |
1512 | selection.mark.col += count; /* XXX: yes? */ |
1450 | selection.end.col += count; |
1513 | selection.end.col += count; |
1451 | } |
1514 | } |
1452 | } |
1515 | } |
1453 | |
1516 | |
1454 | scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), |
1517 | scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col], |
1455 | (unsigned int)count, rstyle); |
1518 | (unsigned int)count, rstyle); |
1456 | break; |
1519 | break; |
1457 | |
1520 | |
1458 | case ERASE: |
1521 | case ERASE: |
1459 | screen.cur.col += count; /* don't worry if > TermWin.ncol */ |
1522 | screen.cur.col += count; /* don't worry if > TermWin.ncol */ |
1460 | selection_check (1); |
1523 | selection_check (1); |
1461 | screen.cur.col -= count; |
1524 | screen.cur.col -= count; |
1462 | scr_blank_line (& (stp[screen.cur.col]), & (srp[screen.cur.col]), |
1525 | scr_blank_line (&stp[screen.cur.col], &srp[screen.cur.col], |
1463 | (unsigned int)count, rstyle); |
1526 | (unsigned int)count, rstyle); |
1464 | break; |
1527 | break; |
1465 | |
1528 | |
1466 | case DELETE: |
1529 | case DELETE: |
1467 | tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
1530 | tr = srp[TermWin.ncol - 1] & (RS_fgMask | RS_bgMask | RS_baseattrMask); |
… | |
… | |
1470 | { |
1533 | { |
1471 | stp[col] = stp[col + count]; |
1534 | stp[col] = stp[col + count]; |
1472 | srp[col] = srp[col + count]; |
1535 | srp[col] = srp[col + count]; |
1473 | } |
1536 | } |
1474 | |
1537 | |
1475 | scr_blank_line (& (stp[TermWin.ncol - count]), |
1538 | scr_blank_line (&stp[TermWin.ncol - count], &srp[TermWin.ncol - count], |
1476 | & (srp[TermWin.ncol - count]), |
|
|
1477 | (unsigned int)count, tr); |
1539 | (unsigned int)count, tr); |
1478 | |
1540 | |
1479 | if (*slp == -1) /* break line continuation */ |
1541 | if (*slp == -1) /* break line continuation */ |
1480 | *slp = TermWin.ncol; |
1542 | *slp = TermWin.ncol; |
1481 | |
1543 | |
… | |
… | |
1490 | || selection.end.col >= TermWin.ncol) |
1552 | || selection.end.col >= TermWin.ncol) |
1491 | CLEAR_SELECTION (); |
1553 | CLEAR_SELECTION (); |
1492 | else |
1554 | else |
1493 | { |
1555 | { |
1494 | /* shift selection */ |
1556 | /* shift selection */ |
1495 | selection.beg.col -= count; |
1557 | selection.beg.col -= count; |
1496 | selection.mark.col -= count; /* XXX: yes? */ |
1558 | selection.mark.col -= count; /* XXX: yes? */ |
1497 | selection.end.col -= count; |
1559 | selection.end.col -= count; |
1498 | } |
1560 | } |
1499 | } |
1561 | } |
1500 | |
1562 | |
1501 | break; |
1563 | break; |
1502 | } |
1564 | } |
… | |
… | |
1568 | { |
1630 | { |
1569 | if (mode) |
1631 | if (mode) |
1570 | screen.flags |= Screen_Relative; |
1632 | screen.flags |= Screen_Relative; |
1571 | else |
1633 | else |
1572 | screen.flags &= ~Screen_Relative; |
1634 | screen.flags &= ~Screen_Relative; |
|
|
1635 | |
1573 | scr_gotorc (0, 0, 0); |
1636 | scr_gotorc (0, 0, 0); |
1574 | } |
1637 | } |
1575 | |
1638 | |
1576 | /* ------------------------------------------------------------------------- */ |
1639 | /* ------------------------------------------------------------------------- */ |
1577 | /* |
1640 | /* |
… | |
… | |
1617 | |
1680 | |
1618 | if (rvideo != mode) |
1681 | if (rvideo != mode) |
1619 | { |
1682 | { |
1620 | rvideo = mode; |
1683 | rvideo = mode; |
1621 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1684 | SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); |
1622 | #if defined(XPM_BACKGROUND) |
1685 | #if XPM_BACKGROUND |
1623 | if (bgPixmap.pixmap == None) |
1686 | if (bgPixmap.pixmap == None) |
1624 | #endif |
1687 | #endif |
1625 | #if defined(TRANSPARENT) |
1688 | #if TRANSPARENT |
1626 | if (! (options & Opt_transparent) || am_transparent == 0) |
1689 | if (! (options & Opt_transparent) || am_transparent == 0) |
1627 | #endif |
1690 | #endif |
1628 | XSetWindowBackground (display->display, TermWin.vt, |
1691 | XSetWindowBackground (display->display, TermWin.vt, |
1629 | pix_colors[Color_bg]); |
1692 | pix_colors[Color_bg]); |
1630 | |
1693 | |
… | |
… | |
1685 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1748 | * XTERM_SEQ: Invoke G2 character set: ESC N |
1686 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1749 | * XTERM_SEQ: Invoke G3 character set: ESC O |
1687 | */ |
1750 | */ |
1688 | void |
1751 | void |
1689 | rxvt_term::scr_charset_choose (int set) |
1752 | rxvt_term::scr_charset_choose (int set) |
1690 | { |
1753 | { |
1691 | screen.charset = set; |
1754 | screen.charset = set; |
1692 | set_font_style (); |
1755 | set_font_style (); |
1693 | } |
1756 | } |
1694 | |
1757 | |
1695 | /* ------------------------------------------------------------------------- */ |
1758 | /* ------------------------------------------------------------------------- */ |
1696 | /* |
1759 | /* |
1697 | * Set a font |
1760 | * Set a font |
1698 | * XTERM_SEQ: Set G0 character set: ESC ( <C> |
1761 | * XTERM_SEQ: Set G0 character set: ESC ( <C> |
… | |
… | |
1701 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1764 | * XTERM_SEQ: Set G3 character set: ESC + <C> |
1702 | * See set_font_style for possible values for <C> |
1765 | * See set_font_style for possible values for <C> |
1703 | */ |
1766 | */ |
1704 | void |
1767 | void |
1705 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1768 | rxvt_term::scr_charset_set (int set, unsigned int ch) |
1706 | { |
1769 | { |
1707 | charsets[set] = (unsigned char)ch; |
1770 | charsets[set] = (unsigned char)ch; |
1708 | set_font_style (); |
1771 | set_font_style (); |
1709 | } |
1772 | } |
1710 | |
1773 | |
1711 | |
1774 | |
1712 | /* ------------------------------------------------------------------------- * |
1775 | /* ------------------------------------------------------------------------- * |
1713 | * MAJOR SCREEN MANIPULATION * |
1776 | * MAJOR SCREEN MANIPULATION * |
1714 | * ------------------------------------------------------------------------- */ |
1777 | * ------------------------------------------------------------------------- */ |
… | |
… | |
1808 | */ |
1871 | */ |
1809 | int |
1872 | int |
1810 | rxvt_term::scr_move_to (int y, int len) |
1873 | rxvt_term::scr_move_to (int y, int len) |
1811 | { |
1874 | { |
1812 | long p = 0; |
1875 | long p = 0; |
1813 | uint16_t oldviewstart; |
1876 | unsigned int oldviewstart; |
1814 | |
1877 | |
1815 | oldviewstart = TermWin.view_start; |
1878 | oldviewstart = TermWin.view_start; |
1816 | |
1879 | |
1817 | if (y < len) |
1880 | if (y < len) |
1818 | { |
1881 | { |
1819 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1882 | p = (TermWin.nrow + TermWin.nscrolled) * (len - y) / len; |
1820 | p -= (long) (TermWin.nrow - 1); |
1883 | p -= (long) (TermWin.nrow - 1); |
1821 | p = max (p, 0); |
1884 | p = max (p, 0); |
1822 | } |
1885 | } |
1823 | |
1886 | |
1824 | TermWin.view_start = (uint16_t)min (p, TermWin.nscrolled); |
1887 | TermWin.view_start = (unsigned int)min (p, TermWin.nscrolled); |
1825 | |
1888 | |
1826 | return scr_changeview (oldviewstart); |
1889 | return scr_changeview (oldviewstart); |
1827 | } |
1890 | } |
1828 | |
1891 | |
1829 | /* ------------------------------------------------------------------------- */ |
1892 | /* ------------------------------------------------------------------------- */ |
… | |
… | |
1833 | */ |
1896 | */ |
1834 | int |
1897 | int |
1835 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1898 | rxvt_term::scr_page (enum page_dirn direction, int nlines) |
1836 | { |
1899 | { |
1837 | int n; |
1900 | int n; |
1838 | uint16_t oldviewstart; |
1901 | unsigned int oldviewstart; |
1839 | |
1902 | |
1840 | #ifdef DEBUG_STRICT |
1903 | #ifdef DEBUG_STRICT |
1841 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1904 | assert ((nlines >= 0) && (nlines <= TermWin.nrow)); |
1842 | #endif |
1905 | #endif |
1843 | oldviewstart = TermWin.view_start; |
1906 | oldviewstart = TermWin.view_start; |
… | |
… | |
1853 | } |
1916 | } |
1854 | return scr_changeview (oldviewstart); |
1917 | return scr_changeview (oldviewstart); |
1855 | } |
1918 | } |
1856 | |
1919 | |
1857 | int |
1920 | int |
1858 | rxvt_term::scr_changeview (uint16_t oldviewstart) |
1921 | rxvt_term::scr_changeview (unsigned int oldviewstart) |
1859 | { |
1922 | { |
1860 | if (TermWin.view_start != oldviewstart) |
1923 | if (TermWin.view_start != oldviewstart) |
1861 | { |
1924 | { |
1862 | want_refresh = 1; |
1925 | want_refresh = 1; |
1863 | num_scr -= (TermWin.view_start - oldviewstart); |
1926 | num_scr -= (TermWin.view_start - oldviewstart); |
… | |
… | |
1960 | |
2023 | |
1961 | void |
2024 | void |
1962 | rxvt_term::scr_refresh (unsigned char refresh_type) |
2025 | rxvt_term::scr_refresh (unsigned char refresh_type) |
1963 | { |
2026 | { |
1964 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
2027 | unsigned char must_clear, /* use draw_string not draw_image_string */ |
1965 | rvid, /* reverse video this position */ |
|
|
1966 | showcursor; /* show the cursor */ |
2028 | showcursor; /* show the cursor */ |
1967 | int16_t col, row, /* column/row we're processing */ |
2029 | int16_t col, row, /* column/row we're processing */ |
1968 | ocrow; /* old cursor row */ |
2030 | ocrow; /* old cursor row */ |
1969 | int i, /* tmp */ |
2031 | int i, /* tmp */ |
1970 | row_offset; /* basic offset in screen structure */ |
2032 | row_offset; /* basic offset in screen structure */ |
1971 | #ifndef NO_CURSORCOLOR |
2033 | #ifndef NO_CURSORCOLOR |
1972 | rend_t cc1; /* store colours at cursor position (s) */ |
2034 | rend_t cc1; /* store colours at cursor position (s) */ |
1973 | #endif |
2035 | #endif |
1974 | rend_t *crp; // cursor rendition pointer |
2036 | rend_t *crp; // cursor rendition pointer |
1975 | |
2037 | |
|
|
2038 | want_refresh = 0; /* screen is current */ |
|
|
2039 | |
1976 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
2040 | if (refresh_type == NO_REFRESH || !TermWin.mapped) |
1977 | return; |
2041 | return; |
1978 | |
2042 | |
1979 | /* |
2043 | /* |
1980 | * A: set up vars |
2044 | * A: set up vars |
… | |
… | |
1982 | must_clear = 0; |
2046 | must_clear = 0; |
1983 | refresh_count = 0; |
2047 | refresh_count = 0; |
1984 | |
2048 | |
1985 | row_offset = TermWin.saveLines - TermWin.view_start; |
2049 | row_offset = TermWin.saveLines - TermWin.view_start; |
1986 | |
2050 | |
1987 | #ifdef XPM_BACKGROUND |
2051 | #if XPM_BACKGROUND |
1988 | must_clear |= (bgPixmap.pixmap != None); |
2052 | must_clear |= (bgPixmap.pixmap != None); |
1989 | #endif |
2053 | #endif |
1990 | #ifdef TRANSPARENT |
2054 | #if TRANSPARENT |
1991 | must_clear |= ((options & Opt_transparent) && am_transparent); |
2055 | must_clear |= ((options & Opt_transparent) && am_transparent); |
1992 | #endif |
2056 | #endif |
1993 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
2057 | ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ |
1994 | |
2058 | |
1995 | /* |
2059 | /* |
1996 | * B: reverse any characters which are selected |
2060 | * B: reverse any characters which are selected |
1997 | */ |
2061 | */ |
1998 | scr_reverse_selection (); |
2062 | scr_reverse_selection (); |
1999 | #if ENABLE_OVERLAY |
|
|
2000 | scr_swap_overlay (); |
|
|
2001 | #endif |
|
|
2002 | |
2063 | |
2003 | /* |
2064 | /* |
2004 | * C: set the cursor character (s) |
2065 | * C: set the cursor character (s) |
2005 | */ |
2066 | */ |
2006 | { |
2067 | { |
… | |
… | |
2080 | oldcursor.col = screen.cur.col; |
2141 | oldcursor.col = screen.cur.col; |
2081 | } |
2142 | } |
2082 | } |
2143 | } |
2083 | } |
2144 | } |
2084 | |
2145 | |
|
|
2146 | #if ENABLE_OVERLAY |
|
|
2147 | scr_swap_overlay (); |
|
|
2148 | #endif |
|
|
2149 | |
2085 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
2150 | rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ |
2086 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
2151 | text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ |
|
|
2152 | |
2087 | #ifndef NO_SLOW_LINK_SUPPORT |
2153 | #ifndef NO_SLOW_LINK_SUPPORT |
2088 | /* |
2154 | /* |
2089 | * D: CopyArea pass - very useful for slower links |
2155 | * D: CopyArea pass - very useful for slower links |
2090 | * This has been deliberately kept simple. |
2156 | * This has been deliberately kept simple. |
2091 | */ |
2157 | */ |
… | |
… | |
2168 | |
2234 | |
2169 | for (col = 0; col < TermWin.ncol; col++) |
2235 | for (col = 0; col < TermWin.ncol; col++) |
2170 | { |
2236 | { |
2171 | /* compare new text with old - if exactly the same then continue */ |
2237 | /* compare new text with old - if exactly the same then continue */ |
2172 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2238 | if (stp[col] == dtp[col] /* Must match characters to skip. */ |
2173 | && (srp[col] == drp[col] /* Either rendition the same or */ |
2239 | && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ |
2174 | || (stp[col] == ' ' /* space w/ no background change */ |
2240 | || (stp[col] == ' ' /* space w/ no background change */ |
2175 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2241 | && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) |
2176 | continue; |
2242 | continue; |
2177 | |
2243 | |
2178 | // redraw one or more characters |
2244 | // redraw one or more characters |
… | |
… | |
2188 | dtp[col] = stp[col]; |
2254 | dtp[col] = stp[col]; |
2189 | drp[col] = rend; |
2255 | drp[col] = rend; |
2190 | |
2256 | |
2191 | int xpixel = Col2Pixel (col); |
2257 | int xpixel = Col2Pixel (col); |
2192 | |
2258 | |
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; ) |
2259 | for (i = 0; ++col < TermWin.ncol; ) |
2196 | { |
2260 | { |
2197 | if (stp[col] == NOCHAR) |
2261 | if (stp[col] == NOCHAR) |
2198 | { |
2262 | { |
2199 | dtp[col] = stp[col]; |
2263 | dtp[col] = stp[col]; |
… | |
… | |
2202 | i++; |
2266 | i++; |
2203 | |
2267 | |
2204 | continue; |
2268 | continue; |
2205 | } |
2269 | } |
2206 | |
2270 | |
2207 | if (rend != srp[col]) |
2271 | if (!RS_SAME (rend, srp[col])) |
2208 | break; |
2272 | break; |
2209 | |
2273 | |
2210 | count++; |
2274 | count++; |
2211 | |
2275 | |
2212 | if (stp[col] != dtp[col] |
2276 | if (stp[col] != dtp[col] |
2213 | || srp[col] != drp[col]) |
2277 | || !RS_SAME (srp[col], drp[col])) |
2214 | { |
2278 | { |
2215 | if (must_clear && (i++ > count / 2)) |
2279 | if (must_clear && (i++ > count / 2)) |
2216 | break; |
2280 | break; |
2217 | |
2281 | |
2218 | dtp[col] = stp[col]; |
2282 | dtp[col] = stp[col]; |
… | |
… | |
2228 | |
2292 | |
2229 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2293 | // sometimes we optimize away the trailing NOCHAR's, add them back |
2230 | while (i && text[count] == NOCHAR) |
2294 | while (i && text[count] == NOCHAR) |
2231 | count++, i--; |
2295 | count++, i--; |
2232 | |
2296 | |
|
|
2297 | #if ENABLE_STYLES |
|
|
2298 | // force redraw after "careful" characters to avoid pixel droppings |
|
|
2299 | if (srp[col] & RS_Careful && col < TermWin.ncol - 1 && 0) |
|
|
2300 | drp[col + 1] = ~srp[col + 1]; |
|
|
2301 | |
|
|
2302 | // include previous careful character(s) if possible, looks nicer (best effort...) |
|
|
2303 | while (text > stp |
|
|
2304 | && srp[text - stp - 1] & RS_Careful |
|
|
2305 | && RS_SAME (rend, srp[text - stp - 1])) |
|
|
2306 | text--, count++, xpixel -= TermWin.fwidth; |
|
|
2307 | #endif |
|
|
2308 | |
2233 | /* |
2309 | /* |
2234 | * Determine the attributes for the string |
2310 | * Determine the attributes for the string |
2235 | */ |
2311 | */ |
2236 | int fid = GET_FONT (rend); |
|
|
2237 | int fore = GET_FGCOLOR (rend); // desired foreground |
2312 | int fore = GET_FGCOLOR (rend); // desired foreground |
2238 | int back = GET_BGCOLOR (rend); // desired background |
2313 | int back = GET_BGCOLOR (rend); // desired background |
2239 | |
2314 | |
2240 | rend = GET_ATTR (rend); |
2315 | // only do special processing if ana attributes are set, which is rare |
2241 | |
2316 | if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink)) |
2242 | rvid = !!(rend & RS_RVid); |
2317 | { |
|
|
2318 | bool invert = rend & RS_RVid; |
2243 | |
2319 | |
2244 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2320 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
2245 | if (rend & RS_Bold && fore == Color_fg && !(options & Opt_realBold)) |
2321 | if (rend & RS_Bold |
|
|
2322 | && fore == Color_fg) |
2246 | { |
2323 | { |
2247 | if (ISSET_PIXCOLOR (Color_BD)) |
2324 | if (ISSET_PIXCOLOR (Color_BD)) |
2248 | fore = Color_BD; |
2325 | fore = Color_BD; |
|
|
2326 | # if !ENABLE_STYLES |
2249 | else |
2327 | else |
2250 | rvid = !rvid; |
2328 | invert = !invert; |
|
|
2329 | # endif |
|
|
2330 | } |
|
|
2331 | |
|
|
2332 | if (rend & RS_Italic |
|
|
2333 | && fore == Color_fg) |
|
|
2334 | { |
|
|
2335 | if (ISSET_PIXCOLOR (Color_IT)) |
|
|
2336 | fore = Color_IT; |
|
|
2337 | # if !ENABLE_STYLES |
|
|
2338 | else |
|
|
2339 | invert = !invert; |
|
|
2340 | # endif |
|
|
2341 | } |
|
|
2342 | |
|
|
2343 | if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) |
|
|
2344 | fore = Color_UL; |
|
|
2345 | #endif |
|
|
2346 | |
|
|
2347 | if (invert) |
|
|
2348 | { |
|
|
2349 | SWAP_IT (fore, back, int); |
|
|
2350 | |
|
|
2351 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
|
|
2352 | if (ISSET_PIXCOLOR (Color_RV)) |
|
|
2353 | back = Color_RV; |
|
|
2354 | #endif |
|
|
2355 | } |
|
|
2356 | |
|
|
2357 | #ifdef TEXT_BLINK |
|
|
2358 | if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) |
|
|
2359 | { |
|
|
2360 | if (!text_blink_ev.active) |
|
|
2361 | { |
|
|
2362 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
|
|
2363 | hidden_text = 0; |
|
|
2364 | } |
|
|
2365 | else if (hidden_text) |
|
|
2366 | fore = back; |
|
|
2367 | } |
|
|
2368 | #endif |
2251 | } |
2369 | } |
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 | |
2370 | |
2285 | /* |
2371 | /* |
2286 | * Actually do the drawing of the string here |
2372 | * Actually do the drawing of the string here |
2287 | */ |
2373 | */ |
2288 | rxvt_font *font = (*TermWin.fontset)[fid]; |
2374 | rxvt_font *font = (*TermWin.fontset[GET_STYLE (rend)])[GET_FONT (rend)]; |
2289 | |
2375 | |
2290 | if (back == fore) |
2376 | if (back == fore) |
2291 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2377 | font->clear_rect (*TermWin.drawable, xpixel, ypixel, |
2292 | TermWin.fwidth * count, TermWin.fheight, |
2378 | TermWin.fwidth * count, TermWin.fheight, |
2293 | back); |
2379 | back); |
… | |
… | |
2315 | xpixel, ypixel + font->ascent + 1, |
2401 | xpixel, ypixel + font->ascent + 1, |
2316 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2402 | xpixel + Width2Pixel (count) - 1, ypixel + font->ascent + 1); |
2317 | } /* for (col....) */ |
2403 | } /* for (col....) */ |
2318 | } /* for (row....) */ |
2404 | } /* for (row....) */ |
2319 | |
2405 | |
|
|
2406 | #if ENABLE_OVERLAY |
|
|
2407 | scr_swap_overlay (); |
|
|
2408 | #endif |
|
|
2409 | |
2320 | /* |
2410 | /* |
2321 | * G: cleanup cursor and display outline cursor if necessary |
2411 | * G: cleanup cursor and display outline cursor if necessary |
2322 | */ |
2412 | */ |
2323 | if (showcursor) |
2413 | if (showcursor) |
2324 | { |
2414 | { |
… | |
… | |
2349 | } |
2439 | } |
2350 | |
2440 | |
2351 | /* |
2441 | /* |
2352 | * H: cleanup selection |
2442 | * H: cleanup selection |
2353 | */ |
2443 | */ |
2354 | #if ENABLE_OVERLAY |
|
|
2355 | scr_swap_overlay (); |
|
|
2356 | #endif |
|
|
2357 | scr_reverse_selection (); |
2444 | scr_reverse_selection (); |
2358 | |
2445 | |
2359 | if (refresh_type & SMOOTH_REFRESH) |
2446 | if (refresh_type & SMOOTH_REFRESH) |
2360 | XFlush (display->display); |
2447 | XFlush (display->display); |
2361 | |
2448 | |
2362 | num_scr = 0; |
2449 | num_scr = 0; |
2363 | num_scr_allow = 1; |
2450 | num_scr_allow = 1; |
2364 | want_refresh = 0; /* screen is current */ |
|
|
2365 | } |
2451 | } |
2366 | |
2452 | |
2367 | void |
2453 | void |
2368 | rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) |
2454 | rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) |
2369 | { |
2455 | { |
2370 | if (!rp || !tp) |
2456 | if (!rp || !tp) |
2371 | return; |
2457 | return; |
2372 | |
2458 | |
2373 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2459 | for (int i = TermWin.ncol; i; i--, rp++, tp++) |
2374 | *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); |
2460 | *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); |
2375 | } |
2461 | } |
2376 | |
2462 | |
2377 | void |
2463 | void |
2378 | rxvt_term::scr_remap_chars () |
2464 | rxvt_term::scr_remap_chars () |
2379 | { |
2465 | { |
… | |
… | |
2385 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2471 | scr_remap_chars (drawn_text[i], drawn_rend[i]); |
2386 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2472 | scr_remap_chars (swap.text[i], swap.rend[i]); |
2387 | } |
2473 | } |
2388 | } |
2474 | } |
2389 | |
2475 | |
|
|
2476 | void |
|
|
2477 | rxvt_term::scr_recolour () |
|
|
2478 | { |
|
|
2479 | if (1 |
|
|
2480 | #if TRANSPARENT |
|
|
2481 | && !am_transparent |
|
|
2482 | #endif |
|
|
2483 | #if XPM_BACKGROUND |
|
|
2484 | && !bgPixmap.pixmap |
|
|
2485 | #endif |
|
|
2486 | ) |
|
|
2487 | { |
|
|
2488 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors[Color_border]); |
|
|
2489 | XClearWindow (display->display, TermWin.parent[0]); |
|
|
2490 | XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); |
|
|
2491 | #if HAVE_SCROLLBARS |
|
|
2492 | if (scrollBar.win) |
|
|
2493 | { |
|
|
2494 | XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); |
|
|
2495 | scrollBar.setIdle (); |
|
|
2496 | scrollbar_show (0); |
|
|
2497 | } |
|
|
2498 | #endif |
|
|
2499 | } |
|
|
2500 | |
|
|
2501 | scr_clear (); |
|
|
2502 | scr_touch (true); |
|
|
2503 | want_refresh = 1; |
|
|
2504 | } |
|
|
2505 | |
2390 | /* ------------------------------------------------------------------------- */ |
2506 | /* ------------------------------------------------------------------------- */ |
2391 | void |
2507 | void |
2392 | rxvt_term::scr_clear (bool really) |
2508 | rxvt_term::scr_clear (bool really) |
2393 | { |
2509 | { |
2394 | if (!TermWin.mapped) |
2510 | if (!TermWin.mapped) |
2395 | return; |
2511 | return; |
2396 | |
2512 | |
2397 | num_scr_allow = 0; |
2513 | num_scr_allow = 0; |
2398 | want_refresh = 1; |
2514 | want_refresh = 1; |
2399 | |
2515 | |
2400 | #ifdef TRANSPARENT |
2516 | #if TRANSPARENT |
2401 | if ((options & Opt_transparent) && (am_pixmap_trans == 0)) |
2517 | if ((options & Opt_transparent) && (am_pixmap_trans == 0)) |
2402 | { |
2518 | { |
2403 | int i; |
2519 | int i; |
2404 | |
2520 | |
2405 | if (! (options & Opt_transparent_all)) |
2521 | if (!(options & Opt_transparent_all)) |
2406 | i = 0; |
2522 | i = 0; |
2407 | else |
2523 | else |
2408 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2524 | i = (int) (sizeof (TermWin.parent) / sizeof (Window)); |
2409 | |
2525 | |
2410 | while (i--) |
2526 | while (i--) |
… | |
… | |
2426 | int end_row = TermWin.saveLines - TermWin.view_start; |
2542 | int end_row = TermWin.saveLines - TermWin.view_start; |
2427 | int i = selection.beg.row + TermWin.saveLines; |
2543 | int i = selection.beg.row + TermWin.saveLines; |
2428 | int col, row = selection.end.row + TermWin.saveLines; |
2544 | int col, row = selection.end.row + TermWin.saveLines; |
2429 | rend_t *srp; |
2545 | rend_t *srp; |
2430 | |
2546 | |
2431 | if (i >= end_row) |
2547 | #if ENABLE_FRILLS |
2432 | col = selection.beg.col; |
2548 | if (selection.rect) |
|
|
2549 | { |
|
|
2550 | end_row += TermWin.nrow; |
|
|
2551 | |
|
|
2552 | for (; i <= row && i <= end_row; i++) |
|
|
2553 | for (srp = screen.rend[i], col = selection.beg.col; col < selection.end.col; col++) |
|
|
2554 | srp[col] ^= RS_RVid; |
|
|
2555 | } |
2433 | else |
2556 | else |
|
|
2557 | #endif |
|
|
2558 | { |
|
|
2559 | if (i >= end_row) |
|
|
2560 | col = selection.beg.col; |
|
|
2561 | else |
2434 | { |
2562 | { |
2435 | col = 0; |
2563 | col = 0; |
2436 | i = end_row; |
2564 | i = end_row; |
2437 | } |
2565 | } |
2438 | |
2566 | |
2439 | end_row += TermWin.nrow; |
2567 | end_row += TermWin.nrow; |
|
|
2568 | |
2440 | for (; i < row && i < end_row; i++, col = 0) |
2569 | for (; i < row && i < end_row; i++, col = 0) |
2441 | for (srp = screen.rend[i]; col < TermWin.ncol; col++) |
2570 | for (srp = screen.rend[i]; col < TermWin.ncol; col++) |
2442 | srp[col] ^= RS_RVid; |
2571 | srp[col] ^= RS_RVid; |
2443 | |
2572 | |
2444 | if (i == row && i < end_row) |
2573 | if (i == row && i < end_row) |
2445 | for (srp = screen.rend[i]; col < selection.end.col; col++) |
2574 | for (srp = screen.rend[i]; col < selection.end.col; col++) |
2446 | srp[col] ^= RS_RVid; |
2575 | srp[col] ^= RS_RVid; |
|
|
2576 | } |
2447 | } |
2577 | } |
2448 | } |
2578 | } |
2449 | |
2579 | |
2450 | /* ------------------------------------------------------------------------- */ |
2580 | /* ------------------------------------------------------------------------- */ |
2451 | /* |
2581 | /* |
… | |
… | |
2801 | |
2931 | |
2802 | i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1); |
2932 | i = (selection.end.row - selection.beg.row + 1) * (TermWin.ncol + 1); |
2803 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2933 | new_selection_text = (wchar_t *)rxvt_malloc ((i + 4) * sizeof (wchar_t)); |
2804 | |
2934 | |
2805 | col = selection.beg.col; |
2935 | col = selection.beg.col; |
2806 | MAX_IT (col, 0); |
|
|
2807 | row = selection.beg.row + TermWin.saveLines; |
2936 | row = selection.beg.row + TermWin.saveLines; |
2808 | end_row = selection.end.row + TermWin.saveLines; |
2937 | end_row = selection.end.row + TermWin.saveLines; |
2809 | int ofs = 0; |
2938 | int ofs = 0; |
2810 | int extra = 0; |
2939 | int extra = 0; |
2811 | |
2940 | |
2812 | for (; row <= end_row; row++, col = 0) |
2941 | for (; row <= end_row; row++, col = 0) |
2813 | { |
2942 | { |
2814 | t = &screen.text[row][col]; |
|
|
2815 | |
|
|
2816 | end_col = screen.tlen[row]; |
2943 | end_col = screen.tlen[row]; |
|
|
2944 | |
|
|
2945 | #if ENABLE_FRILLS |
|
|
2946 | if (selection.rect) |
|
|
2947 | { |
|
|
2948 | col = selection.beg.col; |
|
|
2949 | end_col = TermWin.ncol + 1; |
|
|
2950 | } |
|
|
2951 | #endif |
|
|
2952 | |
|
|
2953 | MAX_IT (col, 0); |
2817 | |
2954 | |
2818 | if (end_col == -1) |
2955 | if (end_col == -1) |
2819 | end_col = TermWin.ncol; |
2956 | end_col = TermWin.ncol; |
2820 | |
2957 | |
2821 | if (row == end_row) |
2958 | if (row == end_row || selection.rect) |
2822 | MIN_IT (end_col, selection.end.col); |
2959 | MIN_IT (end_col, selection.end.col); |
2823 | |
2960 | |
|
|
2961 | t = &screen.text[row][col]; |
2824 | for (; col < end_col; col++) |
2962 | for (; col < end_col; col++) |
2825 | { |
2963 | { |
2826 | if (*t == NOCHAR) |
2964 | if (*t == NOCHAR) |
2827 | t++; |
2965 | t++; |
2828 | #if ENABLE_COMBINING |
2966 | #if ENABLE_COMBINING |
… | |
… | |
3088 | enum { |
3226 | enum { |
3089 | LEFT, RIGHT |
3227 | LEFT, RIGHT |
3090 | } closeto = RIGHT; |
3228 | } closeto = RIGHT; |
3091 | |
3229 | |
3092 | want_refresh = 1; |
3230 | want_refresh = 1; |
|
|
3231 | |
3093 | switch (selection.op) |
3232 | switch (selection.op) |
3094 | { |
3233 | { |
3095 | case SELECTION_INIT: |
3234 | case SELECTION_INIT: |
3096 | CLEAR_SELECTION (); |
3235 | CLEAR_SELECTION (); |
3097 | selection.op = SELECTION_BEGIN; |
3236 | selection.op = SELECTION_BEGIN; |
… | |
… | |
3110 | selection_start_colrow (col, row); |
3249 | selection_start_colrow (col, row); |
3111 | /* FALLTHROUGH */ |
3250 | /* FALLTHROUGH */ |
3112 | default: |
3251 | default: |
3113 | return; |
3252 | return; |
3114 | } |
3253 | } |
|
|
3254 | |
3115 | if (selection.beg.col == selection.end.col |
3255 | if (selection.beg.col == selection.end.col |
3116 | && selection.beg.col != selection.mark.col |
3256 | && selection.beg.col != selection.mark.col |
3117 | && selection.beg.row == selection.end.row |
3257 | && selection.beg.row == selection.end.row |
3118 | && selection.beg.row != selection.mark.row) |
3258 | && selection.beg.row != selection.mark.row) |
3119 | { |
3259 | { |
… | |
… | |
3169 | } |
3309 | } |
3170 | else |
3310 | else |
3171 | { /* button1 drag or button3 drag */ |
3311 | { /* button1 drag or button3 drag */ |
3172 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3312 | if (ROWCOL_IS_AFTER (selection.mark, pos)) |
3173 | { |
3313 | { |
3174 | if ((selection.mark.row == selection.end.row) |
3314 | if (selection.mark.row == selection.end.row |
3175 | && (selection.mark.col == selection.end.col) |
3315 | && selection.mark.col == selection.end.col |
|
|
3316 | && clickchange |
3176 | && clickchange && selection.clicks == 2) |
3317 | && selection.clicks == 2) |
3177 | selection.mark.col--; |
3318 | selection.mark.col--; |
3178 | |
3319 | |
3179 | selection.beg.row = pos.row; |
3320 | selection.beg.row = pos.row; |
3180 | selection.beg.col = pos.col; |
3321 | selection.beg.col = pos.col; |
3181 | selection.end.row = selection.mark.row; |
3322 | selection.end.row = selection.mark.row; |
… | |
… | |
3192 | |
3333 | |
3193 | if (selection.clicks == 1) |
3334 | if (selection.clicks == 1) |
3194 | { |
3335 | { |
3195 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
3336 | end_col = screen.tlen[selection.beg.row + TermWin.saveLines]; |
3196 | |
3337 | |
3197 | if (end_col != -1 && selection.beg.col > end_col) |
3338 | if (selection.beg.col > end_col |
|
|
3339 | && end_col != -1 |
|
|
3340 | #if ENABLE_FRILLS |
|
|
3341 | && !selection.rect |
|
|
3342 | #endif |
3198 | { |
3343 | ) |
3199 | #if 1 |
|
|
3200 | selection.beg.col = ncol; |
3344 | selection.beg.col = ncol; |
3201 | #else |
|
|
3202 | if (selection.beg.row != selection.end.row) |
|
|
3203 | selection.beg.col = ncol; |
|
|
3204 | else |
|
|
3205 | selection.beg.col = selection.mark.col; |
|
|
3206 | #endif |
|
|
3207 | } |
|
|
3208 | |
3345 | |
3209 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
3346 | end_col = screen.tlen[selection.end.row + TermWin.saveLines]; |
3210 | |
3347 | |
3211 | if (end_col != -1 && selection.end.col > end_col) |
3348 | if ( |
|
|
3349 | selection.end.col > end_col |
|
|
3350 | && end_col != -1 |
|
|
3351 | #if ENABLE_FRILLS |
|
|
3352 | && !selection.rect |
|
|
3353 | #endif |
|
|
3354 | ) |
3212 | selection.end.col = ncol; |
3355 | selection.end.col = ncol; |
3213 | } |
3356 | } |
3214 | else if (selection.clicks == 2) |
3357 | else if (selection.clicks == 2) |
3215 | { |
3358 | { |
3216 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3359 | if (ROWCOL_IS_AFTER (selection.end, selection.beg)) |
3217 | selection.end.col--; |
3360 | selection.end.col--; |
3218 | |
3361 | |
3219 | selection_delimit_word (UP, & (selection.beg), & (selection.beg)); |
|
|
3220 | selection_delimit_word (DN, & (selection.end), & (selection.end)); |
3362 | selection_delimit_word (UP, &selection.beg, &selection.beg); |
|
|
3363 | selection_delimit_word (DN, &selection.end, &selection.end); |
3221 | } |
3364 | } |
3222 | else if (selection.clicks == 3) |
3365 | else if (selection.clicks == 3) |
3223 | { |
3366 | { |
3224 | #if ENABLE_FRILLS |
3367 | #if ENABLE_FRILLS |
3225 | if ((options & Opt_tripleclickwords)) |
3368 | if ((options & Opt_tripleclickwords)) |
… | |
… | |
3245 | else |
3388 | else |
3246 | #endif |
3389 | #endif |
3247 | { |
3390 | { |
3248 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3391 | if (ROWCOL_IS_AFTER (selection.mark, selection.beg)) |
3249 | selection.mark.col++; |
3392 | selection.mark.col++; |
|
|
3393 | |
3250 | selection.beg.col = 0; |
3394 | selection.beg.col = 0; |
3251 | selection.end.col = ncol; |
3395 | selection.end.col = ncol; |
3252 | } |
3396 | } |
3253 | } |
3397 | } |
3254 | |
3398 | |
… | |
… | |
3263 | { |
3407 | { |
3264 | selection.mark.row = selection.beg.row; |
3408 | selection.mark.row = selection.beg.row; |
3265 | selection.mark.col = selection.beg.col; |
3409 | selection.mark.col = selection.beg.col; |
3266 | } |
3410 | } |
3267 | } |
3411 | } |
3268 | } |
|
|
3269 | |
3412 | |
3270 | #if ENABLE_FRILLS |
3413 | #if ENABLE_FRILLS |
|
|
3414 | if (selection.rect && selection.beg.col > selection.end.col) |
|
|
3415 | SWAP_IT (selection.beg.col, selection.end.col, int); |
|
|
3416 | #endif |
|
|
3417 | } |
|
|
3418 | |
|
|
3419 | #if ENABLE_FRILLS |
3271 | void |
3420 | void |
3272 | rxvt_term::selection_remove_trailing_spaces () |
3421 | rxvt_term::selection_remove_trailing_spaces () |
3273 | { |
3422 | { |
3274 | int32_t end_col, end_row; |
3423 | int32_t end_col, end_row; |
3275 | text_t *stp; |
3424 | text_t *stp; |
3276 | |
3425 | |
3277 | end_col = selection.end.col; |
3426 | end_col = selection.end.col; |
3278 | end_row = selection.end.row; |
3427 | end_row = selection.end.row; |
|
|
3428 | |
3279 | for ( ; end_row >= selection.beg.row; ) |
3429 | for ( ; end_row >= selection.beg.row; ) |
3280 | { |
3430 | { |
3281 | stp = screen.text[end_row + TermWin.saveLines]; |
3431 | stp = screen.text[end_row + TermWin.saveLines]; |
|
|
3432 | |
3282 | while (--end_col >= 0) |
3433 | while (--end_col >= 0) |
3283 | { |
3434 | { |
3284 | if (stp[end_col] != ' ' && stp[end_col] != '\t') |
3435 | if (stp[end_col] != ' ' |
|
|
3436 | && stp[end_col] != '\t' |
|
|
3437 | && stp[end_col] != NOCHAR) |
3285 | break; |
3438 | break; |
3286 | } |
3439 | } |
|
|
3440 | |
3287 | if (end_col >= 0 |
3441 | if (end_col >= 0 |
3288 | || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) |
3442 | || screen.tlen[end_row - 1 + TermWin.saveLines] != -1) |
3289 | { |
3443 | { |
3290 | selection.end.col = end_col + 1; |
3444 | selection.end.col = end_col + 1; |
3291 | selection.end.row = end_row; |
3445 | selection.end.row = end_row; |
3292 | break; |
3446 | break; |
3293 | } |
3447 | } |
|
|
3448 | |
3294 | end_row--; |
3449 | end_row--; |
3295 | end_col = TermWin.ncol; |
3450 | end_col = TermWin.ncol; |
3296 | } |
3451 | } |
|
|
3452 | |
3297 | if (selection.mark.row > selection.end.row) |
3453 | if (selection.mark.row > selection.end.row) |
3298 | { |
3454 | { |
3299 | selection.mark.row = selection.end.row; |
3455 | selection.mark.row = selection.end.row; |
3300 | selection.mark.col = selection.end.col; |
3456 | selection.mark.col = selection.end.col; |
3301 | } |
3457 | } |
… | |
… | |
3507 | { |
3663 | { |
3508 | text_t *tp = ov_text[y] = new text_t[w]; |
3664 | text_t *tp = ov_text[y] = new text_t[w]; |
3509 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3665 | rend_t *rp = ov_rend[y] = new rend_t[w]; |
3510 | |
3666 | |
3511 | text_t t0, t1, t2; |
3667 | text_t t0, t1, t2; |
3512 | rend_t r = SET_BGCOLOR (SET_FGCOLOR (RS_None, Color_bg), Color_fg); |
3668 | rend_t r = OVERLAY_RSTYLE; |
3513 | |
3669 | |
3514 | if (y == 0) |
3670 | if (y == 0) |
3515 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
3671 | t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; |
3516 | else if (y < h - 1) |
3672 | else if (y < h - 1) |
3517 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
3673 | t0 = 0x2551, t1 = 0x0020, t2 = 0x2551; |
… | |
… | |
3551 | } |
3707 | } |
3552 | |
3708 | |
3553 | void |
3709 | void |
3554 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3710 | rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) |
3555 | { |
3711 | { |
3556 | if (!ov_text || x >= ov_w - 2 || y >= ov_h) |
3712 | if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) |
3557 | return; |
3713 | return; |
3558 | |
3714 | |
3559 | x++, y++; |
3715 | x++, y++; |
3560 | |
3716 | |
3561 | ov_text[y][x] = text; |
3717 | ov_text[y][x] = text; |
… | |
… | |
3587 | rend_t *r2 = screen.rend[y + row_offset] + ov_x; |
3743 | rend_t *r2 = screen.rend[y + row_offset] + ov_x; |
3588 | |
3744 | |
3589 | for (int x = ov_w; x--; ) |
3745 | for (int x = ov_w; x--; ) |
3590 | { |
3746 | { |
3591 | text_t t = *t1; *t1++ = *t2; *t2++ = t; |
3747 | 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)); |
3748 | rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); |
3593 | } |
3749 | } |
3594 | } |
3750 | } |
3595 | } |
3751 | } |
3596 | |
3752 | |
3597 | #endif |
3753 | #endif |