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.194 by root, Mon Feb 14 10:44:50 2005 UTC vs.
Revision 1.202 by root, Sat Mar 12 23:35:14 2005 UTC

25 * - extensive modifications 25 * - extensive modifications
26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> 26 * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org>
27 * Copyright (c) 2001 Marius Gedminas 27 * Copyright (c) 2001 Marius Gedminas
28 * - Ctrl/Mod4+Tab works like Meta+Tab (options) 28 * - Ctrl/Mod4+Tab works like Meta+Tab (options)
29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> 29 * Copyright (c) 2003 Rob McMullen <robm@flipturn.org>
30 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 30 * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com>
31 * 31 *
32 * This program is free software; you can redistribute it and/or modify 32 * This program is free software; you can redistribute it and/or modify
33 * it under the terms of the GNU General Public License as published by 33 * it under the terms of the GNU General Public License as published by
34 * the Free Software Foundation; either version 2 of the License, or 34 * the Free Software Foundation; either version 2 of the License, or
35 * (at your option) any later version. 35 * (at your option) any later version.
117 XK_Escape, 0x238b, 117 XK_Escape, 0x238b,
118 XK_Undo, 0x238c, 118 XK_Undo, 0x238c,
119 XK_Print, 0x2399, 119 XK_Print, 0x2399,
120 120
121 XK_space, 0x2423, 121 XK_space, 0x2423,
122
123#ifdef XK_KP_Begin
124 XK_KP_Prior, 0x21de,
125 XK_KP_Next, 0x21df,
126 XK_KP_Begin, 0x2320,
127 XK_KP_Insert, 0x2380,
128 XK_KP_Delete, 0x2326,
122 XK_KP_Space, 0x2422, 129 XK_KP_Space, 0x2422,
130#endif
123 0, 131 0,
124}; 132};
125 133
126void 134void
127rxvt_term::iso14755_54 (int x, int y) 135rxvt_term::iso14755_54 (int x, int y)
276 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an 284 * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an
277 * escape sequence to toggle the Keypad. 285 * escape sequence to toggle the Keypad.
278 * 286 *
279 * Always permit `shift' to override the current setting 287 * Always permit `shift' to override the current setting
280 */ 288 */
281 shft = (ev.state & ShiftMask); 289 shft = ev.state & ShiftMask;
282 ctrl = (ev.state & ControlMask); 290 ctrl = ev.state & ControlMask;
283 meta = (ev.state & ModMetaMask); 291 meta = ev.state & ModMetaMask;
284 292
285 if (numlock_state || (ev.state & ModNumLockMask)) 293 if (numlock_state || (ev.state & ModNumLockMask))
286 { 294 {
287 numlock_state = (ev.state & ModNumLockMask); 295 numlock_state = (ev.state & ModNumLockMask);
288 PrivMode ((!numlock_state), PrivMode_aplKP); 296 PrivMode ((!numlock_state), PrivMode_aplKP);
308 316
309 // the XOpenIM manpage lies about hardcoding the locale 317 // the XOpenIM manpage lies about hardcoding the locale
310 // at the point of XOpenIM, so temporarily switch locales 318 // at the point of XOpenIM, so temporarily switch locales
311 if (rs[Rs_imLocale]) 319 if (rs[Rs_imLocale])
312 SET_LOCALE (rs[Rs_imLocale]); 320 SET_LOCALE (rs[Rs_imLocale]);
321
313 // assume wchar_t == unicode or better 322 // assume wchar_t == unicode or better
314 len = XwcLookupString (Input_Context, &ev, wkbuf, 323 len = XwcLookupString (Input_Context, &ev, wkbuf,
315 KBUFSZ, &keysym, &status_return); 324 KBUFSZ, &keysym, &status_return);
325
316 if (rs[Rs_imLocale]) 326 if (rs[Rs_imLocale])
317 SET_LOCALE (locale); 327 SET_LOCALE (locale);
318 328
319 if (status_return == XLookupChars 329 if (status_return == XLookupChars
320 || status_return == XLookupBoth) 330 || status_return == XLookupBoth)
512 else 522 else
513 strcpy (kbuf, key_backspace); 523 strcpy (kbuf, key_backspace);
514 break; 524 break;
515#endif 525#endif
516#ifndef NO_DELETE_KEY 526#ifndef NO_DELETE_KEY
527# ifdef XK_KP_Prior
528 case XK_KP_Delete:
529 /* allow shift to override */
530 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
531 {
532 strcpy (kbuf, "\033On");
533 break;
534 }
535 /* FALLTHROUGH */
536# endif
517 case XK_Delete: 537 case XK_Delete:
518 strcpy (kbuf, key_delete); 538 strcpy (kbuf, key_delete);
519 break; 539 break;
520#endif 540#endif
521 case XK_Tab: 541 case XK_Tab:
624#ifdef XK_KP_Begin 644#ifdef XK_KP_Begin
625 case XK_KP_Begin: 645 case XK_KP_Begin:
626 strcpy (kbuf, "\033Ou"); 646 strcpy (kbuf, "\033Ou");
627 break; 647 break;
628 648
629 case XK_KP_Insert:
630 strcpy (kbuf, "\033Op");
631 break;
632
633 case XK_KP_Delete:
634 strcpy (kbuf, "\033On");
635 break;
636#endif 649#endif
637 case XK_KP_F1: /* "\033OP" */ 650 case XK_KP_F1: /* "\033OP" */
638 case XK_KP_F2: /* "\033OQ" */ 651 case XK_KP_F2: /* "\033OQ" */
639 case XK_KP_F3: /* "\033OR" */ 652 case XK_KP_F3: /* "\033OR" */
640 case XK_KP_F4: /* "\033OS" */ 653 case XK_KP_F4: /* "\033OS" */
672 break; 685 break;
673 686
674 case XK_Find: 687 case XK_Find:
675 strcpy (kbuf, "\033[1~"); 688 strcpy (kbuf, "\033[1~");
676 break; 689 break;
690
691#ifdef XK_KP_End
692 case XK_KP_Insert:
693 /* allow shift to override */
694 if ((priv_modes & PrivMode_aplKP) ? !shft : shft)
695 {
696 strcpy (kbuf, "\033Op");
697 break;
698 }
699 /* FALLTHROUGH */
700#endif
677 case XK_Insert: 701 case XK_Insert:
678 strcpy (kbuf, "\033[2~"); 702 strcpy (kbuf, "\033[2~");
679 break; 703 break;
680#ifdef DXK_Remove /* support for DEC remove like key */ 704#ifdef DXK_Remove /* support for DEC remove like key */
681 case DXK_Remove: 705 case DXK_Remove:
1308 button_release (ev.xbutton); 1332 button_release (ev.xbutton);
1309 break; 1333 break;
1310 1334
1311 case ClientMessage: 1335 case ClientMessage:
1312 if (ev.xclient.format == 32 1336 if (ev.xclient.format == 32
1337 && ev.xclient.message_type == xa[XA_WM_PROTOCOLS])
1338 {
1313 && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) 1339 if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW])
1314 destroy (); 1340 destroy ();
1341#if ENABLE_EWMH
1342 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING])
1343 XSendEvent (disp, ev.xclient.window = display->root,
1344 False, SubstructureRedirectMask | SubstructureNotifyMask,
1345 &ev);
1346#endif
1347 }
1348#if ENABLE_XEMBED
1349 else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED])
1350 {
1351 if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN)
1352 focus_in ();
1353 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1354 focus_out ();
1355 }
1356#endif
1315#ifdef OFFIX_DND 1357#ifdef OFFIX_DND
1316 /* OffiX Dnd (drag 'n' drop) protocol */ 1358 /* OffiX Dnd (drag 'n' drop) protocol */
1317 else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] 1359 else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
1318 && (ev.xclient.data.l[0] == DndFile 1360 && (ev.xclient.data.l[0] == DndFile
1319 || ev.xclient.data.l[0] == DndDir 1361 || ev.xclient.data.l[0] == DndDir
1320 || ev.xclient.data.l[0] == DndLink)) 1362 || ev.xclient.data.l[0] == DndLink))
1321 { 1363 {
1322 /* Get Dnd data */ 1364 /* Get Dnd data */
1323 Atom ActualType; 1365 Atom ActualType;
1324 int ActualFormat; 1366 int ActualFormat;
1325 unsigned char *data; 1367 unsigned char *data;
1368 break; 1410 break;
1369 } 1411 }
1370 break; 1412 break;
1371 1413
1372 case FocusIn: 1414 case FocusIn:
1373 if (!TermWin.focus) 1415 focus_in ();
1374 {
1375 TermWin.focus = 1;
1376 want_refresh = 1;
1377#ifdef USE_XIM
1378 if (Input_Context != NULL)
1379 {
1380 IMSetStatusPosition ();
1381 XSetICFocus (Input_Context);
1382 }
1383#endif
1384#ifdef CURSOR_BLINK
1385 if (options & Opt_cursorBlink)
1386 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1387#endif
1388#ifdef OFF_FOCUS_FADING
1389 if (rs[Rs_fade])
1390 {
1391 pix_colors = pix_colors_focused;
1392 scr_recolour ();
1393 }
1394#endif
1395
1396 }
1397 break; 1416 break;
1398 1417
1399 case FocusOut: 1418 case FocusOut:
1400 if (TermWin.focus) 1419 focus_out ();
1401 {
1402 TermWin.focus = 0;
1403 want_refresh = 1;
1404
1405#if ENABLE_FRILLS || ISO_14755
1406 iso14755buf = 0;
1407#endif
1408#if ENABLE_OVERLAY
1409 scr_overlay_off ();
1410#endif
1411#ifdef USE_XIM
1412 if (Input_Context != NULL)
1413 XUnsetICFocus (Input_Context);
1414#endif
1415#ifdef CURSOR_BLINK
1416 if (options & Opt_cursorBlink)
1417 cursor_blink_ev.stop ();
1418 hidden_cursor = 0;
1419#endif
1420#ifdef OFF_FOCUS_FADING
1421 if (rs[Rs_fade])
1422 {
1423 pix_colors = pix_colors_unfocused;
1424 scr_recolour ();
1425 }
1426#endif
1427 }
1428 break; 1420 break;
1429 1421
1430 case ConfigureNotify: 1422 case ConfigureNotify:
1431 if (ev.xconfigure.window == TermWin.parent[0]) 1423 if (ev.xconfigure.window == TermWin.parent[0])
1432 { 1424 {
1646 scr_refresh (refresh_type); 1638 scr_refresh (refresh_type);
1647 refresh_limit = 0; 1639 refresh_limit = 0;
1648 scrollbar_show (1); 1640 scrollbar_show (1);
1649 } 1641 }
1650 break; 1642 break;
1643 }
1644}
1645
1646void
1647rxvt_term::focus_in ()
1648{
1649 if (!TermWin.focus)
1650 {
1651 TermWin.focus = 1;
1652 want_refresh = 1;
1653#ifdef USE_XIM
1654 if (Input_Context != NULL)
1655 {
1656 IMSetStatusPosition ();
1657 XSetICFocus (Input_Context);
1658 }
1659#endif
1660#ifdef CURSOR_BLINK
1661 if (options & Opt_cursorBlink)
1662 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1663#endif
1664#ifdef OFF_FOCUS_FADING
1665 if (rs[Rs_fade])
1666 {
1667 pix_colors = pix_colors_focused;
1668 scr_recolour ();
1669 }
1670#endif
1671 }
1672}
1673
1674void
1675rxvt_term::focus_out ()
1676{
1677 if (TermWin.focus)
1678 {
1679 TermWin.focus = 0;
1680 want_refresh = 1;
1681
1682#if ENABLE_FRILLS || ISO_14755
1683 iso14755buf = 0;
1684#endif
1685#if ENABLE_OVERLAY
1686 scr_overlay_off ();
1687#endif
1688#ifdef USE_XIM
1689 if (Input_Context != NULL)
1690 XUnsetICFocus (Input_Context);
1691#endif
1692#ifdef CURSOR_BLINK
1693 if (options & Opt_cursorBlink)
1694 cursor_blink_ev.stop ();
1695 hidden_cursor = 0;
1696#endif
1697#ifdef OFF_FOCUS_FADING
1698 if (rs[Rs_fade])
1699 {
1700 pix_colors = pix_colors_unfocused;
1701 scr_recolour ();
1702 }
1703#endif
1651 } 1704 }
1652} 1705}
1653 1706
1654#if TRANSPARENT 1707#if TRANSPARENT
1655void 1708void
2580 // some window managers resize the window early, and these programs 2633 // some window managers resize the window early, and these programs
2581 // then sometimes get the size wrong. 2634 // then sometimes get the size wrong.
2582 // unfortunately other programs are even more buggy and dislike 2635 // unfortunately other programs are even more buggy and dislike
2583 // being sent SIGWINCH, so only do it when we were in fact being 2636 // being sent SIGWINCH, so only do it when we were in fact being
2584 // resized. 2637 // resized.
2585 if (seen_resize) 2638 if (seen_resize && cmd_pid)
2586 kill (-cmd_pid, SIGWINCH); 2639 kill (-cmd_pid, SIGWINCH);
2587 } 2640 }
2588 2641
2589 /* Read a text string from the input buffer */ 2642 /* Read a text string from the input buffer */
2590 unicode_t buf[UBUFSIZ]; 2643 unicode_t buf[UBUFSIZ];
3537 else if (ch < 0x20) 3590 else if (ch < 0x20)
3538 return NULL; /* other control character - exit */ 3591 return NULL; /* other control character - exit */
3539 3592
3540 seen_esc = false; 3593 seen_esc = false;
3541 3594
3542 if (n >= sizeof (string) - 1) 3595 if (n >= STRING_MAX - 1)
3543 // stop at some sane length 3596 // stop at some sane length
3544 return NULL; 3597 return NULL;
3545 3598
3546 if (ch == C0_SYN) 3599 if (ch == C0_SYN)
3547 string[n++] = cmd_get8 (); 3600 string[n++] = cmd_get8 ();
3615 set_window_color (color, str); 3668 set_window_color (color, str);
3616} 3669}
3617 3670
3618/* 3671/*
3619 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3672 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3620 * 0 = change iconName/title
3621 * 1 = change iconName
3622 * 2 = change title
3623 * 4 = change color
3624 * 10 = change fg color
3625 * 11 = change bg color
3626 * 12 = change text color
3627 * 13 = change mouse foreground color
3628 * 17 = change highlight character colour
3629 * 18 = change bold character color
3630 * 19 = change underlined character color
3631 * 46 = change logfile (not implemented)
3632 * 50 = change font
3633 *
3634 * rxvt extensions:
3635 * 20 = bg pixmap
3636 * 39 = change default fg color
3637 * 49 = change default bg color
3638 * 55 = dump scrollback buffer and all of screen
3639 * 701 = change locale
3640 * 702 = find font
3641 * 703 = menu
3642 */ 3673 */
3643void 3674void
3644rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) 3675rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
3645{ 3676{
3646 int changed = 0; 3677 int changed = 0;
3745 break; 3776 break;
3746#ifndef NO_BOLD_UNDERLINE_REVERSE 3777#ifndef NO_BOLD_UNDERLINE_REVERSE
3747 case XTerm_Color_BD: 3778 case XTerm_Color_BD:
3748 process_color_seq (XTerm_Color_BD, Color_BD, str, resp); 3779 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3749 break; 3780 break;
3750 case XTerm_Color_IT:
3751 process_color_seq (XTerm_Color_IT, Color_IT, str, resp);
3752 break;
3753 case XTerm_Color_UL: 3781 case XTerm_Color_UL:
3754 process_color_seq (XTerm_Color_UL, Color_UL, str, resp); 3782 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3755 break; 3783 break;
3756 case XTerm_Color_RV: 3784 case XTerm_Color_RV:
3757 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3785 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3758 break; 3786 break;
3787 case URxvt_Color_IT:
3788 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3789 break;
3759#endif 3790#endif
3760#if TRANSPARENT && TINTING 3791#if TRANSPARENT && TINTING
3761 case XTerm_Color_tint: 3792 case URxvt_Color_tint:
3762 process_color_seq (XTerm_Color_tint, Color_tint, str, resp); 3793 process_color_seq (URxvt_Color_tint, Color_tint, str, resp);
3763 check_our_parents (); 3794 check_our_parents ();
3764 if (am_transparent) 3795 if (am_transparent)
3765 want_full_refresh = want_refresh = 1; 3796 want_full_refresh = want_refresh = 1;
3766 break; 3797 break;
3767#endif 3798#endif
3801 3832
3802 case XTerm_logfile: 3833 case XTerm_logfile:
3803 // TODO, when secure mode? 3834 // TODO, when secure mode?
3804 break; 3835 break;
3805 3836
3837#ifdef MENUBAR
3838 case URxvt_Menu:
3839 if (options & Opt_insecure)
3840 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3841 break;
3842#endif
3843#if 0
3844 case XTerm_dumpscreen: /* no error notices */
3845 {
3846 int fd;
3847 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3848 {
3849 scr_dump (fd);
3850 close (fd);
3851 }
3852 }
3853 break;
3854#endif
3806 case XTerm_font: 3855 case XTerm_font:
3807 op = URxvt_font; 3856 op = URxvt_font;
3808 case URxvt_font: 3857 case URxvt_font:
3809#if ENABLE_STYLES 3858#if ENABLE_STYLES
3810 case URxvt_boldFont: 3859 case URxvt_boldFont:
3825 set_fonts (); 3874 set_fonts ();
3826 } 3875 }
3827 break; 3876 break;
3828 3877
3829#if ENABLE_FRILLS 3878#if ENABLE_FRILLS
3830 case XTerm_locale: 3879 case URxvt_locale:
3831 if (query) 3880 if (query)
3832 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); 3881 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp);
3833 else 3882 else
3834 { 3883 {
3835 set_locale (str); 3884 set_locale (str);
3836 pty.set_utf8_mode (enc_utf8); 3885 pty.set_utf8_mode (enc_utf8);
3837# ifdef USE_XIM
3838 im_cb (); 3886 init_xlocale ();
3839# endif
3840 } 3887 }
3841 break; 3888 break;
3842#endif
3843 3889
3844#ifdef MENUBAR 3890 case URxvt_view_up:
3845 case XTerm_Menu: 3891 case URxvt_view_down:
3846 if (options & Opt_insecure) 3892 int lines = atoi (str);
3847 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked 3893
3848 break; 3894 if (lines)
3849#endif 3895 scr_page (op == URxvt_view_up ? UP : DN, lines);
3850#if 0
3851 case XTerm_dumpscreen: /* no error notices */
3852 { 3896 else
3853 int fd;
3854 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3855 { 3897 {
3856 scr_dump (fd); 3898 scr_erase_savelines ();
3857 close (fd);
3858 } 3899 }
3859 } 3900
3860 break; 3901 break;
3861#endif 3902#endif
3862 } 3903 }
3863} 3904}
3864/*----------------------------------------------------------------------*/ 3905/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines