… | |
… | |
1683 | |
1683 | |
1684 | refresh_check (); |
1684 | refresh_check (); |
1685 | } |
1685 | } |
1686 | |
1686 | |
1687 | void |
1687 | void |
|
|
1688 | rxvt_term::set_urgency (bool enable) |
|
|
1689 | { |
|
|
1690 | if (enable == urgency_hint) |
|
|
1691 | return; |
|
|
1692 | |
|
|
1693 | if (XWMHints *h = XGetWMHints (dpy, parent[0])) |
|
|
1694 | { |
|
|
1695 | h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); |
|
|
1696 | XSetWMHints (dpy, parent[0], h); |
|
|
1697 | urgency_hint = enable; |
|
|
1698 | } |
|
|
1699 | } |
|
|
1700 | |
|
|
1701 | void |
1688 | rxvt_term::focus_in () |
1702 | rxvt_term::focus_in () |
1689 | { |
1703 | { |
1690 | if (!focus) |
1704 | if (!focus) |
1691 | { |
1705 | { |
1692 | focus = 1; |
1706 | focus = 1; |
1693 | want_refresh = 1; |
1707 | want_refresh = 1; |
1694 | |
|
|
1695 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
|
|
1696 | |
1708 | |
1697 | #if USE_XIM |
1709 | #if USE_XIM |
1698 | if (Input_Context != NULL) |
1710 | if (Input_Context != NULL) |
1699 | { |
1711 | { |
1700 | IMSetPosition (); |
1712 | IMSetPosition (); |
… | |
… | |
1712 | scr_recolour (); |
1724 | scr_recolour (); |
1713 | } |
1725 | } |
1714 | #endif |
1726 | #endif |
1715 | #if ENABLE_FRILLS |
1727 | #if ENABLE_FRILLS |
1716 | if (option (Opt_urgentOnBell)) |
1728 | if (option (Opt_urgentOnBell)) |
1717 | { |
1729 | 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 |
1730 | #endif |
|
|
1731 | |
|
|
1732 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1725 | } |
1733 | } |
1726 | } |
1734 | } |
1727 | |
1735 | |
1728 | void |
1736 | void |
1729 | rxvt_term::focus_out () |
1737 | rxvt_term::focus_out () |
… | |
… | |
1731 | if (focus) |
1739 | if (focus) |
1732 | { |
1740 | { |
1733 | focus = 0; |
1741 | focus = 0; |
1734 | want_refresh = 1; |
1742 | want_refresh = 1; |
1735 | |
1743 | |
1736 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1744 | #if ENABLE_FRILLS |
1737 | |
1745 | if (option (Opt_urgentOnBell)) |
|
|
1746 | set_urgency (0); |
|
|
1747 | #endif |
1738 | #if ENABLE_FRILLS || ISO_14755 |
1748 | #if ENABLE_FRILLS || ISO_14755 |
1739 | if (iso14755buf) |
1749 | if (iso14755buf) |
1740 | { |
1750 | { |
1741 | iso14755buf = 0; |
1751 | iso14755buf = 0; |
1742 | # if ISO_14755 |
1752 | # if ISO_14755 |
… | |
… | |
1759 | { |
1769 | { |
1760 | pix_colors = pix_colors_unfocused; |
1770 | pix_colors = pix_colors_unfocused; |
1761 | scr_recolour (); |
1771 | scr_recolour (); |
1762 | } |
1772 | } |
1763 | #endif |
1773 | #endif |
|
|
1774 | |
|
|
1775 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1764 | } |
1776 | } |
1765 | } |
1777 | } |
1766 | |
1778 | |
1767 | void |
1779 | void |
1768 | rxvt_term::update_fade_color (unsigned int idx) |
1780 | rxvt_term::update_fade_color (unsigned int idx) |
… | |
… | |
2179 | wchar_t ch = NOCHAR; |
2191 | wchar_t ch = NOCHAR; |
2180 | char *seq_begin; // remember start of esc-sequence here |
2192 | char *seq_begin; // remember start of esc-sequence here |
2181 | |
2193 | |
2182 | for (;;) |
2194 | for (;;) |
2183 | { |
2195 | { |
2184 | if (ch == NOCHAR) |
2196 | if (expect_false (ch == NOCHAR)) |
2185 | { |
2197 | { |
2186 | seq_begin = cmdbuf_ptr; |
2198 | seq_begin = cmdbuf_ptr; |
2187 | ch = next_char (); |
2199 | ch = next_char (); |
2188 | |
2200 | |
2189 | if (ch == NOCHAR) |
2201 | if (ch == NOCHAR) |
2190 | break; |
2202 | break; |
2191 | } |
2203 | } |
2192 | |
2204 | |
2193 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2205 | if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT)) |
2194 | { |
2206 | { |
2195 | if (!seen_input) |
2207 | if (expect_false (!seen_input)) |
2196 | { |
2208 | { |
2197 | seen_input = 1; |
2209 | seen_input = 1; |
2198 | // many badly-written programs (e.g. jed) contain a race condition: |
2210 | // many badly-written programs (e.g. jed) contain a race condition: |
2199 | // they first read the screensize and then install a SIGWINCH handler. |
2211 | // they first read the screensize and then install a SIGWINCH handler. |
2200 | // some window managers resize the window early, and these programs |
2212 | // some window managers resize the window early, and these programs |
… | |
… | |
2213 | wchar_t *str = buf; |
2225 | wchar_t *str = buf; |
2214 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2226 | wchar_t *eol = str + min (ncol, UBUFSIZ); |
2215 | |
2227 | |
2216 | for (;;) |
2228 | for (;;) |
2217 | { |
2229 | { |
2218 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2230 | if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))) |
2219 | break; |
2231 | break; |
2220 | |
2232 | |
2221 | *str++ = ch; |
2233 | *str++ = ch; |
2222 | |
2234 | |
2223 | if (ch == C0_LF || str >= eol) |
2235 | if (expect_false (ch == C0_LF || str >= eol)) |
2224 | { |
2236 | { |
2225 | if (ch == C0_LF) |
2237 | if (ch == C0_LF) |
2226 | nlines++; |
2238 | nlines++; |
2227 | |
2239 | |
2228 | refresh_count++; |
2240 | refresh_count++; |
… | |
… | |
2310 | rxvt_term::next_char () NOTHROW |
2322 | rxvt_term::next_char () NOTHROW |
2311 | { |
2323 | { |
2312 | while (cmdbuf_ptr < cmdbuf_endp) |
2324 | while (cmdbuf_ptr < cmdbuf_endp) |
2313 | { |
2325 | { |
2314 | // assume 7-bit to be ascii ALWAYS |
2326 | // assume 7-bit to be ascii ALWAYS |
2315 | if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) |
2327 | if (expect_true ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b)) |
2316 | return *cmdbuf_ptr++; |
2328 | return *cmdbuf_ptr++; |
2317 | |
2329 | |
2318 | wchar_t wc; |
2330 | wchar_t wc; |
2319 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2331 | size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); |
2320 | |
2332 | |
… | |
… | |
2381 | /*----------------------------------------------------------------------*/ |
2393 | /*----------------------------------------------------------------------*/ |
2382 | #ifdef PRINTPIPE |
2394 | #ifdef PRINTPIPE |
2383 | FILE * |
2395 | FILE * |
2384 | rxvt_term::popen_printer () |
2396 | rxvt_term::popen_printer () |
2385 | { |
2397 | { |
2386 | FILE *stream = popen (rs[Rs_print_pipe], "w"); |
2398 | FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); |
2387 | |
2399 | |
2388 | if (stream == NULL) |
2400 | if (stream == NULL) |
2389 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2401 | rxvt_warn ("can't open printer pipe, not printing.\n"); |
2390 | |
2402 | |
2391 | return stream; |
2403 | return stream; |
… | |
… | |
2402 | * simulate attached vt100 printer |
2414 | * simulate attached vt100 printer |
2403 | */ |
2415 | */ |
2404 | void |
2416 | void |
2405 | rxvt_term::process_print_pipe () |
2417 | rxvt_term::process_print_pipe () |
2406 | { |
2418 | { |
2407 | int done; |
2419 | FILE *fd = popen_printer (); |
2408 | FILE *fd; |
|
|
2409 | |
2420 | |
2410 | if ((fd = popen_printer ()) == NULL) |
2421 | if (!fd) |
2411 | return; |
2422 | return; |
2412 | |
2423 | |
2413 | /* |
2424 | /* |
2414 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2425 | * Send all input to the printer until either ESC[4i or ESC[?4i |
2415 | * is received. |
2426 | * is received. |
2416 | */ |
2427 | */ |
2417 | for (done = 0; !done;) |
2428 | for (int done = 0; !done; ) |
2418 | { |
2429 | { |
2419 | unsigned char buf[8]; |
2430 | unsigned char buf[8]; |
2420 | unicode_t ch; |
2431 | unicode_t ch; |
2421 | unsigned int i, len; |
2432 | unsigned int i, len; |
2422 | |
2433 | |
… | |
… | |
3510 | break; |
3521 | break; |
3511 | #endif |
3522 | #endif |
3512 | |
3523 | |
3513 | #if ENABLE_PERL |
3524 | #if ENABLE_PERL |
3514 | case URxvt_perl: |
3525 | case URxvt_perl: |
3515 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3526 | HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END)); |
3516 | ; // no responses yet |
|
|
3517 | break; |
3527 | break; |
3518 | #endif |
3528 | #endif |
3519 | } |
3529 | } |
3520 | } |
3530 | } |
3521 | /*----------------------------------------------------------------------*/ |
3531 | /*----------------------------------------------------------------------*/ |