… | |
… | |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
147 | || !IN_RANGE_EXC (y, 0, nrow)) |
148 | return; |
148 | return; |
149 | |
149 | |
150 | for (;;) |
150 | for (;;) |
151 | { |
151 | { |
152 | const line_t &l = ROW(y - view_start); |
152 | const line_t &l = ROW(y + view_start); |
153 | |
153 | |
154 | text_t t = l.t[x]; |
154 | text_t t = l.t[x]; |
155 | |
155 | |
156 | if (t != NOCHAR || !x) |
156 | if (t != NOCHAR || !x) |
157 | { |
157 | { |
… | |
… | |
443 | scr_move_to (0, 1); |
443 | scr_move_to (0, 1); |
444 | return; |
444 | return; |
445 | } |
445 | } |
446 | else if (keysym == XK_End) |
446 | else if (keysym == XK_End) |
447 | { |
447 | { |
448 | scr_move_to (1, 0); |
448 | scr_move_to (1, 1); |
449 | return; |
449 | return; |
450 | } |
450 | } |
451 | } |
451 | } |
452 | #endif |
452 | #endif |
453 | } |
453 | } |
… | |
… | |
972 | |
972 | |
973 | if (want_refresh) |
973 | if (want_refresh) |
974 | { |
974 | { |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
975 | if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) |
976 | { |
976 | { |
977 | int row = -view_start; |
977 | int row = view_start; |
978 | int end_row = row + nrow; |
978 | int end_row = row + nrow; |
979 | |
979 | |
980 | while (row > -nsaved && ROW (row - 1).is_longer ()) |
980 | while (row > top_row && ROW (row - 1).is_longer ()) |
981 | --row; |
981 | --row; |
982 | |
982 | |
983 | do |
983 | do |
984 | { |
984 | { |
985 | int start_row = row; |
985 | int start_row = row; |
… | |
… | |
987 | |
987 | |
988 | do |
988 | do |
989 | { |
989 | { |
990 | l = &ROW (row++); |
990 | l = &ROW (row++); |
991 | |
991 | |
992 | if (l->f & LINE_FILTERED) |
992 | if (!(l->f & LINE_FILTERED)) |
993 | row++; |
|
|
994 | else |
|
|
995 | { |
993 | { |
996 | // line not filtered, mark it as filtered |
994 | // line not filtered, mark it as filtered |
997 | l->f |= LINE_FILTERED; |
995 | l->f |= LINE_FILTERED; |
998 | while (l->is_longer ()) |
996 | while (l->is_longer ()) |
999 | { |
997 | { |
1000 | l = &ROW (++row); |
998 | l = &ROW (row++); |
1001 | l->f |= LINE_FILTERED; |
999 | l->f |= LINE_FILTERED; |
1002 | } |
1000 | } |
1003 | |
1001 | |
1004 | // and filter it |
1002 | // and filter it |
1005 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
1003 | HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); |
… | |
… | |
1007 | break; |
1005 | break; |
1008 | } |
1006 | } |
1009 | } |
1007 | } |
1010 | while (l->is_longer () && row < end_row); |
1008 | while (l->is_longer () && row < end_row); |
1011 | } |
1009 | } |
1012 | while (++row < end_row); |
1010 | while (row < end_row); |
1013 | } |
1011 | } |
1014 | |
1012 | |
1015 | scr_refresh (refresh_type); |
1013 | scr_refresh (refresh_type); |
1016 | scrollbar_show (1); |
1014 | scrollbar_show (1); |
1017 | #ifdef USE_XIM |
1015 | #ifdef USE_XIM |
… | |
… | |
1023 | } |
1021 | } |
1024 | |
1022 | |
1025 | void |
1023 | void |
1026 | rxvt_term::check_cb (check_watcher &w) |
1024 | rxvt_term::check_cb (check_watcher &w) |
1027 | { |
1025 | { |
1028 | SET_R (this); |
1026 | make_current (); |
1029 | SET_LOCALE (locale); |
|
|
1030 | |
1027 | |
1031 | display->flush (); |
1028 | display->flush (); |
1032 | |
1029 | |
1033 | if (want_refresh && !flush_ev.active) |
1030 | if (want_refresh && !flush_ev.active) |
1034 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1031 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
1035 | } |
1032 | } |
1036 | |
1033 | |
1037 | void |
1034 | void |
1038 | rxvt_term::flush_cb (time_watcher &w) |
1035 | rxvt_term::flush_cb (time_watcher &w) |
1039 | { |
1036 | { |
1040 | SET_R (this); |
1037 | make_current (); |
1041 | SET_LOCALE (locale); |
|
|
1042 | |
1038 | |
1043 | refresh_limit = 1; |
1039 | refresh_limit = 1; |
1044 | refresh_count = 0; |
1040 | refresh_count = 0; |
1045 | flush (); |
1041 | flush (); |
1046 | } |
1042 | } |
… | |
… | |
1103 | { |
1099 | { |
1104 | if (mouse_slip_wheel_speed == 0 |
1100 | if (mouse_slip_wheel_speed == 0 |
1105 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1101 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1106 | : scr_page (UP, mouse_slip_wheel_speed)) |
1102 | : scr_page (UP, mouse_slip_wheel_speed)) |
1107 | { |
1103 | { |
1108 | if (view_start == nsaved || |
1104 | if (view_start == top_row || view_start == 0) |
1109 | view_start == 0) |
|
|
1110 | mouse_slip_wheel_speed = 0; |
1105 | mouse_slip_wheel_speed = 0; |
1111 | |
1106 | |
1112 | refresh_type |= SMOOTH_REFRESH; |
1107 | refresh_type |= SMOOTH_REFRESH; |
1113 | want_refresh = 1; |
1108 | want_refresh = 1; |
1114 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1109 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
… | |
… | |
1175 | } |
1170 | } |
1176 | |
1171 | |
1177 | void |
1172 | void |
1178 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1173 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1179 | { |
1174 | { |
1180 | SET_R (this); |
1175 | make_current (); |
1181 | SET_LOCALE (locale); |
|
|
1182 | |
1176 | |
1183 | if (revents & EVENT_READ) |
1177 | if (revents & EVENT_READ) |
1184 | // loop, but don't allow a single term to monopolize us |
1178 | // loop, but don't allow a single term to monopolize us |
1185 | while (pty_fill ()) |
1179 | while (pty_fill ()) |
1186 | if (cmd_parse ()) |
1180 | if (cmd_parse ()) |
… | |
… | |
1218 | } |
1212 | } |
1219 | |
1213 | |
1220 | void |
1214 | void |
1221 | rxvt_term::pointer_cb (time_watcher &w) |
1215 | rxvt_term::pointer_cb (time_watcher &w) |
1222 | { |
1216 | { |
1223 | SET_R (this); |
1217 | make_current (); |
1224 | SET_LOCALE (locale); |
|
|
1225 | |
1218 | |
1226 | pointer_blank (); |
1219 | pointer_blank (); |
1227 | } |
1220 | } |
1228 | #endif |
1221 | #endif |
1229 | |
1222 | |
… | |
… | |
1308 | |
1301 | |
1309 | /*{{{ process an X event */ |
1302 | /*{{{ process an X event */ |
1310 | void |
1303 | void |
1311 | rxvt_term::x_cb (XEvent &ev) |
1304 | rxvt_term::x_cb (XEvent &ev) |
1312 | { |
1305 | { |
|
|
1306 | make_current (); |
|
|
1307 | |
1313 | dDisp; |
1308 | dDisp; |
1314 | |
1309 | |
1315 | SET_R (this); |
1310 | if (ev.xany.window == vt |
1316 | SET_LOCALE (locale); |
1311 | && SHOULD_INVOKE (HOOK_X_EVENT) |
|
|
1312 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1313 | return; |
1317 | |
1314 | |
|
|
1315 | // for XQueryPointer |
1318 | Window unused_root, unused_child; |
1316 | Window unused_root, unused_child; |
1319 | int unused_root_x, unused_root_y; |
1317 | int unused_root_x, unused_root_y; |
1320 | unsigned int unused_mask; |
1318 | unsigned int unused_mask; |
1321 | |
1319 | |
1322 | switch (ev.type) |
1320 | switch (ev.type) |
… | |
… | |
1573 | |
1571 | |
1574 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1572 | while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) |
1575 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1573 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1576 | ev.xexpose.width, ev.xexpose.height, False); |
1574 | ev.xexpose.width, ev.xexpose.height, False); |
1577 | |
1575 | |
1578 | scr_refresh (refresh_type); |
1576 | want_refresh = 1; |
1579 | } |
1577 | } |
1580 | else |
1578 | else |
1581 | { |
1579 | { |
1582 | XEvent unused_event; |
1580 | XEvent unused_event; |
1583 | |
1581 | |
… | |
… | |
1618 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1616 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1619 | break; |
1617 | break; |
1620 | |
1618 | |
1621 | if (ev.xany.window == vt) |
1619 | if (ev.xany.window == vt) |
1622 | { |
1620 | { |
|
|
1621 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1623 | if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1622 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1624 | ; // nop |
1623 | ; // nop |
1625 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1624 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1626 | { |
1625 | { |
1627 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1626 | while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) |
1628 | ; |
1627 | ; |
… | |
… | |
1710 | &unused_root_x, &unused_root_y, |
1709 | &unused_root_x, &unused_root_y, |
1711 | &ev.xbutton.x, &ev.xbutton.y, |
1710 | &ev.xbutton.x, &ev.xbutton.y, |
1712 | &unused_mask); |
1711 | &unused_mask); |
1713 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1712 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1714 | scrollbar_size ()); |
1713 | scrollbar_size ()); |
1715 | scr_refresh (refresh_type); |
1714 | want_refresh = 1; |
1716 | refresh_limit = 0; |
1715 | refresh_limit = 0; |
1717 | scrollbar_show (1); |
1716 | scrollbar_show (1); |
1718 | } |
1717 | } |
1719 | break; |
1718 | break; |
1720 | } |
1719 | } |
… | |
… | |
1820 | |
1819 | |
1821 | #if TRANSPARENT |
1820 | #if TRANSPARENT |
1822 | void |
1821 | void |
1823 | rxvt_term::rootwin_cb (XEvent &ev) |
1822 | rxvt_term::rootwin_cb (XEvent &ev) |
1824 | { |
1823 | { |
1825 | SET_R (this); |
1824 | make_current (); |
1826 | SET_LOCALE (locale); |
|
|
1827 | |
1825 | |
1828 | switch (ev.type) |
1826 | switch (ev.type) |
1829 | { |
1827 | { |
1830 | case PropertyNotify: |
1828 | case PropertyNotify: |
1831 | /* |
1829 | /* |
… | |
… | |
1922 | #else |
1920 | #else |
1923 | selection.rect = false; |
1921 | selection.rect = false; |
1924 | #endif |
1922 | #endif |
1925 | |
1923 | |
1926 | /* allow shift+left click to extend selection */ |
1924 | /* allow shift+left click to extend selection */ |
1927 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1925 | if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) |
1928 | { |
1926 | { |
1929 | if (MEvent.button == Button1 && clickintime) |
1927 | if (MEvent.button == Button1 && clickintime) |
1930 | selection_rotate (ev.x, ev.y); |
1928 | selection_rotate (ev.x, ev.y); |
1931 | else |
1929 | else |
1932 | selection_extend (ev.x, ev.y, 1); |
1930 | selection_extend (ev.x, ev.y, 1); |
… | |
… | |
2216 | slip_wheel_ev.start (); |
2214 | slip_wheel_ev.start (); |
2217 | } |
2215 | } |
2218 | else |
2216 | else |
2219 | { |
2217 | { |
2220 | # endif |
2218 | # endif |
2221 | # ifdef JUMP_MOUSE_WHEEL |
|
|
2222 | scr_page (v, i); |
2219 | scr_page (v, i); |
2223 | scr_refresh (SMOOTH_REFRESH); |
|
|
2224 | scrollbar_show (1); |
2220 | scrollbar_show (1); |
2225 | # else |
|
|
2226 | while (i--) |
|
|
2227 | { |
|
|
2228 | scr_page (v, 1); |
|
|
2229 | scr_refresh (SMOOTH_REFRESH); |
|
|
2230 | scrollbar_show (1); |
|
|
2231 | } |
|
|
2232 | # endif |
|
|
2233 | # ifdef MOUSE_SLIP_WHEELING |
2221 | # ifdef MOUSE_SLIP_WHEELING |
2234 | } |
2222 | } |
2235 | #endif |
2223 | # endif |
2236 | } |
2224 | } |
2237 | break; |
2225 | break; |
2238 | #endif |
2226 | #endif |
2239 | } |
2227 | } |
2240 | } |
2228 | } |
… | |
… | |
2834 | refresh_limit++; |
2822 | refresh_limit++; |
2835 | else |
2823 | else |
2836 | { |
2824 | { |
2837 | flag = true; |
2825 | flag = true; |
2838 | scr_refresh (refresh_type); |
2826 | scr_refresh (refresh_type); |
2839 | flush_ev.stop (); |
2827 | want_refresh = 1; |
2840 | } |
2828 | } |
2841 | } |
2829 | } |
2842 | |
2830 | |
2843 | } |
2831 | } |
2844 | else |
2832 | else |
… | |
… | |
3870 | { |
3858 | { |
3871 | if ((name = strchr (buf, ';')) == NULL) |
3859 | if ((name = strchr (buf, ';')) == NULL) |
3872 | break; |
3860 | break; |
3873 | |
3861 | |
3874 | *name++ = '\0'; |
3862 | *name++ = '\0'; |
3875 | color = atoi (buf); |
3863 | color = atoi (buf) + minCOLOR; |
3876 | |
3864 | |
3877 | if (color < 0 || color >= TOTAL_COLORS) |
3865 | if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) |
3878 | break; |
3866 | break; |
3879 | |
3867 | |
3880 | if ((buf = strchr (name, ';')) != NULL) |
3868 | if ((buf = strchr (name, ';')) != NULL) |
3881 | *buf++ = '\0'; |
3869 | *buf++ = '\0'; |
3882 | |
3870 | |
3883 | if (name[0] == '?' && !name[1]) |
3871 | if (name[0] == '?' && !name[1]) |
3884 | { |
3872 | { |
3885 | unsigned short r, g, b; |
3873 | unsigned short r, g, b; |
3886 | pix_colors_focused[color + minCOLOR].get (display, r, g, b); |
3874 | pix_colors_focused[color].get (display, r, g, b); |
3887 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3875 | tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); |
3888 | } |
3876 | } |
3889 | else |
3877 | else |
3890 | set_window_color (color + minCOLOR, name); |
3878 | set_window_color (color, name); |
3891 | } |
3879 | } |
3892 | break; |
3880 | break; |
3893 | case XTerm_Color00: |
3881 | case XTerm_Color00: |
3894 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3882 | process_color_seq (XTerm_Color00, Color_fg, str, resp); |
3895 | break; |
3883 | break; |
3896 | case XTerm_Color01: |
3884 | case XTerm_Color01: |
3897 | process_color_seq (XTerm_Color00, Color_bg, str, resp); |
3885 | process_color_seq (XTerm_Color01, Color_bg, str, resp); |
3898 | break; |
3886 | break; |
3899 | #ifndef NO_CURSORCOLOR |
3887 | #ifndef NO_CURSORCOLOR |
3900 | case XTerm_Color_cursor: |
3888 | case XTerm_Color_cursor: |
3901 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3889 | process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); |
3902 | break; |
3890 | break; |
… | |
… | |
3906 | break; |
3894 | break; |
3907 | case XTerm_Color_pointer_bg: |
3895 | case XTerm_Color_pointer_bg: |
3908 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3896 | process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); |
3909 | break; |
3897 | break; |
3910 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3898 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3911 | case XTerm_Color_BD: |
|
|
3912 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
|
|
3913 | break; |
|
|
3914 | case XTerm_Color_UL: |
|
|
3915 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
|
|
3916 | break; |
|
|
3917 | case XTerm_Color_RV: |
3899 | case XTerm_Color_RV: |
3918 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3900 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3901 | break; |
|
|
3902 | case Rxvt_Color_BD: |
|
|
3903 | case URxvt_Color_BD: |
|
|
3904 | process_color_seq (op, Color_BD, str, resp); |
|
|
3905 | break; |
|
|
3906 | case Rxvt_Color_UL: |
|
|
3907 | case URxvt_Color_UL: |
|
|
3908 | process_color_seq (op, Color_UL, str, resp); |
3919 | break; |
3909 | break; |
3920 | case URxvt_Color_IT: |
3910 | case URxvt_Color_IT: |
3921 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3911 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
3922 | break; |
3912 | break; |
3923 | #endif |
3913 | #endif |
… | |
… | |
3928 | if (am_transparent) |
3918 | if (am_transparent) |
3929 | want_full_refresh = want_refresh = 1; |
3919 | want_full_refresh = want_refresh = 1; |
3930 | break; |
3920 | break; |
3931 | #endif |
3921 | #endif |
3932 | |
3922 | |
3933 | case XTerm_Pixmap: |
3923 | case Rxvt_Pixmap: |
3934 | if (*str != ';') |
3924 | if (*str != ';') |
3935 | { |
3925 | { |
3936 | #if XPM_BACKGROUND |
3926 | #if XPM_BACKGROUND |
3937 | scale_pixmap (""); /* reset to default scaling */ |
3927 | scale_pixmap (""); /* reset to default scaling */ |
3938 | set_bgPixmap (str); /* change pixmap */ |
3928 | set_bgPixmap (str); /* change pixmap */ |
3939 | #endif |
|
|
3940 | scr_touch (true); |
3929 | scr_touch (true); |
|
|
3930 | #endif |
3941 | } |
3931 | } |
|
|
3932 | |
3942 | while ((str = strchr (str, ';')) != NULL) |
3933 | while ((str = strchr (str, ';')) != NULL) |
3943 | { |
3934 | { |
3944 | str++; |
3935 | str++; |
3945 | #if XPM_BACKGROUND |
3936 | #if XPM_BACKGROUND |
3946 | changed += scale_pixmap (str); |
3937 | changed += scale_pixmap (str); |
… | |
… | |
3949 | |
3940 | |
3950 | if (changed) |
3941 | if (changed) |
3951 | { |
3942 | { |
3952 | #ifdef XPM_BACKGROUND |
3943 | #ifdef XPM_BACKGROUND |
3953 | resize_pixmap (); |
3944 | resize_pixmap (); |
3954 | #endif |
|
|
3955 | scr_touch (true); |
3945 | scr_touch (true); |
|
|
3946 | #endif |
3956 | } |
3947 | } |
3957 | break; |
3948 | break; |
3958 | |
3949 | |
3959 | case XTerm_restoreFG: |
3950 | case Rxvt_restoreFG: |
3960 | set_window_color (Color_fg, str); |
3951 | set_window_color (Color_fg, str); |
3961 | break; |
3952 | break; |
3962 | case XTerm_restoreBG: |
3953 | case Rxvt_restoreBG: |
3963 | set_window_color (Color_bg, str); |
3954 | set_window_color (Color_bg, str); |
3964 | break; |
3955 | break; |
3965 | |
3956 | |
3966 | case XTerm_logfile: |
3957 | case XTerm_logfile: |
3967 | // TODO, when secure mode? |
3958 | // TODO, when secure mode? |
… | |
… | |
3972 | if (OPTION (Opt_insecure)) |
3963 | if (OPTION (Opt_insecure)) |
3973 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3964 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3974 | break; |
3965 | break; |
3975 | #endif |
3966 | #endif |
3976 | #if 0 |
3967 | #if 0 |
3977 | case XTerm_dumpscreen: /* no error notices */ |
3968 | case Rxvt_dumpscreen: /* no error notices */ |
3978 | { |
3969 | { |
3979 | int fd; |
3970 | int fd; |
3980 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3971 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
3981 | { |
3972 | { |
3982 | scr_dump (fd); |
3973 | scr_dump (fd); |