--- rxvt-unicode/src/command.C 2005/12/31 16:40:28 1.218 +++ rxvt-unicode/src/command.C 2006/01/04 01:10:08 1.232 @@ -45,11 +45,17 @@ *----------------------------------------------------------------------*/ /*{{{ includes: */ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ +#include "../config.h" +#include "rxvt.h" +#include "rxvtperl.h" #include "version.h" #include "command.h" +#if HAVE_SCHED_YIELD +#undef HAVE_SCHED_YIELD // disabled for the time being +//# include +#endif + #ifdef KEYSYM_RESOURCE # include "keyboard.h" #endif @@ -157,12 +163,10 @@ x--; } } -#endif void rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) { -#if ENABLE_OVERLAY rxvt_fontset *fs = FONTSET (r); rxvt_font *f = (*fs)[fs->find_font (ch)]; wchar_t *chr, *alloc, ch2, *fname; @@ -240,8 +244,8 @@ if (alloc) delete [] alloc; # endif -#endif } +#endif void rxvt_term::commit_iso14755 () @@ -868,7 +872,7 @@ if (len <= 0) return; /* not mapped */ - if (options & Opt_scrollTtyKeypress) + if (OPTION (Opt_scrollTtyKeypress)) if (view_start) { view_start = 0; @@ -984,7 +988,7 @@ display->flush (); if (want_refresh && !flush_ev.active) - flush_ev.start (NOW + 0.01); + flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally } void @@ -1069,6 +1073,24 @@ } #endif +#if HAVE_SCHED_YIELD +static struct event_handler +{ + check_watcher cw_yield; + + void yield (check_watcher &w) + { + sched_yield (); + w.stop (); + } + + event_handler () + : cw_yield (this, &event_handler::yield) + { + } +} event_handler; +#endif + bool rxvt_term::pty_fill () { @@ -1084,18 +1106,25 @@ cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; - n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); + ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); - if (n > 0) + if (r > 0) { - cmdbuf_endp += n; + cmdbuf_endp += r; return true; } - else if ((n < 0 && errno != EAGAIN && errno != EINTR) || n == 0) + else if (r < 0 && (errno == EAGAIN || errno == EINTR)) + { +#if HAVE_SCHED_YIELD + if (display->is_local) + event_handler.cw_yield.start (); +#endif + } + else { pty_ev.stop (); - if (!(options & Opt_hold)) + if (!OPTION (Opt_hold)) destroy (); } @@ -1127,7 +1156,7 @@ #ifdef POINTER_BLANK hidden_pointer = 0; - if (options & Opt_pointerBlank) + if (OPTION (Opt_pointerBlank)) pointer_ev.start (NOW + pointerBlankDelay); #endif } @@ -1136,7 +1165,7 @@ void rxvt_term::pointer_blank () { - if (! (options & Opt_pointerBlank)) + if (! OPTION (Opt_pointerBlank)) return; XDefineCursor (display->display, vt, display->blank_cursor); @@ -1244,7 +1273,7 @@ SET_LOCALE (locale); #if defined(CURSOR_BLINK) - if ((options & Opt_cursorBlink) && ev.type == KeyPress) + if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) { if (hidden_cursor) { @@ -1257,7 +1286,7 @@ #endif #if defined(POINTER_BLANK) - if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) + if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) { if (ev.type == MotionNotify || ev.type == ButtonPress @@ -1463,7 +1492,7 @@ } #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (options & Opt_transparent) + if (OPTION (Opt_transparent)) check_our_parents (); #endif } @@ -1674,6 +1703,9 @@ { focus = 1; want_refresh = 1; + + PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if USE_XIM if (Input_Context != NULL) { @@ -1682,7 +1714,7 @@ } #endif #if CURSOR_BLINK - if (options & Opt_cursorBlink) + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.start (NOW + BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING @@ -1703,18 +1735,23 @@ focus = 0; want_refresh = 1; + PERL_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if ENABLE_FRILLS || ISO_14755 - iso14755buf = 0; -#endif -#if ENABLE_OVERLAY - scr_overlay_off (); + if (iso14755buf) + { + iso14755buf = 0; +# if ENABLE_OVERLAY + scr_overlay_off (); +# endif + } #endif #if USE_XIM if (Input_Context != NULL) XUnsetICFocus (Input_Context); #endif #if CURSOR_BLINK - if (options & Opt_cursorBlink) + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.stop (); hidden_cursor = 0; #endif @@ -1748,7 +1785,7 @@ /* FALLTHROUGH */ case ReparentNotify: - if ((options & Opt_transparent) && check_our_parents () && am_transparent) + if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) want_refresh = want_full_refresh = 1; break; } @@ -1761,6 +1798,7 @@ int reportmode = 0, clickintime; bypass_keystate = ev.state & (ModMetaMask | ShiftMask); + if (!bypass_keystate) reportmode = !! (priv_modes & PrivMode_mouse_report); @@ -1819,48 +1857,49 @@ if (ev.button != MEvent.button) MEvent.clicks = 0; - switch (ev.button) - { - case Button1: - /* allow meta + click to select rectangular areas */ - /* should be done in screen.C */ + if (!PERL_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) + switch (ev.button) + { + case Button1: + /* allow meta + click to select rectangular areas */ + /* should be done in screen.C */ #if ENABLE_FRILLS - selection.rect = !!(ev.state & ModMetaMask); + selection.rect = !!(ev.state & ModMetaMask); #else - selection.rect = false; + selection.rect = false; #endif - /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) - { - if (MEvent.button == Button1 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - } - else - { - if (MEvent.button == Button1 && clickintime) - MEvent.clicks++; - else - MEvent.clicks = 1; + /* allow shift+left click to extend selection */ + if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) + { + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); + } + else + { + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; + else + MEvent.clicks = 1; - selection_click (MEvent.clicks, ev.x, ev.y); - } + selection_click (MEvent.clicks, ev.x, ev.y); + } - MEvent.button = Button1; - break; + MEvent.button = Button1; + break; - case Button3: - if (MEvent.button == Button3 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); + case Button3: + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); - MEvent.button = Button3; - break; - } - } + MEvent.button = Button3; + break; + } + } MEvent.time = ev.time; return; @@ -2100,7 +2139,7 @@ if (ev.state & ShiftMask) i = 1; - else if (options & Opt_mouseWheelScrollPage) + else if (OPTION (Opt_mouseWheelScrollPage)) i = nrow - 1; else i = 5; @@ -2396,7 +2435,7 @@ pchanged = 0; - if (!(options & Opt_transparent)) + if (!OPTION (Opt_transparent)) return pchanged; /* Don't try any more */ XGetWindowAttributes (disp, display->root, &wrootattr); @@ -2684,10 +2723,11 @@ refresh_count++; - if (!(options & Opt_jumpScroll) + if (!OPTION (Opt_jumpScroll) || (refresh_count >= refresh_limit * (nrow - 1))) { refreshnow = true; + refresh_count = 0; ch = NOCHAR; break; } @@ -2728,12 +2768,13 @@ */ if (refreshnow) { - if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) + if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) refresh_limit++; else { flag = true; scr_refresh (refresh_type); + flush_ev.stop (); } } @@ -3402,7 +3443,7 @@ scr_report_position (); break; case 7: /* unofficial extension */ - if (options & Opt_insecure) + if (OPTION (Opt_insecure)) tt_printf ("%-.250s\012", rs[Rs_display_name]); break; case 8: /* unofficial extension */ @@ -3576,7 +3617,7 @@ { char *s; XGetIconName (disp, parent[0], &s); - tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3584,7 +3625,7 @@ { char *s; XFetchName (disp, parent[0], &s); - tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3870,7 +3911,7 @@ #ifdef MENUBAR case URxvt_Menu: - if (options & Opt_insecure) + if (OPTION (Opt_insecure)) menubar_dispatch (const_cast(str)); // casting away constness is checked break; #endif @@ -3896,7 +3937,7 @@ #endif if (query) tt_printf ("\33]%d;%-.250s%c", saveop, - (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc + OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc ? fontset[op - URxvt_font]->fontdesc : "", resp); else @@ -3912,7 +3953,7 @@ #if ENABLE_FRILLS case URxvt_locale: if (query) - tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); + tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); else { set_locale (str); @@ -3923,15 +3964,22 @@ case URxvt_view_up: case URxvt_view_down: - int lines = atoi (str); + { + int lines = atoi (str); - if (lines) - scr_page (op == URxvt_view_up ? UP : DN, lines); - else - { + if (lines) + scr_page (op == URxvt_view_up ? UP : DN, lines); + else scr_erase_savelines (); - } + } + + break; +#endif +#if ENABLE_PERL + case URxvt_perl: + if (PERL_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) + ; // no responses yet break; #endif } @@ -4050,9 +4098,19 @@ /* extra handling for values with state unkept */ switch (arg[i]) { +#if ENABLE_STYLES + case 1021: + if (mode) + SET_OPTION (Opt_intensityStyles); + else + CLR_OPTION (Opt_intensityStyles); + + scr_touch (true); + break; +#endif case 1048: /* alternative cursor save */ case 1049: - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (mode == 0) scr_cursor (RESTORE); else if (mode == 1) @@ -4077,10 +4135,10 @@ set_widthheight (((state ? 132 : 80) * fwidth), height); break; case 4: /* smooth scrolling */ - if (state) - options &= ~Opt_jumpScroll; + if (!state) + SET_OPTION (Opt_jumpScroll); else - options |= Opt_jumpScroll; + CLR_OPTION (Opt_jumpScroll); break; case 5: /* reverse video */ scr_rvideo_mode (state); @@ -4131,26 +4189,26 @@ break; /* X11 mouse highlighting */ #endif case 1010: /* scroll to bottom on TTY output inhibit */ - if (state) - options &= ~Opt_scrollTtyOutput; + if (!state) + SET_OPTION (Opt_scrollTtyOutput); else - options |= Opt_scrollTtyOutput; + CLR_OPTION (Opt_scrollTtyOutput); break; case 1011: /* scroll to bottom on key press */ if (state) - options |= Opt_scrollTtyKeypress; + SET_OPTION (Opt_scrollTtyKeypress); else - options &= ~Opt_scrollTtyKeypress; + CLR_OPTION (Opt_scrollTtyKeypress); break; case 1047: /* secondary screen w/ clearing last */ - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); scr_change_screen (state); break; case 1049: /* secondary screen w/ clearing first */ scr_change_screen (state); - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); break; @@ -4310,7 +4368,6 @@ scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif - } } }