--- rxvt-unicode/src/command.C 2006/01/06 01:16:58 1.237 +++ rxvt-unicode/src/command.C 2006/01/08 00:07:18 1.248 @@ -27,7 +27,7 @@ * Copyright (c) 2001 Marius Gedminas * - Ctrl/Mod4+Tab works like Meta+Tab (options) * Copyright (c) 2003 Rob McMullen - * Copyright (c) 2003-2005 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -869,6 +869,9 @@ } } + if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STR_LEN, kbuf, len, DT_END))) + return; + if (len <= 0) return; /* not mapped */ @@ -1204,7 +1207,7 @@ void rxvt_term::pointer_blank () { - if (! OPTION (Opt_pointerBlank)) + if (!OPTION (Opt_pointerBlank)) return; XDefineCursor (display->display, vt, display->blank_cursor); @@ -1311,33 +1314,6 @@ SET_R (this); SET_LOCALE (locale); -#if defined(CURSOR_BLINK) - if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) - { - if (hidden_cursor) - { - hidden_cursor = 0; - want_refresh = 1; - } - - cursor_blink_ev.start (NOW + BLINK_INTERVAL); - } -#endif - -#if defined(POINTER_BLANK) - if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) - { - if (ev.type == MotionNotify - || ev.type == ButtonPress - || ev.type == ButtonRelease) - if (hidden_pointer) - pointer_unblank (); - - if (ev.type == KeyPress && hidden_pointer == 0) - pointer_blank (); - } -#endif - Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; @@ -1377,7 +1353,7 @@ { iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); commit_iso14755 (); - return; // case-break; + goto skip_switch; } for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) @@ -1385,7 +1361,7 @@ { iso14755buf = ISO_14755_51 | i[1]; commit_iso14755 (); - return; // case-break; + goto skip_switch; } scr_bell (); @@ -1414,6 +1390,10 @@ } #endif + if (ev.xany.window == vt + && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) + break; + #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) if (!(ev.xkey.state & ControlMask)) slip_wheel_ev.stop (); @@ -1557,18 +1537,20 @@ selection_send (ev.xselectionrequest); break; - case UnmapNotify: - mapped = 0; + case MapNotify: + mapped = 1; #ifdef TEXT_BLINK - text_blink_ev.stop (); + text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); #endif + HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; - case MapNotify: - mapped = 1; + case UnmapNotify: + mapped = 0; #ifdef TEXT_BLINK - text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + text_blink_ev.stop (); #endif + HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; #ifdef TRANSPARENT @@ -1637,7 +1619,9 @@ if (ev.xany.window == vt) { - if (ev.xbutton.state & (Button1Mask | Button3Mask)) + if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) + ; // nop + else if (ev.xbutton.state & (Button1Mask | Button3Mask)) { while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) ; @@ -1733,6 +1717,35 @@ } break; } + +skip_switch: ; + +#if defined(CURSOR_BLINK) + if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) + { + if (hidden_cursor) + { + hidden_cursor = 0; + want_refresh = 1; + } + + cursor_blink_ev.start (NOW + BLINK_INTERVAL); + } +#endif + +#if defined(POINTER_BLANK) + if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) + { + if (ev.type == MotionNotify + || ev.type == ButtonPress + || ev.type == ButtonRelease) + if (hidden_pointer) + pointer_unblank (); + + if (ev.type == KeyPress && hidden_pointer == 0) + pointer_blank (); + } +#endif } void @@ -1867,6 +1880,7 @@ { /* same button, within alloted time */ MEvent.clicks++; + if (MEvent.clicks > 1) { /* only report double clicks */ @@ -1896,7 +1910,7 @@ if (ev.button != MEvent.button) MEvent.clicks = 0; - if (!HOOK_INVOKE ((this, HOOK_MOUSE_CLICK, DT_XEVENT, &ev, DT_END))) + if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) switch (ev.button) { case Button1: @@ -2084,8 +2098,10 @@ break; } } + return; } + #if MENUBAR /* * Menubar window processing of button press @@ -2158,6 +2174,9 @@ && ev.button == Button1 && MEvent.clicks <= 1) selection_extend (ev.x, ev.y, 0); + if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) + return; + switch (ev.button) { case Button1: @@ -2711,7 +2730,7 @@ rxvt_term::cmd_parse () { bool flag = false; - unicode_t ch = NOCHAR; + wchar_t ch = NOCHAR; char *seq_begin; // remember start of esc-sequence here for (;;) @@ -2720,10 +2739,10 @@ { seq_begin = cmdbuf_ptr; ch = next_char (); - } - if (ch == NOCHAR) // TODO: improve - break; + if (ch == NOCHAR) + break; + } if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) { @@ -2742,11 +2761,11 @@ } /* Read a text string from the input buffer */ - unicode_t buf[UBUFSIZ]; + wchar_t buf[UBUFSIZ]; bool refreshnow = false; int nlines = 0; - unicode_t *str = buf; - unicode_t *eol = str + min (ncol, UBUFSIZ); + wchar_t *str = buf; + wchar_t *eol = str + min (ncol, UBUFSIZ); for (;;) { @@ -2774,8 +2793,8 @@ // scr_add_lines only works for nlines <= nrow - 1. if (nlines >= nrow - 1) { - if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) - scr_add_lines (buf, nlines, str - buf); + if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, str - buf, nlines); nlines = 0; str = buf; @@ -2799,8 +2818,8 @@ ch = next_char (); } - if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) - scr_add_lines (buf, nlines, str - buf); + if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, str - buf, nlines); /* * If there have been a lot of new lines, then update the screen @@ -2841,17 +2860,8 @@ return flag; } -// read the next octet -unicode_t -rxvt_term::next_octet () -{ - return cmdbuf_ptr < cmdbuf_endp - ? *cmdbuf_ptr++ - : NOCHAR; -} - // read the next character -unicode_t +wchar_t rxvt_term::next_char () { while (cmdbuf_ptr < cmdbuf_endp) @@ -2871,7 +2881,7 @@ } if (len == (size_t)-1) - return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through + return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through // assume wchar == unicode cmdbuf_ptr += len; @@ -2881,15 +2891,24 @@ return NOCHAR; } +// read the next octet +uint32_t +rxvt_term::next_octet () +{ + return cmdbuf_ptr < cmdbuf_endp + ? (unsigned char)*cmdbuf_ptr++ + : NOCHAR; +} + /* rxvt_cmd_getc () - Return next input character */ /* * Return the next input character after first passing any keyboard input * to the command. */ -unicode_t +wchar_t rxvt_term::cmd_getc () { - unicode_t c = next_char (); + wchar_t c = next_char (); if (c == NOCHAR) throw out_of_input; @@ -2897,10 +2916,10 @@ return c; } -unicode_t +uint32_t rxvt_term::cmd_get8 () { - unicode_t c = next_octet (); + uint32_t c = next_octet (); if (c == NOCHAR) throw out_of_input; @@ -3177,8 +3196,8 @@ /* 8.3.87: NEXT LINE */ case C1_NEL: /* ESC E */ { - unicode_t nlcr[] = { C0_LF, C0_CR }; - scr_add_lines (nlcr, 1, 2); + wchar_t nlcr[] = { C0_LF, C0_CR }; + scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); } break; @@ -4016,7 +4035,7 @@ #if ENABLE_PERL case URxvt_perl: - if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STRING, str, DT_END))) + if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) ; // no responses yet break; #endif @@ -4456,6 +4475,9 @@ void rxvt_term::tt_write (const char *data, unsigned int len) { + if (pty.pty < 0) + return; + if (v_buflen == 0) { ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE));