--- rxvt-unicode/src/command.C 2005/02/14 10:44:50 1.194 +++ rxvt-unicode/src/command.C 2005/07/13 02:47:02 1.204 @@ -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-2004 Marc Lehmann + * Copyright (c) 2003-2005 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 @@ -119,7 +119,15 @@ XK_Print, 0x2399, XK_space, 0x2423, + +#ifdef XK_KP_Begin + XK_KP_Prior, 0x21de, + XK_KP_Next, 0x21df, + XK_KP_Begin, 0x2320, + XK_KP_Insert, 0x2380, + XK_KP_Delete, 0x2326, XK_KP_Space, 0x2422, +#endif 0, }; @@ -157,9 +165,11 @@ { rxvt_fontset *fs = FONTSET (r); rxvt_font *f = (*fs)[fs->find_font (ch)]; - wchar_t *chr, *alloc, ch2; + wchar_t *chr, *alloc, ch2, *fname; int len; + fname = rxvt_utf8towcs (f->name); + #if ENABLE_COMBINING if (IS_COMPOSE (ch)) { @@ -177,7 +187,7 @@ len = 1; } - int width = strlen (f->name); + int width = wcswidth (fname, wcslen (fname)); scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); @@ -200,7 +210,9 @@ scr_overlay_set (12, y, NOCHAR, r); } - scr_overlay_set (0, len, f->name); + scr_overlay_set (0, len, fname); + + free (fname); #if ENABLE_COMBINING if (alloc) @@ -278,9 +290,9 @@ * * Always permit `shift' to override the current setting */ - shft = (ev.state & ShiftMask); - ctrl = (ev.state & ControlMask); - meta = (ev.state & ModMetaMask); + shft = ev.state & ShiftMask; + ctrl = ev.state & ControlMask; + meta = ev.state & ModMetaMask; if (numlock_state || (ev.state & ModNumLockMask)) { @@ -310,9 +322,11 @@ // at the point of XOpenIM, so temporarily switch locales if (rs[Rs_imLocale]) SET_LOCALE (rs[Rs_imLocale]); + // assume wchar_t == unicode or better len = XwcLookupString (Input_Context, &ev, wkbuf, KBUFSZ, &keysym, &status_return); + if (rs[Rs_imLocale]) SET_LOCALE (locale); @@ -514,6 +528,16 @@ break; #endif #ifndef NO_DELETE_KEY +# ifdef XK_KP_Prior + case XK_KP_Delete: + /* allow shift to override */ + if ((priv_modes & PrivMode_aplKP) ? !shft : shft) + { + strcpy (kbuf, "\033On"); + break; + } + /* FALLTHROUGH */ +# endif case XK_Delete: strcpy (kbuf, key_delete); break; @@ -626,13 +650,6 @@ strcpy (kbuf, "\033Ou"); break; - case XK_KP_Insert: - strcpy (kbuf, "\033Op"); - break; - - case XK_KP_Delete: - strcpy (kbuf, "\033On"); - break; #endif case XK_KP_F1: /* "\033OP" */ case XK_KP_F2: /* "\033OQ" */ @@ -674,6 +691,17 @@ case XK_Find: strcpy (kbuf, "\033[1~"); break; + +#ifdef XK_KP_End + case XK_KP_Insert: + /* allow shift to override */ + if ((priv_modes & PrivMode_aplKP) ? !shft : shft) + { + strcpy (kbuf, "\033Op"); + break; + } + /* FALLTHROUGH */ +#endif case XK_Insert: strcpy (kbuf, "\033[2~"); break; @@ -1310,14 +1338,32 @@ case ClientMessage: if (ev.xclient.format == 32 - && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) - destroy (); + && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) + { + if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) + destroy (); +#if ENABLE_EWMH + else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) + XSendEvent (disp, ev.xclient.window = display->root, + False, SubstructureRedirectMask | SubstructureNotifyMask, + &ev); +#endif + } +#if ENABLE_XEMBED + else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) + { + if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) + focus_in (); + else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) + focus_out (); + } +#endif #ifdef OFFIX_DND /* OffiX Dnd (drag 'n' drop) protocol */ - else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] - && (ev.xclient.data.l[0] == DndFile - || ev.xclient.data.l[0] == DndDir - || ev.xclient.data.l[0] == DndLink)) + else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] + && (ev.xclient.data.l[0] == DndFile + || ev.xclient.data.l[0] == DndDir + || ev.xclient.data.l[0] == DndLink)) { /* Get Dnd data */ Atom ActualType; @@ -1370,61 +1416,11 @@ break; case FocusIn: - if (!TermWin.focus) - { - TermWin.focus = 1; - want_refresh = 1; -#ifdef USE_XIM - if (Input_Context != NULL) - { - IMSetStatusPosition (); - XSetICFocus (Input_Context); - } -#endif -#ifdef CURSOR_BLINK - if (options & Opt_cursorBlink) - cursor_blink_ev.start (NOW + BLINK_INTERVAL); -#endif -#ifdef OFF_FOCUS_FADING - if (rs[Rs_fade]) - { - pix_colors = pix_colors_focused; - scr_recolour (); - } -#endif - - } + focus_in (); break; case FocusOut: - if (TermWin.focus) - { - TermWin.focus = 0; - want_refresh = 1; - -#if ENABLE_FRILLS || ISO_14755 - iso14755buf = 0; -#endif -#if ENABLE_OVERLAY - scr_overlay_off (); -#endif -#ifdef USE_XIM - if (Input_Context != NULL) - XUnsetICFocus (Input_Context); -#endif -#ifdef CURSOR_BLINK - if (options & Opt_cursorBlink) - cursor_blink_ev.stop (); - hidden_cursor = 0; -#endif -#ifdef OFF_FOCUS_FADING - if (rs[Rs_fade]) - { - pix_colors = pix_colors_unfocused; - scr_recolour (); - } -#endif - } + focus_out (); break; case ConfigureNotify: @@ -1651,6 +1647,67 @@ } } +void +rxvt_term::focus_in () +{ + if (!TermWin.focus) + { + TermWin.focus = 1; + want_refresh = 1; +#ifdef USE_XIM + if (Input_Context != NULL) + { + IMSetStatusPosition (); + XSetICFocus (Input_Context); + } +#endif +#ifdef CURSOR_BLINK + if (options & Opt_cursorBlink) + cursor_blink_ev.start (NOW + BLINK_INTERVAL); +#endif +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + pix_colors = pix_colors_focused; + scr_recolour (); + } +#endif + } +} + +void +rxvt_term::focus_out () +{ + if (TermWin.focus) + { + TermWin.focus = 0; + want_refresh = 1; + +#if ENABLE_FRILLS || ISO_14755 + iso14755buf = 0; +#endif +#if ENABLE_OVERLAY + scr_overlay_off (); +#endif +#ifdef USE_XIM + if (Input_Context != NULL) + XUnsetICFocus (Input_Context); +#endif +#ifdef CURSOR_BLINK + if (options & Opt_cursorBlink) + cursor_blink_ev.stop (); + hidden_cursor = 0; +#endif +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + pix_colors = pix_colors_unfocused; + scr_recolour (); + } +#endif + } +} + #if TRANSPARENT void rxvt_term::rootwin_cb (XEvent &ev) @@ -2582,7 +2639,7 @@ // unfortunately other programs are even more buggy and dislike // being sent SIGWINCH, so only do it when we were in fact being // resized. - if (seen_resize) + if (seen_resize && cmd_pid) kill (-cmd_pid, SIGWINCH); } @@ -2591,6 +2648,7 @@ bool refreshnow = false; int nlines = 0; unicode_t *str = buf; + unicode_t *eol = str + min (TermWin.ncol, UBUFSIZ); for (;;) { @@ -2599,7 +2657,7 @@ *str++ = ch; - if (ch == C0_LF) + if (ch == C0_LF || str >= eol) { nlines++; refresh_count++; @@ -2618,13 +2676,20 @@ scr_add_lines (buf, nlines, str - buf); nlines = 0; str = buf; + eol = str + min (TermWin.ncol, UBUFSIZ); + } + + if (str >= eol) + { + if (eol >= buf + UBUFSIZ) + { + ch = NOCHAR; + break; + } + else + eol = min (eol + TermWin.ncol, buf + UBUFSIZ); } - } - if (str >= buf + UBUFSIZ) - { - ch = NOCHAR; - break; } seq_begin = cmdbuf_ptr; @@ -3539,7 +3604,7 @@ seen_esc = false; - if (n >= sizeof (string) - 1) + if (n >= STRING_MAX - 1) // stop at some sane length return NULL; @@ -3617,28 +3682,6 @@ /* * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) - * 0 = change iconName/title - * 1 = change iconName - * 2 = change title - * 4 = change color - * 10 = change fg color - * 11 = change bg color - * 12 = change text color - * 13 = change mouse foreground color - * 17 = change highlight character colour - * 18 = change bold character color - * 19 = change underlined character color - * 46 = change logfile (not implemented) - * 50 = change font - * - * rxvt extensions: - * 20 = bg pixmap - * 39 = change default fg color - * 49 = change default bg color - * 55 = dump scrollback buffer and all of screen - * 701 = change locale - * 702 = find font - * 703 = menu */ void rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) @@ -3747,19 +3790,19 @@ case XTerm_Color_BD: process_color_seq (XTerm_Color_BD, Color_BD, str, resp); break; - case XTerm_Color_IT: - process_color_seq (XTerm_Color_IT, Color_IT, 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 URxvt_Color_IT: + process_color_seq (URxvt_Color_IT, Color_IT, str, resp); + break; #endif #if TRANSPARENT && TINTING - case XTerm_Color_tint: - process_color_seq (XTerm_Color_tint, Color_tint, str, resp); + case URxvt_Color_tint: + process_color_seq (URxvt_Color_tint, Color_tint, str, resp); check_our_parents (); if (am_transparent) want_full_refresh = want_refresh = 1; @@ -3803,6 +3846,24 @@ // TODO, when secure mode? break; +#ifdef MENUBAR + case URxvt_Menu: + if (options & Opt_insecure) + menubar_dispatch (const_cast(str)); // casting away constness is checked + break; +#endif +#if 0 + case XTerm_dumpscreen: /* no error notices */ + { + int fd; + if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) + { + scr_dump (fd); + close (fd); + } + } + break; +#endif case XTerm_font: op = URxvt_font; case URxvt_font: @@ -3827,36 +3888,28 @@ break; #if ENABLE_FRILLS - case XTerm_locale: + case URxvt_locale: if (query) - tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); + tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); else { set_locale (str); pty.set_utf8_mode (enc_utf8); -# ifdef USE_XIM - im_cb (); -# endif + init_xlocale (); } break; -#endif -#ifdef MENUBAR - case XTerm_Menu: - if (options & Opt_insecure) - menubar_dispatch (const_cast(str)); // casting away constness is checked - break; -#endif -#if 0 - case XTerm_dumpscreen: /* no error notices */ - { - int fd; - if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) - { - scr_dump (fd); - close (fd); - } - } + case URxvt_view_up: + case URxvt_view_down: + int lines = atoi (str); + + if (lines) + scr_page (op == URxvt_view_up ? UP : DN, lines); + else + { + scr_erase_savelines (); + } + break; #endif }