ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.254 by root, Wed Jan 11 02:13:56 2006 UTC vs.
Revision 1.267 by root, Mon Jan 16 15:00:20 2006 UTC

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 }
919#endif /* DEBUG_CMD */ 919#endif /* DEBUG_CMD */
920 tt_write (kbuf, (unsigned int)len); 920 tt_write (kbuf, (unsigned int)len);
921} 921}
922/*}}} */ 922/*}}} */
923 923
924#if MENUBAR_MAX || defined (KEYSYM_RESOURCE) 924#if defined (KEYSYM_RESOURCE)
925/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
926/* attempt to `write' count to the input buffer */
927unsigned int 925unsigned int
928rxvt_term::cmd_write (const char *str, unsigned int count) 926rxvt_term::cmd_write (const char *str, unsigned int count)
929{ 927{
930 unsigned int n, s; 928 unsigned int n, s;
931 929
972 970
973 if (want_refresh) 971 if (want_refresh)
974 { 972 {
975 if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) 973 if (SHOULD_INVOKE (HOOK_LINE_UPDATE))
976 { 974 {
977 int row = -view_start; 975 int row = view_start;
978 int end_row = row + nrow; 976 int end_row = row + nrow;
979 977
980 while (row > -nsaved && ROW (row - 1).is_longer ()) 978 while (row > top_row && ROW (row - 1).is_longer ())
981 --row; 979 --row;
982 980
983 do 981 do
984 { 982 {
985 int start_row = row; 983 int start_row = row;
986 line_t *l; 984 line_t *l;
987 985
988 do 986 do
989 { 987 {
990 l = &ROW (row); 988 l = &ROW (row++);
991 989
992 if (l->f & LINE_FILTERED) 990 if (!(l->f & LINE_FILTERED))
993 row++;
994 else
995 { 991 {
996 // line not filtered, mark it as filtered 992 // line not filtered, mark it as filtered
997 l->f |= LINE_FILTERED; 993 l->f |= LINE_FILTERED;
998 while (l->is_longer ()) 994 while (l->is_longer ())
999 { 995 {
1000 l = &ROW (++row); 996 l = &ROW (row++);
1001 l->f |= LINE_FILTERED; 997 l->f |= LINE_FILTERED;
1002 } 998 }
1003 999
1004 // and filter it 1000 // and filter it
1005 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); 1001 HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END));
1007 break; 1003 break;
1008 } 1004 }
1009 } 1005 }
1010 while (l->is_longer () && row < end_row); 1006 while (l->is_longer () && row < end_row);
1011 } 1007 }
1012 while (++row < end_row); 1008 while (row < end_row);
1013 } 1009 }
1014 1010
1015 scr_refresh (refresh_type); 1011 scr_refresh (refresh_type);
1016 scrollbar_show (1); 1012 scrollbar_show (1);
1017#ifdef USE_XIM 1013#ifdef USE_XIM
1023} 1019}
1024 1020
1025void 1021void
1026rxvt_term::check_cb (check_watcher &w) 1022rxvt_term::check_cb (check_watcher &w)
1027{ 1023{
1028 SET_R (this); 1024 make_current ();
1029 SET_LOCALE (locale);
1030 1025
1031 display->flush (); 1026 display->flush ();
1032 1027
1033 if (want_refresh && !flush_ev.active) 1028 if (want_refresh && !flush_ev.active)
1034 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally 1029 flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally
1035} 1030}
1036 1031
1037void 1032void
1038rxvt_term::flush_cb (time_watcher &w) 1033rxvt_term::flush_cb (time_watcher &w)
1039{ 1034{
1040 SET_R (this); 1035 make_current ();
1041 SET_LOCALE (locale);
1042 1036
1043 refresh_limit = 1; 1037 refresh_limit = 1;
1044 refresh_count = 0; 1038 refresh_count = 0;
1045 flush (); 1039 flush ();
1046} 1040}
1103{ 1097{
1104 if (mouse_slip_wheel_speed == 0 1098 if (mouse_slip_wheel_speed == 0
1105 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) 1099 || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed)
1106 : scr_page (UP, mouse_slip_wheel_speed)) 1100 : scr_page (UP, mouse_slip_wheel_speed))
1107 { 1101 {
1108 if (view_start == nsaved || 1102 if (view_start == top_row || view_start == 0)
1109 view_start == 0)
1110 mouse_slip_wheel_speed = 0; 1103 mouse_slip_wheel_speed = 0;
1111 1104
1112 refresh_type |= SMOOTH_REFRESH; 1105 refresh_type |= SMOOTH_REFRESH;
1113 want_refresh = 1; 1106 want_refresh = 1;
1114 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1107 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1175} 1168}
1176 1169
1177void 1170void
1178rxvt_term::pty_cb (io_watcher &w, short revents) 1171rxvt_term::pty_cb (io_watcher &w, short revents)
1179{ 1172{
1180 SET_R (this); 1173 make_current ();
1181 SET_LOCALE (locale);
1182 1174
1183 if (revents & EVENT_READ) 1175 if (revents & EVENT_READ)
1184 // loop, but don't allow a single term to monopolize us 1176 // loop, but don't allow a single term to monopolize us
1185 while (pty_fill ()) 1177 while (pty_fill ())
1186 if (cmd_parse ()) 1178 if (cmd_parse ())
1218} 1210}
1219 1211
1220void 1212void
1221rxvt_term::pointer_cb (time_watcher &w) 1213rxvt_term::pointer_cb (time_watcher &w)
1222{ 1214{
1223 SET_R (this); 1215 make_current ();
1224 SET_LOCALE (locale);
1225 1216
1226 pointer_blank (); 1217 pointer_blank ();
1227} 1218}
1228#endif 1219#endif
1229 1220
1308 1299
1309/*{{{ process an X event */ 1300/*{{{ process an X event */
1310void 1301void
1311rxvt_term::x_cb (XEvent &ev) 1302rxvt_term::x_cb (XEvent &ev)
1312{ 1303{
1304 make_current ();
1305
1313 dDisp; 1306 dDisp;
1314 1307
1315 SET_R (this); 1308 if (ev.xany.window == vt
1316 SET_LOCALE (locale); 1309 && SHOULD_INVOKE (HOOK_X_EVENT)
1310 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1311 return;
1317 1312
1313 // for XQueryPointer
1318 Window unused_root, unused_child; 1314 Window unused_root, unused_child;
1319 int unused_root_x, unused_root_y; 1315 int unused_root_x, unused_root_y;
1320 unsigned int unused_mask; 1316 unsigned int unused_mask;
1321 1317
1322 switch (ev.type) 1318 switch (ev.type)
1589 if (isScrollbarWindow (ev.xany.window)) 1585 if (isScrollbarWindow (ev.xany.window))
1590 { 1586 {
1591 scrollBar.setIdle (); 1587 scrollBar.setIdle ();
1592 scrollbar_show (0); 1588 scrollbar_show (0);
1593 } 1589 }
1594#ifdef MENUBAR
1595 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1596 menubar_expose ();
1597#endif
1598 1590
1599#ifdef TRANSPARENT 1591#ifdef TRANSPARENT
1600 if (am_transparent && ev.xany.window == parent[0]) 1592 if (am_transparent && ev.xany.window == parent[0])
1601 XClearWindow (disp, ev.xany.window); 1593 XClearWindow (disp, ev.xany.window);
1602#endif 1594#endif
1606 case MotionNotify: 1598 case MotionNotify:
1607#ifdef POINTER_BLANK 1599#ifdef POINTER_BLANK
1608 if (hidden_pointer) 1600 if (hidden_pointer)
1609 pointer_unblank (); 1601 pointer_unblank ();
1610#endif 1602#endif
1611#if MENUBAR
1612 if (isMenuBarWindow (ev.xany.window))
1613 {
1614 menubar_control (ev.xbutton);
1615 break;
1616 }
1617#endif
1618 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) 1603 if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate)
1619 break; 1604 break;
1620 1605
1621 if (ev.xany.window == vt) 1606 if (ev.xany.window == vt)
1622 { 1607 {
1608 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1623 if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1609 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1624 ; // nop 1610 ; // nop
1625 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1611 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1626 { 1612 {
1627 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) 1613 while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev))
1628 ; 1614 ;
1820 1806
1821#if TRANSPARENT 1807#if TRANSPARENT
1822void 1808void
1823rxvt_term::rootwin_cb (XEvent &ev) 1809rxvt_term::rootwin_cb (XEvent &ev)
1824{ 1810{
1825 SET_R (this); 1811 make_current ();
1826 SET_LOCALE (locale);
1827 1812
1828 switch (ev.type) 1813 switch (ev.type)
1829 { 1814 {
1830 case PropertyNotify: 1815 case PropertyNotify:
1831 /* 1816 /*
1922#else 1907#else
1923 selection.rect = false; 1908 selection.rect = false;
1924#endif 1909#endif
1925 1910
1926 /* allow shift+left click to extend selection */ 1911 /* allow shift+left click to extend selection */
1927 if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) 1912 if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
1928 { 1913 {
1929 if (MEvent.button == Button1 && clickintime) 1914 if (MEvent.button == Button1 && clickintime)
1930 selection_rotate (ev.x, ev.y); 1915 selection_rotate (ev.x, ev.y);
1931 else 1916 else
1932 selection_extend (ev.x, ev.y, 1); 1917 selection_extend (ev.x, ev.y, 1);
2100 } 2085 }
2101 } 2086 }
2102 2087
2103 return; 2088 return;
2104 } 2089 }
2105
2106#if MENUBAR
2107 /*
2108 * Menubar window processing of button press
2109 */
2110 if (isMenuBarWindow (ev.window))
2111 menubar_control (ev);
2112#endif
2113} 2090}
2114 2091
2115void 2092void
2116rxvt_term::button_release (XButtonEvent &ev) 2093rxvt_term::button_release (XButtonEvent &ev)
2117{ 2094{
2226 } 2203 }
2227 break; 2204 break;
2228#endif 2205#endif
2229 } 2206 }
2230 } 2207 }
2231#ifdef MENUBAR
2232 else if (isMenuBarWindow (ev.window))
2233 menubar_control (ev);
2234#endif
2235} 2208}
2236 2209
2237#ifdef TRANSPARENT 2210#ifdef TRANSPARENT
2238#if TINTING 2211#if TINTING
2239/* taken from aterm-0.4.2 */ 2212/* taken from aterm-0.4.2 */
2782 } 2755 }
2783 2756
2784 // scr_add_lines only works for nlines <= nrow - 1. 2757 // scr_add_lines only works for nlines <= nrow - 1.
2785 if (nlines >= nrow - 1) 2758 if (nlines >= nrow - 1)
2786 { 2759 {
2760 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2787 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2761 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2788 scr_add_lines (buf, str - buf, nlines); 2762 scr_add_lines (buf, str - buf, nlines);
2789 2763
2790 nlines = 0; 2764 nlines = 0;
2791 str = buf; 2765 str = buf;
2792 eol = str + min (ncol, UBUFSIZ); 2766 eol = str + min (ncol, UBUFSIZ);
2807 2781
2808 seq_begin = cmdbuf_ptr; 2782 seq_begin = cmdbuf_ptr;
2809 ch = next_char (); 2783 ch = next_char ();
2810 } 2784 }
2811 2785
2786 if (!(SHOULD_INVOKE (HOOK_ADD_LINES)
2812 if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) 2787 && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))))
2813 scr_add_lines (buf, str - buf, nlines); 2788 scr_add_lines (buf, str - buf, nlines);
2814 2789
2815 /* 2790 /*
2816 * If there have been a lot of new lines, then update the screen 2791 * If there have been a lot of new lines, then update the screen
2817 * What the heck I'll cheat and only refresh less than every page-full. 2792 * What the heck I'll cheat and only refresh less than every page-full.
3860 { 3835 {
3861 if ((name = strchr (buf, ';')) == NULL) 3836 if ((name = strchr (buf, ';')) == NULL)
3862 break; 3837 break;
3863 3838
3864 *name++ = '\0'; 3839 *name++ = '\0';
3865 color = atoi (buf); 3840 color = atoi (buf) + minCOLOR;
3866 3841
3867 if (color < 0 || color >= TOTAL_COLORS) 3842 if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR))
3868 break; 3843 break;
3869 3844
3870 if ((buf = strchr (name, ';')) != NULL) 3845 if ((buf = strchr (name, ';')) != NULL)
3871 *buf++ = '\0'; 3846 *buf++ = '\0';
3872 3847
3873 if (name[0] == '?' && !name[1]) 3848 if (name[0] == '?' && !name[1])
3874 { 3849 {
3875 unsigned short r, g, b; 3850 unsigned short r, g, b;
3876 pix_colors_focused[color + minCOLOR].get (display, r, g, b); 3851 pix_colors_focused[color].get (display, r, g, b);
3877 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3852 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3878 } 3853 }
3879 else 3854 else
3880 set_window_color (color + minCOLOR, name); 3855 set_window_color (color, name);
3881 } 3856 }
3882 break; 3857 break;
3883 case XTerm_Color00: 3858 case XTerm_Color00:
3884 process_color_seq (XTerm_Color00, Color_fg, str, resp); 3859 process_color_seq (XTerm_Color00, Color_fg, str, resp);
3885 break; 3860 break;
3886 case XTerm_Color01: 3861 case XTerm_Color01:
3887 process_color_seq (XTerm_Color00, Color_bg, str, resp); 3862 process_color_seq (XTerm_Color01, Color_bg, str, resp);
3888 break; 3863 break;
3889#ifndef NO_CURSORCOLOR 3864#ifndef NO_CURSORCOLOR
3890 case XTerm_Color_cursor: 3865 case XTerm_Color_cursor:
3891 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp); 3866 process_color_seq (XTerm_Color_cursor, Color_cursor, str, resp);
3892 break; 3867 break;
3896 break; 3871 break;
3897 case XTerm_Color_pointer_bg: 3872 case XTerm_Color_pointer_bg:
3898 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); 3873 process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp);
3899 break; 3874 break;
3900#ifndef NO_BOLD_UNDERLINE_REVERSE 3875#ifndef NO_BOLD_UNDERLINE_REVERSE
3901 case XTerm_Color_BD:
3902 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3903 break;
3904 case XTerm_Color_UL:
3905 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3906 break;
3907 case XTerm_Color_RV: 3876 case XTerm_Color_RV:
3908 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3877 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3878 break;
3879 case Rxvt_Color_BD:
3880 case URxvt_Color_BD:
3881 process_color_seq (op, Color_BD, str, resp);
3882 break;
3883 case Rxvt_Color_UL:
3884 case URxvt_Color_UL:
3885 process_color_seq (op, Color_UL, str, resp);
3909 break; 3886 break;
3910 case URxvt_Color_IT: 3887 case URxvt_Color_IT:
3911 process_color_seq (URxvt_Color_IT, Color_IT, str, resp); 3888 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3912 break; 3889 break;
3913#endif 3890#endif
3918 if (am_transparent) 3895 if (am_transparent)
3919 want_full_refresh = want_refresh = 1; 3896 want_full_refresh = want_refresh = 1;
3920 break; 3897 break;
3921#endif 3898#endif
3922 3899
3923 case XTerm_Pixmap: 3900 case Rxvt_Pixmap:
3924 if (*str != ';') 3901 if (*str != ';')
3925 { 3902 {
3926#if XPM_BACKGROUND 3903#if XPM_BACKGROUND
3927 scale_pixmap (""); /* reset to default scaling */ 3904 scale_pixmap (""); /* reset to default scaling */
3928 set_bgPixmap (str); /* change pixmap */ 3905 set_bgPixmap (str); /* change pixmap */
3929#endif
3930 scr_touch (true); 3906 scr_touch (true);
3907#endif
3931 } 3908 }
3909
3932 while ((str = strchr (str, ';')) != NULL) 3910 while ((str = strchr (str, ';')) != NULL)
3933 { 3911 {
3934 str++; 3912 str++;
3935#if XPM_BACKGROUND 3913#if XPM_BACKGROUND
3936 changed += scale_pixmap (str); 3914 changed += scale_pixmap (str);
3939 3917
3940 if (changed) 3918 if (changed)
3941 { 3919 {
3942#ifdef XPM_BACKGROUND 3920#ifdef XPM_BACKGROUND
3943 resize_pixmap (); 3921 resize_pixmap ();
3944#endif
3945 scr_touch (true); 3922 scr_touch (true);
3923#endif
3946 } 3924 }
3947 break; 3925 break;
3948 3926
3949 case XTerm_restoreFG: 3927 case Rxvt_restoreFG:
3950 set_window_color (Color_fg, str); 3928 set_window_color (Color_fg, str);
3951 break; 3929 break;
3952 case XTerm_restoreBG: 3930 case Rxvt_restoreBG:
3953 set_window_color (Color_bg, str); 3931 set_window_color (Color_bg, str);
3954 break; 3932 break;
3955 3933
3956 case XTerm_logfile: 3934 case XTerm_logfile:
3957 // TODO, when secure mode? 3935 // TODO, when secure mode?
3958 break; 3936 break;
3959 3937
3960#ifdef MENUBAR
3961 case URxvt_Menu:
3962 if (OPTION (Opt_insecure))
3963 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3964 break;
3965#endif
3966#if 0 3938#if 0
3967 case XTerm_dumpscreen: /* no error notices */ 3939 case Rxvt_dumpscreen: /* no error notices */
3968 { 3940 {
3969 int fd; 3941 int fd;
3970 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) 3942 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3971 { 3943 {
3972 scr_dump (fd); 3944 scr_dump (fd);
4087 { 5, PrivMode_rVideo }, 4059 { 5, PrivMode_rVideo },
4088 { 6, PrivMode_relOrigin }, 4060 { 6, PrivMode_relOrigin },
4089 { 7, PrivMode_Autowrap }, 4061 { 7, PrivMode_Autowrap },
4090 // 8, bi-directional support mode 4062 // 8, bi-directional support mode
4091 { 9, PrivMode_MouseX10 }, 4063 { 9, PrivMode_MouseX10 },
4092#ifdef menuBar_esc
4093 { menuBar_esc, PrivMode_menuBar },
4094#endif
4095 // 18, 19 printing-related 4064 // 18, 19 printing-related
4096 { 25, PrivMode_VisibleCursor }, 4065 { 25, PrivMode_VisibleCursor },
4097#ifdef scrollBar_esc 4066#ifdef scrollBar_esc
4098 { scrollBar_esc, PrivMode_scrollBar }, 4067 { scrollBar_esc, PrivMode_scrollBar },
4099#endif 4068#endif
4194 /* case 8: - auto repeat, can't do on a per window basis */ 4163 /* case 8: - auto repeat, can't do on a per window basis */
4195 case 9: /* X10 mouse reporting */ 4164 case 9: /* X10 mouse reporting */
4196 if (state) /* orthogonal */ 4165 if (state) /* orthogonal */
4197 priv_modes &= ~PrivMode_MouseX11; 4166 priv_modes &= ~PrivMode_MouseX11;
4198 break; 4167 break;
4199#ifdef menuBar_esc
4200 case menuBar_esc:
4201#ifdef MENUBAR
4202 map_menuBar (state);
4203#endif
4204 break;
4205#endif
4206#ifdef scrollBar_esc 4168#ifdef scrollBar_esc
4207 case scrollBar_esc: 4169 case scrollBar_esc:
4208 if (scrollbar_mapping (state)) 4170 if (scrollbar_mapping (state))
4209 { 4171 {
4210 resize_all_windows (0, 0, 0); 4172 resize_all_windows (0, 0, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines