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.197 by root, Thu Feb 17 15:07:48 2005 UTC vs.
Revision 1.206 by root, Thu Aug 11 02:05:07 2005 UTC

163void 163void
164rxvt_term::iso14755_51 (unicode_t ch, rend_t r) 164rxvt_term::iso14755_51 (unicode_t ch, rend_t r)
165{ 165{
166 rxvt_fontset *fs = FONTSET (r); 166 rxvt_fontset *fs = FONTSET (r);
167 rxvt_font *f = (*fs)[fs->find_font (ch)]; 167 rxvt_font *f = (*fs)[fs->find_font (ch)];
168 wchar_t *chr, *alloc, ch2; 168 wchar_t *chr, *alloc, ch2, *fname;
169 int len; 169 int len;
170
171 fname = rxvt_utf8towcs (f->name);
170 172
171#if ENABLE_COMBINING 173#if ENABLE_COMBINING
172 if (IS_COMPOSE (ch)) 174 if (IS_COMPOSE (ch))
173 { 175 {
174 len = rxvt_composite.expand (ch, 0); 176 len = rxvt_composite.expand (ch, 0);
183 alloc = 0; 185 alloc = 0;
184 chr = &ch2; 186 chr = &ch2;
185 len = 1; 187 len = 1;
186 } 188 }
187 189
188 int width = strlen (f->name); 190 int width = wcswidth (fname, wcslen (fname));
189 191
190 scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); 192 scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1);
191 193
192 r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); 194 r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r));
193 195
206#endif 208#endif
207 scr_overlay_set (11, y, ch, r); 209 scr_overlay_set (11, y, ch, r);
208 scr_overlay_set (12, y, NOCHAR, r); 210 scr_overlay_set (12, y, NOCHAR, r);
209 } 211 }
210 212
211 scr_overlay_set (0, len, f->name); 213 scr_overlay_set (0, len, fname);
214
215 free (fname);
212 216
213#if ENABLE_COMBINING 217#if ENABLE_COMBINING
214 if (alloc) 218 if (alloc)
215 delete [] alloc; 219 delete [] alloc;
216#endif 220#endif
316 320
317 // the XOpenIM manpage lies about hardcoding the locale 321 // the XOpenIM manpage lies about hardcoding the locale
318 // at the point of XOpenIM, so temporarily switch locales 322 // at the point of XOpenIM, so temporarily switch locales
319 if (rs[Rs_imLocale]) 323 if (rs[Rs_imLocale])
320 SET_LOCALE (rs[Rs_imLocale]); 324 SET_LOCALE (rs[Rs_imLocale]);
325
321 // assume wchar_t == unicode or better 326 // assume wchar_t == unicode or better
322 len = XwcLookupString (Input_Context, &ev, wkbuf, 327 len = XwcLookupString (Input_Context, &ev, wkbuf,
323 KBUFSZ, &keysym, &status_return); 328 KBUFSZ, &keysym, &status_return);
329
324 if (rs[Rs_imLocale]) 330 if (rs[Rs_imLocale])
325 SET_LOCALE (locale); 331 SET_LOCALE (locale);
326 332
327 if (status_return == XLookupChars 333 if (status_return == XLookupChars
328 || status_return == XLookupBoth) 334 || status_return == XLookupBoth)
1330 button_release (ev.xbutton); 1336 button_release (ev.xbutton);
1331 break; 1337 break;
1332 1338
1333 case ClientMessage: 1339 case ClientMessage:
1334 if (ev.xclient.format == 32 1340 if (ev.xclient.format == 32
1341 && ev.xclient.message_type == xa[XA_WM_PROTOCOLS])
1342 {
1335 && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) 1343 if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW])
1336 destroy (); 1344 destroy ();
1345#if ENABLE_EWMH
1346 else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING])
1347 XSendEvent (disp, ev.xclient.window = display->root,
1348 False, SubstructureRedirectMask | SubstructureNotifyMask,
1349 &ev);
1350#endif
1351 }
1352#if ENABLE_XEMBED
1353 else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED])
1354 {
1355 if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN)
1356 focus_in ();
1357 else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT)
1358 focus_out ();
1359 }
1360#endif
1337#ifdef OFFIX_DND 1361#ifdef OFFIX_DND
1338 /* OffiX Dnd (drag 'n' drop) protocol */ 1362 /* OffiX Dnd (drag 'n' drop) protocol */
1339 else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] 1363 else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL]
1340 && (ev.xclient.data.l[0] == DndFile 1364 && (ev.xclient.data.l[0] == DndFile
1341 || ev.xclient.data.l[0] == DndDir 1365 || ev.xclient.data.l[0] == DndDir
1342 || ev.xclient.data.l[0] == DndLink)) 1366 || ev.xclient.data.l[0] == DndLink))
1343 { 1367 {
1344 /* Get Dnd data */ 1368 /* Get Dnd data */
1345 Atom ActualType; 1369 Atom ActualType;
1346 int ActualFormat; 1370 int ActualFormat;
1347 unsigned char *data; 1371 unsigned char *data;
1390 break; 1414 break;
1391 } 1415 }
1392 break; 1416 break;
1393 1417
1394 case FocusIn: 1418 case FocusIn:
1395 if (!TermWin.focus) 1419 focus_in ();
1396 {
1397 TermWin.focus = 1;
1398 want_refresh = 1;
1399#ifdef USE_XIM
1400 if (Input_Context != NULL)
1401 {
1402 IMSetStatusPosition ();
1403 XSetICFocus (Input_Context);
1404 }
1405#endif
1406#ifdef CURSOR_BLINK
1407 if (options & Opt_cursorBlink)
1408 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1409#endif
1410#ifdef OFF_FOCUS_FADING
1411 if (rs[Rs_fade])
1412 {
1413 pix_colors = pix_colors_focused;
1414 scr_recolour ();
1415 }
1416#endif
1417
1418 }
1419 break; 1420 break;
1420 1421
1421 case FocusOut: 1422 case FocusOut:
1422 if (TermWin.focus) 1423 focus_out ();
1423 {
1424 TermWin.focus = 0;
1425 want_refresh = 1;
1426
1427#if ENABLE_FRILLS || ISO_14755
1428 iso14755buf = 0;
1429#endif
1430#if ENABLE_OVERLAY
1431 scr_overlay_off ();
1432#endif
1433#ifdef USE_XIM
1434 if (Input_Context != NULL)
1435 XUnsetICFocus (Input_Context);
1436#endif
1437#ifdef CURSOR_BLINK
1438 if (options & Opt_cursorBlink)
1439 cursor_blink_ev.stop ();
1440 hidden_cursor = 0;
1441#endif
1442#ifdef OFF_FOCUS_FADING
1443 if (rs[Rs_fade])
1444 {
1445 pix_colors = pix_colors_unfocused;
1446 scr_recolour ();
1447 }
1448#endif
1449 }
1450 break; 1424 break;
1451 1425
1452 case ConfigureNotify: 1426 case ConfigureNotify:
1453 if (ev.xconfigure.window == TermWin.parent[0]) 1427 if (ev.xconfigure.window == TermWin.parent[0])
1454 { 1428 {
1668 scr_refresh (refresh_type); 1642 scr_refresh (refresh_type);
1669 refresh_limit = 0; 1643 refresh_limit = 0;
1670 scrollbar_show (1); 1644 scrollbar_show (1);
1671 } 1645 }
1672 break; 1646 break;
1647 }
1648}
1649
1650void
1651rxvt_term::focus_in ()
1652{
1653 if (!TermWin.focus)
1654 {
1655 TermWin.focus = 1;
1656 want_refresh = 1;
1657#if USE_XIM
1658 if (Input_Context != NULL)
1659 {
1660 IMSetStatusPosition ();
1661 XSetICFocus (Input_Context);
1662 }
1663#endif
1664#if CURSOR_BLINK
1665 if (options & Opt_cursorBlink)
1666 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1667#endif
1668#if OFF_FOCUS_FADING
1669 if (rs[Rs_fade])
1670 {
1671 pix_colors = pix_colors_focused;
1672 scr_recolour ();
1673 }
1674#endif
1675 }
1676}
1677
1678void
1679rxvt_term::focus_out ()
1680{
1681 if (TermWin.focus)
1682 {
1683 TermWin.focus = 0;
1684 want_refresh = 1;
1685
1686#if ENABLE_FRILLS || ISO_14755
1687 iso14755buf = 0;
1688#endif
1689#if ENABLE_OVERLAY
1690 scr_overlay_off ();
1691#endif
1692#if USE_XIM
1693 if (Input_Context != NULL)
1694 XUnsetICFocus (Input_Context);
1695#endif
1696#if CURSOR_BLINK
1697 if (options & Opt_cursorBlink)
1698 cursor_blink_ev.stop ();
1699 hidden_cursor = 0;
1700#endif
1701#if OFF_FOCUS_FADING
1702 if (rs[Rs_fade])
1703 {
1704 pix_colors = pix_colors_unfocused;
1705 scr_recolour ();
1706 }
1707#endif
1673 } 1708 }
1674} 1709}
1675 1710
1676#if TRANSPARENT 1711#if TRANSPARENT
1677void 1712void
2611 /* Read a text string from the input buffer */ 2646 /* Read a text string from the input buffer */
2612 unicode_t buf[UBUFSIZ]; 2647 unicode_t buf[UBUFSIZ];
2613 bool refreshnow = false; 2648 bool refreshnow = false;
2614 int nlines = 0; 2649 int nlines = 0;
2615 unicode_t *str = buf; 2650 unicode_t *str = buf;
2651 unicode_t *eol = str + min (TermWin.ncol, UBUFSIZ);
2616 2652
2617 for (;;) 2653 for (;;)
2618 { 2654 {
2619 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2655 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2620 break; 2656 break;
2621 2657
2622 *str++ = ch; 2658 *str++ = ch;
2623 2659
2624 if (ch == C0_LF) 2660 if (ch == C0_LF || str >= eol)
2625 { 2661 {
2662 if (ch == C0_LF)
2626 nlines++; 2663 nlines++;
2664
2627 refresh_count++; 2665 refresh_count++;
2628 2666
2629 if (!(options & Opt_jumpScroll) 2667 if (!(options & Opt_jumpScroll)
2630 || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) 2668 || (refresh_count >= refresh_limit * (TermWin.nrow - 1)))
2631 { 2669 {
2638 if (nlines >= TermWin.nrow - 1) 2676 if (nlines >= TermWin.nrow - 1)
2639 { 2677 {
2640 scr_add_lines (buf, nlines, str - buf); 2678 scr_add_lines (buf, nlines, str - buf);
2641 nlines = 0; 2679 nlines = 0;
2642 str = buf; 2680 str = buf;
2681 eol = str + min (TermWin.ncol, UBUFSIZ);
2643 } 2682 }
2644 }
2645 2683
2646 if (str >= buf + UBUFSIZ) 2684 if (str >= eol)
2647 { 2685 {
2686 if (eol >= buf + UBUFSIZ)
2687 {
2648 ch = NOCHAR; 2688 ch = NOCHAR;
2649 break; 2689 break;
2690 }
2691 else
2692 eol = min (eol + TermWin.ncol, buf + UBUFSIZ);
2693 }
2694
2650 } 2695 }
2651 2696
2652 seq_begin = cmdbuf_ptr; 2697 seq_begin = cmdbuf_ptr;
2653 ch = next_char (); 2698 ch = next_char ();
2654 } 2699 }
3559 else if (ch < 0x20) 3604 else if (ch < 0x20)
3560 return NULL; /* other control character - exit */ 3605 return NULL; /* other control character - exit */
3561 3606
3562 seen_esc = false; 3607 seen_esc = false;
3563 3608
3564 if (n >= sizeof (string) - 1) 3609 if (n >= STRING_MAX - 1)
3565 // stop at some sane length 3610 // stop at some sane length
3566 return NULL; 3611 return NULL;
3567 3612
3568 if (ch == C0_SYN) 3613 if (ch == C0_SYN)
3569 string[n++] = cmd_get8 (); 3614 string[n++] = cmd_get8 ();
3637 set_window_color (color, str); 3682 set_window_color (color, str);
3638} 3683}
3639 3684
3640/* 3685/*
3641 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3686 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3642 * 0 = change iconName/title
3643 * 1 = change iconName
3644 * 2 = change title
3645 * 4 = change color
3646 * 10 = change fg color
3647 * 11 = change bg color
3648 * 12 = change text color
3649 * 13 = change mouse foreground color
3650 * 17 = change highlight character colour
3651 * 18 = change bold character color
3652 * 19 = change underlined character color
3653 * 46 = change logfile (not implemented)
3654 * 50 = change font
3655 *
3656 * rxvt extensions:
3657 * 20 = bg pixmap
3658 * 39 = change default fg color
3659 * 49 = change default bg color
3660 * 55 = dump scrollback buffer and all of screen
3661 * 701 = change locale
3662 * 702 = find font
3663 * 703 = menu
3664 */ 3687 */
3665void 3688void
3666rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) 3689rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
3667{ 3690{
3668 int changed = 0; 3691 int changed = 0;
3767 break; 3790 break;
3768#ifndef NO_BOLD_UNDERLINE_REVERSE 3791#ifndef NO_BOLD_UNDERLINE_REVERSE
3769 case XTerm_Color_BD: 3792 case XTerm_Color_BD:
3770 process_color_seq (XTerm_Color_BD, Color_BD, str, resp); 3793 process_color_seq (XTerm_Color_BD, Color_BD, str, resp);
3771 break; 3794 break;
3772 case XTerm_Color_IT:
3773 process_color_seq (XTerm_Color_IT, Color_IT, str, resp);
3774 break;
3775 case XTerm_Color_UL: 3795 case XTerm_Color_UL:
3776 process_color_seq (XTerm_Color_UL, Color_UL, str, resp); 3796 process_color_seq (XTerm_Color_UL, Color_UL, str, resp);
3777 break; 3797 break;
3778 case XTerm_Color_RV: 3798 case XTerm_Color_RV:
3779 process_color_seq (XTerm_Color_RV, Color_RV, str, resp); 3799 process_color_seq (XTerm_Color_RV, Color_RV, str, resp);
3780 break; 3800 break;
3801 case URxvt_Color_IT:
3802 process_color_seq (URxvt_Color_IT, Color_IT, str, resp);
3803 break;
3781#endif 3804#endif
3782#if TRANSPARENT && TINTING 3805#if TRANSPARENT && TINTING
3783 case XTerm_Color_tint: 3806 case URxvt_Color_tint:
3784 process_color_seq (XTerm_Color_tint, Color_tint, str, resp); 3807 process_color_seq (URxvt_Color_tint, Color_tint, str, resp);
3785 check_our_parents (); 3808 check_our_parents ();
3786 if (am_transparent) 3809 if (am_transparent)
3787 want_full_refresh = want_refresh = 1; 3810 want_full_refresh = want_refresh = 1;
3788 break; 3811 break;
3789#endif 3812#endif
3823 3846
3824 case XTerm_logfile: 3847 case XTerm_logfile:
3825 // TODO, when secure mode? 3848 // TODO, when secure mode?
3826 break; 3849 break;
3827 3850
3851#ifdef MENUBAR
3852 case URxvt_Menu:
3853 if (options & Opt_insecure)
3854 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked
3855 break;
3856#endif
3857#if 0
3858 case XTerm_dumpscreen: /* no error notices */
3859 {
3860 int fd;
3861 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3862 {
3863 scr_dump (fd);
3864 close (fd);
3865 }
3866 }
3867 break;
3868#endif
3828 case XTerm_font: 3869 case XTerm_font:
3829 op = URxvt_font; 3870 op = URxvt_font;
3830 case URxvt_font: 3871 case URxvt_font:
3831#if ENABLE_STYLES 3872#if ENABLE_STYLES
3832 case URxvt_boldFont: 3873 case URxvt_boldFont:
3847 set_fonts (); 3888 set_fonts ();
3848 } 3889 }
3849 break; 3890 break;
3850 3891
3851#if ENABLE_FRILLS 3892#if ENABLE_FRILLS
3852 case XTerm_locale: 3893 case URxvt_locale:
3853 if (query) 3894 if (query)
3854 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); 3895 tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp);
3855 else 3896 else
3856 { 3897 {
3857 set_locale (str); 3898 set_locale (str);
3858 pty.set_utf8_mode (enc_utf8); 3899 pty.set_utf8_mode (enc_utf8);
3859# ifdef USE_XIM
3860 im_cb (); 3900 init_xlocale ();
3861# endif
3862 } 3901 }
3863 break; 3902 break;
3864#endif
3865 3903
3866#ifdef MENUBAR 3904 case URxvt_view_up:
3867 case XTerm_Menu: 3905 case URxvt_view_down:
3868 if (options & Opt_insecure) 3906 int lines = atoi (str);
3869 menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked 3907
3870 break; 3908 if (lines)
3871#endif 3909 scr_page (op == URxvt_view_up ? UP : DN, lines);
3872#if 0
3873 case XTerm_dumpscreen: /* no error notices */
3874 { 3910 else
3875 int fd;
3876 if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0)
3877 { 3911 {
3878 scr_dump (fd); 3912 scr_erase_savelines ();
3879 close (fd);
3880 } 3913 }
3881 } 3914
3882 break; 3915 break;
3883#endif 3916#endif
3884 } 3917 }
3885} 3918}
3886/*----------------------------------------------------------------------*/ 3919/*----------------------------------------------------------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines