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.413 by ayin, Sun Feb 17 12:11:56 2008 UTC vs.
Revision 1.421 by root, Wed Oct 15 17:16:47 2008 UTC

1015 } 1015 }
1016 while (row < end_row); 1016 while (row < end_row);
1017 } 1017 }
1018 1018
1019 scr_refresh (); 1019 scr_refresh ();
1020 scrollbar_show (1); 1020 scrollBar.show (1);
1021#ifdef USE_XIM 1021#ifdef USE_XIM
1022 IMSendSpot (); 1022 IMSendSpot ();
1023#endif 1023#endif
1024 } 1024 }
1025 1025
1127 { 1127 {
1128 // this should really be sched_yield(), but the linux guys thought 1128 // this should really be sched_yield(), but the linux guys thought
1129 // that giving a process calling sched_yield () less cpu time than 1129 // that giving a process calling sched_yield () less cpu time than
1130 // ones with high nice levels is a useful thing to do. It surely is is 1130 // ones with high nice levels is a useful thing to do. It surely is is
1131 // allowed by the sus... as is returning ENOSYS. 1131 // allowed by the sus... as is returning ENOSYS.
1132 // since the linux guys additionally thought that breaking the only
1133 // known workaroudn against their unusable sched_yield hack is cool,
1134 // we just nanosleep a bit and hope for the best.
1132 1135
1133 struct timespec ts = { 0, 0 }; 1136 struct timespec ts = { 0, 1000 };
1134 nanosleep (&ts, 0); 1137 nanosleep (&ts, 0);
1135 1138
1136 w.stop (); 1139 w.stop ();
1137 } 1140 }
1138 1141
1536 ; 1539 ;
1537 1540
1538 if (scrollBar.state && ev.xany.window == scrollBar.win) 1541 if (scrollBar.state && ev.xany.window == scrollBar.win)
1539 { 1542 {
1540 scrollBar.state = STATE_IDLE; 1543 scrollBar.state = STATE_IDLE;
1541 scrollbar_show (0); 1544 scrollBar.show (0);
1542 } 1545 }
1543 } 1546 }
1544 break; 1547 break;
1545 1548
1546 case MotionNotify: 1549 case MotionNotify:
1647 &ev.xbutton.x, &ev.xbutton.y, 1650 &ev.xbutton.x, &ev.xbutton.y,
1648 &unused_mask); 1651 &unused_mask);
1649 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1652 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1650 scrollBar.size ()); 1653 scrollBar.size ());
1651 want_refresh = 1; 1654 want_refresh = 1;
1652 scrollbar_show (1); 1655 scrollBar.show (1);
1653 } 1656 }
1654 break; 1657 break;
1655 } 1658 }
1656 1659
1657#if defined(CURSOR_BLINK) 1660#if defined(CURSOR_BLINK)
1683 1686
1684 refresh_check (); 1687 refresh_check ();
1685} 1688}
1686 1689
1687void 1690void
1691rxvt_term::set_urgency (bool enable)
1692{
1693 if (enable == urgency_hint)
1694 return;
1695
1696 if (XWMHints *h = XGetWMHints (dpy, parent[0]))
1697 {
1698 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1699 XSetWMHints (dpy, parent[0], h);
1700 urgency_hint = enable;
1701 }
1702}
1703
1704void
1688rxvt_term::focus_in () 1705rxvt_term::focus_in ()
1689{ 1706{
1690 if (!focus) 1707 if (!focus)
1691 { 1708 {
1692 focus = 1; 1709 focus = 1;
1693 want_refresh = 1; 1710 want_refresh = 1;
1694
1695 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1696 1711
1697#if USE_XIM 1712#if USE_XIM
1698 if (Input_Context != NULL) 1713 if (Input_Context != NULL)
1699 { 1714 {
1700 IMSetPosition (); 1715 IMSetPosition ();
1712 scr_recolour (); 1727 scr_recolour ();
1713 } 1728 }
1714#endif 1729#endif
1715#if ENABLE_FRILLS 1730#if ENABLE_FRILLS
1716 if (option (Opt_urgentOnBell)) 1731 if (option (Opt_urgentOnBell))
1717 { 1732 set_urgency (0);
1718 if (XWMHints *h = XGetWMHints(dpy, parent[0]))
1719 {
1720 h->flags &= ~XUrgencyHint;
1721 XSetWMHints (dpy, parent[0], h);
1722 }
1723 }
1724#endif 1733#endif
1734
1735 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1725 } 1736 }
1726} 1737}
1727 1738
1728void 1739void
1729rxvt_term::focus_out () 1740rxvt_term::focus_out ()
1731 if (focus) 1742 if (focus)
1732 { 1743 {
1733 focus = 0; 1744 focus = 0;
1734 want_refresh = 1; 1745 want_refresh = 1;
1735 1746
1736 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1747#if ENABLE_FRILLS
1737 1748 if (option (Opt_urgentOnBell))
1749 set_urgency (0);
1750#endif
1738#if ENABLE_FRILLS || ISO_14755 1751#if ENABLE_FRILLS || ISO_14755
1739 if (iso14755buf) 1752 if (iso14755buf)
1740 { 1753 {
1741 iso14755buf = 0; 1754 iso14755buf = 0;
1742# if ISO_14755 1755# if ISO_14755
1759 { 1772 {
1760 pix_colors = pix_colors_unfocused; 1773 pix_colors = pix_colors_unfocused;
1761 scr_recolour (); 1774 scr_recolour ();
1762 } 1775 }
1763#endif 1776#endif
1777
1778 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1764 } 1779 }
1765} 1780}
1766 1781
1767void 1782void
1768rxvt_term::update_fade_color (unsigned int idx) 1783rxvt_term::update_fade_color (unsigned int idx)
2066 reportmode = !! (priv_modes & PrivMode_mouse_report); 2081 reportmode = !! (priv_modes & PrivMode_mouse_report);
2067 2082
2068 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) 2083 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
2069 { 2084 {
2070 scrollBar.state = STATE_IDLE; 2085 scrollBar.state = STATE_IDLE;
2071 scrollbar_show (0); 2086 scrollBar.show (0);
2072 } 2087 }
2073 2088
2074#ifdef SELECTION_SCROLLING 2089#ifdef SELECTION_SCROLLING
2075 sel_scroll_ev.stop(); 2090 sel_scroll_ev.stop();
2076#endif 2091#endif
2159 } 2174 }
2160 else 2175 else
2161# endif 2176# endif
2162 { 2177 {
2163 scr_page (v, i); 2178 scr_page (v, i);
2164 scrollbar_show (1); 2179 scrollBar.show (1);
2165 } 2180 }
2166 } 2181 }
2167 break; 2182 break;
2168#endif 2183#endif
2169 } 2184 }
2179 wchar_t ch = NOCHAR; 2194 wchar_t ch = NOCHAR;
2180 char *seq_begin; // remember start of esc-sequence here 2195 char *seq_begin; // remember start of esc-sequence here
2181 2196
2182 for (;;) 2197 for (;;)
2183 { 2198 {
2184 if (ch == NOCHAR) 2199 if (expect_false (ch == NOCHAR))
2185 { 2200 {
2186 seq_begin = cmdbuf_ptr; 2201 seq_begin = cmdbuf_ptr;
2187 ch = next_char (); 2202 ch = next_char ();
2188 2203
2189 if (ch == NOCHAR) 2204 if (ch == NOCHAR)
2190 break; 2205 break;
2191 } 2206 }
2192 2207
2193 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2208 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2194 { 2209 {
2195 if (!seen_input) 2210 if (expect_false (!seen_input))
2196 { 2211 {
2197 seen_input = 1; 2212 seen_input = 1;
2198 // many badly-written programs (e.g. jed) contain a race condition: 2213 // many badly-written programs (e.g. jed) contain a race condition:
2199 // they first read the screensize and then install a SIGWINCH handler. 2214 // they first read the screensize and then install a SIGWINCH handler.
2200 // some window managers resize the window early, and these programs 2215 // some window managers resize the window early, and these programs
2213 wchar_t *str = buf; 2228 wchar_t *str = buf;
2214 wchar_t *eol = str + min (ncol, UBUFSIZ); 2229 wchar_t *eol = str + min (ncol, UBUFSIZ);
2215 2230
2216 for (;;) 2231 for (;;)
2217 { 2232 {
2218 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2233 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2219 break; 2234 break;
2220 2235
2221 *str++ = ch; 2236 *str++ = ch;
2222 2237
2223 if (ch == C0_LF || str >= eol) 2238 if (expect_false (ch == C0_LF || str >= eol))
2224 { 2239 {
2225 if (ch == C0_LF) 2240 if (ch == C0_LF)
2226 nlines++; 2241 nlines++;
2227 2242
2228 refresh_count++; 2243 refresh_count++;
2310rxvt_term::next_char () NOTHROW 2325rxvt_term::next_char () NOTHROW
2311{ 2326{
2312 while (cmdbuf_ptr < cmdbuf_endp) 2327 while (cmdbuf_ptr < cmdbuf_endp)
2313 { 2328 {
2314 // assume 7-bit to be ascii ALWAYS 2329 // assume 7-bit to be ascii ALWAYS
2315 if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) 2330 if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b))
2316 return *cmdbuf_ptr++; 2331 return *cmdbuf_ptr++;
2317 2332
2318 wchar_t wc; 2333 wchar_t wc;
2319 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); 2334 size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate);
2320 2335
2324 cmdbuf_ptr = cmdbuf_endp; 2339 cmdbuf_ptr = cmdbuf_endp;
2325 break; 2340 break;
2326 } 2341 }
2327 2342
2328 if (len == (size_t)-1) 2343 if (len == (size_t)-1)
2344 {
2345 mbrtowc (0, 0, 0, mbstate); // reset now undefined conversion state
2329 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2346 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2347 }
2330 2348
2331 // assume wchar == unicode 2349 // assume wchar == unicode
2332 cmdbuf_ptr += len; 2350 cmdbuf_ptr += len;
2333 return wc & UNICODE_MASK; 2351 return wc & UNICODE_MASK;
2334 } 2352 }
2378/*----------------------------------------------------------------------*/ 2396/*----------------------------------------------------------------------*/
2379#ifdef PRINTPIPE 2397#ifdef PRINTPIPE
2380FILE * 2398FILE *
2381rxvt_term::popen_printer () 2399rxvt_term::popen_printer ()
2382{ 2400{
2383 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2401 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2384 2402
2385 if (stream == NULL) 2403 if (stream == NULL)
2386 rxvt_warn ("can't open printer pipe, not printing.\n"); 2404 rxvt_warn ("can't open printer pipe, not printing.\n");
2387 2405
2388 return stream; 2406 return stream;
2399 * simulate attached vt100 printer 2417 * simulate attached vt100 printer
2400 */ 2418 */
2401void 2419void
2402rxvt_term::process_print_pipe () 2420rxvt_term::process_print_pipe ()
2403{ 2421{
2404 int done; 2422 FILE *fd = popen_printer ();
2405 FILE *fd;
2406 2423
2407 if ((fd = popen_printer ()) == NULL) 2424 if (!fd)
2408 return; 2425 return;
2409 2426
2410 /* 2427 /*
2411 * Send all input to the printer until either ESC[4i or ESC[?4i 2428 * Send all input to the printer until either ESC[4i or ESC[?4i
2412 * is received. 2429 * is received.
2413 */ 2430 */
2414 for (done = 0; !done;) 2431 for (int done = 0; !done; )
2415 { 2432 {
2416 unsigned char buf[8]; 2433 unsigned char buf[8];
2417 unicode_t ch; 2434 unicode_t ch;
2418 unsigned int i, len; 2435 unsigned int i, len;
2419 2436
2691 2708
2692 /* 8.3.106: RESET TO INITIAL STATE */ 2709 /* 8.3.106: RESET TO INITIAL STATE */
2693 case 'c': 2710 case 'c':
2694 mbstate.reset (); 2711 mbstate.reset ();
2695 scr_poweron (); 2712 scr_poweron ();
2696 scrollbar_show (1); 2713 scrollBar.show (1);
2697 break; 2714 break;
2698 2715
2699 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ 2716 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
2700 case 'n': 2717 case 'n':
2701 scr_charset_choose (2); 2718 scr_charset_choose (2);
3507 break; 3524 break;
3508#endif 3525#endif
3509 3526
3510#if ENABLE_PERL 3527#if ENABLE_PERL
3511 case URxvt_perl: 3528 case URxvt_perl:
3512 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) 3529 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END));
3513 ; // no responses yet
3514 break; 3530 break;
3515#endif 3531#endif
3516 } 3532 }
3517} 3533}
3518/*----------------------------------------------------------------------*/ 3534/*----------------------------------------------------------------------*/
3677 if (state) /* orthogonal */ 3693 if (state) /* orthogonal */
3678 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3694 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3679 break; 3695 break;
3680#ifdef scrollBar_esc 3696#ifdef scrollBar_esc
3681 case scrollBar_esc: 3697 case scrollBar_esc:
3682 if (scrollbar_mapping (state)) 3698 if (scrollBar.map (state))
3683 { 3699 {
3684 resize_all_windows (0, 0, 0); 3700 resize_all_windows (0, 0, 0);
3685 scr_touch (true); 3701 scr_touch (true);
3686 } 3702 }
3687 break; 3703 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines