--- rxvt-unicode/src/command.C 2006/01/08 01:02:15 1.249 +++ rxvt-unicode/src/command.C 2006/01/17 12:22:59 1.269 @@ -149,7 +149,7 @@ for (;;) { - const line_t &l = ROW(y - view_start); + const line_t &l = ROW(y + view_start); text_t t = l.t[x]; @@ -445,7 +445,7 @@ } else if (keysym == XK_End) { - scr_move_to (1, 0); + scr_move_to (1, 1); return; } } @@ -869,7 +869,7 @@ } } - if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STR_LEN, kbuf, len, DT_END))) + if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) return; if (len <= 0) @@ -921,9 +921,7 @@ } /*}}} */ -#if MENUBAR_MAX || defined (KEYSYM_RESOURCE) -/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ -/* attempt to `write' count to the input buffer */ +#if defined (KEYSYM_RESOURCE) unsigned int rxvt_term::cmd_write (const char *str, unsigned int count) { @@ -974,19 +972,20 @@ { if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) { - int row = -view_start; + int row = view_start; + int end_row = row + nrow; - while (row > -nsaved && ROW (row - 1).is_longer ()) + while (row > top_row && ROW (row - 1).is_longer ()) --row; - while (row < -view_start + nrow) + do { int start_row = row; line_t *l; do { - l = &ROW (row); + l = &ROW (row++); if (!(l->f & LINE_FILTERED)) { @@ -994,7 +993,7 @@ l->f |= LINE_FILTERED; while (l->is_longer ()) { - l = &ROW (++row); + l = &ROW (row++); l->f |= LINE_FILTERED; } @@ -1004,14 +1003,12 @@ break; } } - while (l->is_longer ()); - - row++; + while (l->is_longer () && row < end_row); } - + while (row < end_row); } - scr_refresh (refresh_type); + scr_refresh (); scrollbar_show (1); #ifdef USE_XIM IMSendSpot (); @@ -1024,8 +1021,7 @@ void rxvt_term::check_cb (check_watcher &w) { - SET_R (this); - SET_LOCALE (locale); + make_current (); display->flush (); @@ -1036,8 +1032,7 @@ void rxvt_term::flush_cb (time_watcher &w) { - SET_R (this); - SET_LOCALE (locale); + make_current (); refresh_limit = 1; refresh_count = 0; @@ -1075,7 +1070,6 @@ if ((scrollbar_isUp() || scrollbar_isDn()) && scr_page (scrollbar_isUp() ? UP : DN, 1)) { - refresh_type |= SMOOTH_REFRESH; want_refresh = 1; w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); } @@ -1089,7 +1083,6 @@ if (scr_page (scroll_selection_dir, scroll_selection_lines)) { selection_extend (selection_save_x, selection_save_y, selection_save_state); - refresh_type |= SMOOTH_REFRESH; want_refresh = 1; w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); } @@ -1104,11 +1097,9 @@ || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) : scr_page (UP, mouse_slip_wheel_speed)) { - if (view_start == nsaved || - view_start == 0) + if (view_start == top_row || view_start == 0) mouse_slip_wheel_speed = 0; - refresh_type |= SMOOTH_REFRESH; want_refresh = 1; w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); } @@ -1148,7 +1139,7 @@ cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; - ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); + ssize_t r = read (pty->pty, cmdbuf_endp, CBUFSIZ - n); if (r > 0) { @@ -1176,8 +1167,7 @@ void rxvt_term::pty_cb (io_watcher &w, short revents) { - SET_R (this); - SET_LOCALE (locale); + make_current (); if (revents & EVENT_READ) // loop, but don't allow a single term to monopolize us @@ -1219,8 +1209,7 @@ void rxvt_term::pointer_cb (time_watcher &w) { - SET_R (this); - SET_LOCALE (locale); + make_current (); pointer_blank (); } @@ -1309,11 +1298,16 @@ void rxvt_term::x_cb (XEvent &ev) { + make_current (); + dDisp; - SET_R (this); - SET_LOCALE (locale); + if (ev.xany.window == vt + && SHOULD_INVOKE (HOOK_X_EVENT) + && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) + return; + // for XQueryPointer Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; @@ -1330,10 +1324,10 @@ case KeyRelease: { -#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 - KeySym ks; +#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL + KeySym keysym; - ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ + keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ #endif #if ENABLE_FRILLS || ISO_14755 @@ -1348,16 +1342,16 @@ // iso14755 part 5.2 handling: release time // first: controls if ((ev.xkey.state & ControlMask) - && ((ks >= 0x40 && ks <= 0x5f) - || (ks >= 0x61 && ks <= 0x7f))) + && ((keysym >= 0x40 && keysym <= 0x5f) + || (keysym >= 0x61 && keysym <= 0x7f))) { - iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); + iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); commit_iso14755 (); goto skip_switch; } for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) - if (i[0] == ks) + if (i[0] == keysym) { iso14755buf = ISO_14755_51 | i[1]; commit_iso14755 (); @@ -1391,13 +1385,13 @@ #endif if (ev.xany.window == vt - && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) + && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) break; #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) if (!(ev.xkey.state & ControlMask)) slip_wheel_ev.stop (); - else if (ks == XK_Control_L || ks == XK_Control_R) + else if (keysym == XK_Control_L || keysym == XK_Control_R) mouse_slip_wheel_speed = 0; #endif break; @@ -1574,7 +1568,7 @@ scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); - scr_refresh (refresh_type); + want_refresh = 1; } else { @@ -1590,10 +1584,6 @@ scrollBar.setIdle (); scrollbar_show (0); } -#ifdef MENUBAR - if (menubar_visible () && isMenuBarWindow (ev.xany.window)) - menubar_expose (); -#endif #ifdef TRANSPARENT if (am_transparent && ev.xany.window == parent[0]) @@ -1607,19 +1597,13 @@ if (hidden_pointer) pointer_unblank (); #endif -#if MENUBAR - if (isMenuBarWindow (ev.xany.window)) - { - menubar_control (ev.xbutton); - break; - } -#endif if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) break; if (ev.xany.window == vt) { - if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) + if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) + && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) ; // nop else if (ev.xbutton.state & (Button1Mask | Button3Mask)) { @@ -1711,7 +1695,7 @@ &unused_mask); scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, scrollbar_size ()); - scr_refresh (refresh_type); + want_refresh = 1; refresh_limit = 0; scrollbar_show (1); } @@ -1821,8 +1805,7 @@ void rxvt_term::rootwin_cb (XEvent &ev) { - SET_R (this); - SET_LOCALE (locale); + make_current (); switch (ev.type) { @@ -1923,7 +1906,7 @@ #endif /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) + if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) { if (MEvent.button == Button1 && clickintime) selection_rotate (ev.x, ev.y); @@ -2101,14 +2084,6 @@ return; } - -#if MENUBAR - /* - * Menubar window processing of button press - */ - if (isMenuBarWindow (ev.window)) - menubar_control (ev); -#endif } void @@ -2124,9 +2099,6 @@ { scrollBar.setIdle (); scrollbar_show (0); -#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - refresh_type &= ~SMOOTH_REFRESH; -#endif } #ifdef SELECTION_SCROLLING @@ -2217,30 +2189,16 @@ else { # endif -# ifdef JUMP_MOUSE_WHEEL scr_page (v, i); - scr_refresh (SMOOTH_REFRESH); scrollbar_show (1); -# else - while (i--) - { - scr_page (v, 1); - scr_refresh (SMOOTH_REFRESH); - scrollbar_show (1); - } -# endif # ifdef MOUSE_SLIP_WHEELING } -#endif +# endif } break; #endif } } -#ifdef MENUBAR - else if (isMenuBarWindow (ev.window)) - menubar_control (ev); -#endif } #ifdef TRANSPARENT @@ -2793,7 +2751,8 @@ // scr_add_lines only works for nlines <= nrow - 1. if (nlines >= nrow - 1) { - if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + if (!(SHOULD_INVOKE (HOOK_ADD_LINES) + && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) scr_add_lines (buf, str - buf, nlines); nlines = 0; @@ -2818,7 +2777,8 @@ ch = next_char (); } - if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + if (!(SHOULD_INVOKE (HOOK_ADD_LINES) + && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) scr_add_lines (buf, str - buf, nlines); /* @@ -2834,8 +2794,8 @@ else { flag = true; - scr_refresh (refresh_type); - flush_ev.stop (); + scr_refresh (); + want_refresh = 1; } } @@ -3871,9 +3831,9 @@ break; *name++ = '\0'; - color = atoi (buf); + color = atoi (buf) + minCOLOR; - if (color < 0 || color >= TOTAL_COLORS) + if (!IN_RANGE_INC (color, minCOLOR, maxTermCOLOR)) break; if ((buf = strchr (name, ';')) != NULL) @@ -3882,18 +3842,18 @@ if (name[0] == '?' && !name[1]) { unsigned short r, g, b; - pix_colors_focused[color + minCOLOR].get (display, r, g, b); + pix_colors_focused[color].get (display, r, g, b); tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); } else - set_window_color (color + minCOLOR, name); + set_window_color (color, name); } break; case XTerm_Color00: process_color_seq (XTerm_Color00, Color_fg, str, resp); break; case XTerm_Color01: - process_color_seq (XTerm_Color00, Color_bg, str, resp); + process_color_seq (XTerm_Color01, Color_bg, str, resp); break; #ifndef NO_CURSORCOLOR case XTerm_Color_cursor: @@ -3907,15 +3867,17 @@ process_color_seq (XTerm_Color_pointer_bg, Color_pointer_bg, str, resp); break; #ifndef NO_BOLD_UNDERLINE_REVERSE - case XTerm_Color_BD: - process_color_seq (XTerm_Color_BD, Color_BD, str, resp); - break; - case XTerm_Color_UL: - process_color_seq (XTerm_Color_UL, Color_UL, str, resp); - break; case XTerm_Color_RV: process_color_seq (XTerm_Color_RV, Color_RV, str, resp); break; + case Rxvt_Color_BD: + case URxvt_Color_BD: + process_color_seq (op, Color_BD, str, resp); + break; + case Rxvt_Color_UL: + case URxvt_Color_UL: + process_color_seq (op, Color_UL, str, resp); + break; case URxvt_Color_IT: process_color_seq (URxvt_Color_IT, Color_IT, str, resp); break; @@ -3929,15 +3891,16 @@ break; #endif - case XTerm_Pixmap: + case Rxvt_Pixmap: if (*str != ';') { #if XPM_BACKGROUND scale_pixmap (""); /* reset to default scaling */ set_bgPixmap (str); /* change pixmap */ -#endif scr_touch (true); +#endif } + while ((str = strchr (str, ';')) != NULL) { str++; @@ -3950,15 +3913,15 @@ { #ifdef XPM_BACKGROUND resize_pixmap (); -#endif scr_touch (true); +#endif } break; - case XTerm_restoreFG: + case Rxvt_restoreFG: set_window_color (Color_fg, str); break; - case XTerm_restoreBG: + case Rxvt_restoreBG: set_window_color (Color_bg, str); break; @@ -3966,14 +3929,8 @@ // TODO, when secure mode? break; -#ifdef MENUBAR - case URxvt_Menu: - if (OPTION (Opt_insecure)) - menubar_dispatch (const_cast(str)); // casting away constness is checked - break; -#endif #if 0 - case XTerm_dumpscreen: /* no error notices */ + case Rxvt_dumpscreen: /* no error notices */ { int fd; if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) @@ -4014,7 +3971,7 @@ else { set_locale (str); - pty.set_utf8_mode (enc_utf8); + pty->set_utf8_mode (enc_utf8); init_xlocale (); } break; @@ -4098,9 +4055,6 @@ { 7, PrivMode_Autowrap }, // 8, bi-directional support mode { 9, PrivMode_MouseX10 }, -#ifdef menuBar_esc - { menuBar_esc, PrivMode_menuBar }, -#endif // 18, 19 printing-related { 25, PrivMode_VisibleCursor }, #ifdef scrollBar_esc @@ -4205,13 +4159,6 @@ if (state) /* orthogonal */ priv_modes &= ~PrivMode_MouseX11; break; -#ifdef menuBar_esc - case menuBar_esc: -#ifdef MENUBAR - map_menuBar (state); -#endif - break; -#endif #ifdef scrollBar_esc case scrollBar_esc: if (scrollbar_mapping (state)) @@ -4463,12 +4410,15 @@ void rxvt_term::tt_write (const char *data, unsigned int len) { - if (pty.pty < 0) + if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) + return; + + if (pty->pty < 0) return; if (v_buflen == 0) { - ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); + ssize_t written = write (pty->pty, data, min (len, MAX_PTY_WRITE)); if ((unsigned int)written == len) return; @@ -4487,7 +4437,7 @@ void rxvt_term::pty_write () { - int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); + int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); if (written > 0) {