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.411 by ayin, Sat Feb 16 16:07:29 2008 UTC vs.
Revision 1.436 by sf-exg, Sun Jan 24 21:53:13 2010 UTC

419 meta = ev.state & ModMetaMask; 419 meta = ev.state & ModMetaMask;
420 420
421 if (numlock_state || (ev.state & ModNumLockMask)) 421 if (numlock_state || (ev.state & ModNumLockMask))
422 { 422 {
423 numlock_state = (ev.state & ModNumLockMask); 423 numlock_state = (ev.state & ModNumLockMask);
424 PrivMode ((!numlock_state), PrivMode_aplKP); 424 set_privmode (PrivMode_aplKP, !numlock_state);
425 } 425 }
426 426
427 kbuf[0] = 0; 427 kbuf[0] = 0;
428 428
429#ifdef USE_XIM 429#ifdef USE_XIM
579 } 579 }
580 } 580 }
581 581
582#if ENABLE_FRILLS || ISO_14755 582#if ENABLE_FRILLS || ISO_14755
583 // ISO 14755 support 583 // ISO 14755 support
584 if (shft && ctrl) 584 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_51))
585 { 585 {
586 int hv; 586 int hv;
587 587
588 if (iso14755buf & ISO_14755_51 588 if (iso14755buf & ISO_14755_51
589 && (keysym == XK_space || keysym == XK_KP_Space 589 && (keysym == XK_space || keysym == XK_KP_Space
619 scr_overlay_off (); 619 scr_overlay_off ();
620# endif 620# endif
621 iso14755buf = 0; 621 iso14755buf = 0;
622 } 622 }
623 } 623 }
624 else if (option (Opt_iso14755) &&
624 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) 625 ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
625 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) 626 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))))
626 if (!(iso14755buf & ISO_14755_STARTED)) 627 if (!(iso14755buf & ISO_14755_STARTED))
627 { 628 {
628 iso14755buf |= ISO_14755_STARTED; 629 iso14755buf |= ISO_14755_STARTED;
629# if ISO_14755 630# if ISO_14755
630 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); 631 scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1);
1015 } 1016 }
1016 while (row < end_row); 1017 while (row < end_row);
1017 } 1018 }
1018 1019
1019 scr_refresh (); 1020 scr_refresh ();
1020 scrollbar_show (1); 1021 scrollBar.show (1);
1021#ifdef USE_XIM 1022#ifdef USE_XIM
1022 IMSendSpot (); 1023 IMSendSpot ();
1023#endif 1024#endif
1024 } 1025 }
1025 1026
1127 { 1128 {
1128 // this should really be sched_yield(), but the linux guys thought 1129 // this should really be sched_yield(), but the linux guys thought
1129 // that giving a process calling sched_yield () less cpu time than 1130 // 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 1131 // ones with high nice levels is a useful thing to do. It surely is is
1131 // allowed by the sus... as is returning ENOSYS. 1132 // allowed by the sus... as is returning ENOSYS.
1133 // since the linux guys additionally thought that breaking the only
1134 // known workaroudn against their unusable sched_yield hack is cool,
1135 // we just nanosleep a bit and hope for the best.
1132 1136
1133 struct timespec ts = { 0, 0 }; 1137 struct timespec ts = { 0, 1000 };
1134 nanosleep (&ts, 0); 1138 nanosleep (&ts, 0);
1135 1139
1136 w.stop (); 1140 w.stop ();
1137 } 1141 }
1138 1142
1188{ 1192{
1189 make_current (); 1193 make_current ();
1190 1194
1191 if (revents & ev::READ) 1195 if (revents & ev::READ)
1192 // loop, but don't allow a single term to monopolize us 1196 // loop, but don't allow a single term to monopolize us
1193 while (pty_fill ()) 1197 for (int i = CBUFCNT; i-- && pty_fill (); )
1194 if (cmd_parse ()) 1198 cmd_parse ();
1195 break;
1196 1199
1197 if (revents & ev::WRITE) 1200 if (revents & ev::WRITE)
1198 pty_write (); 1201 pty_write ();
1199 1202
1200 refresh_check (); 1203 refresh_check ();
1459 selection_property (ev.xproperty.window, ev.xproperty.atom); 1462 selection_property (ev.xproperty.window, ev.xproperty.atom);
1460 1463
1461 break; 1464 break;
1462 1465
1463 case SelectionClear: 1466 case SelectionClear:
1464 selection_clear (); 1467 selection_clear (ev.xselectionclear.selection == xa[XA_CLIPBOARD]);
1465 break; 1468 break;
1466 1469
1467 case SelectionNotify: 1470 case SelectionNotify:
1468 if (selection_wait == Sel_normal) 1471 if (selection_wait == Sel_normal)
1469 selection_paste (ev.xselection.requestor, ev.xselection.property, true); 1472 selection_paste (ev.xselection.requestor, ev.xselection.property, true);
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:
1645 &unused_root, &unused_child, 1648 &unused_root, &unused_child,
1646 &unused_root_x, &unused_root_y, 1649 &unused_root_x, &unused_root_y,
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)
1682#endif 1685#endif
1683 1686
1684 refresh_check (); 1687 refresh_check ();
1685} 1688}
1686 1689
1690#if ENABLE_FRILLS
1691void
1692rxvt_term::set_urgency (bool enable)
1693{
1694 if (enable == urgency_hint)
1695 return;
1696
1697 if (XWMHints *h = XGetWMHints (dpy, parent[0]))
1698 {
1699 h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0);
1700 XSetWMHints (dpy, parent[0], h);
1701 urgency_hint = enable;
1702 }
1703}
1704#endif
1705
1687void 1706void
1688rxvt_term::focus_in () 1707rxvt_term::focus_in ()
1689{ 1708{
1690 if (!focus) 1709 if (!focus)
1691 { 1710 {
1692 focus = 1; 1711 focus = 1;
1693 want_refresh = 1; 1712 want_refresh = 1;
1694
1695 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1696 1713
1697#if USE_XIM 1714#if USE_XIM
1698 if (Input_Context != NULL) 1715 if (Input_Context != NULL)
1699 { 1716 {
1700 IMSetPosition (); 1717 IMSetPosition ();
1712 scr_recolour (); 1729 scr_recolour ();
1713 } 1730 }
1714#endif 1731#endif
1715#if ENABLE_FRILLS 1732#if ENABLE_FRILLS
1716 if (option (Opt_urgentOnBell)) 1733 if (option (Opt_urgentOnBell))
1717 { 1734 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 1735#endif
1736
1737 HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END));
1725 } 1738 }
1726} 1739}
1727 1740
1728void 1741void
1729rxvt_term::focus_out () 1742rxvt_term::focus_out ()
1731 if (focus) 1744 if (focus)
1732 { 1745 {
1733 focus = 0; 1746 focus = 0;
1734 want_refresh = 1; 1747 want_refresh = 1;
1735 1748
1736 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); 1749#if ENABLE_FRILLS
1737 1750 if (option (Opt_urgentOnBell))
1751 set_urgency (0);
1752#endif
1738#if ENABLE_FRILLS || ISO_14755 1753#if ENABLE_FRILLS || ISO_14755
1739 if (iso14755buf) 1754 if (iso14755buf)
1740 { 1755 {
1741 iso14755buf = 0; 1756 iso14755buf = 0;
1742# if ISO_14755 1757# if ISO_14755
1759 { 1774 {
1760 pix_colors = pix_colors_unfocused; 1775 pix_colors = pix_colors_unfocused;
1761 scr_recolour (); 1776 scr_recolour ();
1762 } 1777 }
1763#endif 1778#endif
1779
1780 HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END));
1764 } 1781 }
1765} 1782}
1766 1783
1767void 1784void
1768rxvt_term::update_fade_color (unsigned int idx) 1785rxvt_term::update_fade_color (unsigned int idx)
2010 } 2027 }
2011 2028
2012 if (scrollBar.style == R_SB_XTERM 2029 if (scrollBar.style == R_SB_XTERM
2013 || scrollbar_above_slider (ev.y) 2030 || scrollbar_above_slider (ev.y)
2014 || scrollbar_below_slider (ev.y)) 2031 || scrollbar_below_slider (ev.y))
2015 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); 2032 scr_move_to (scrollbar_position (ev.y) - csrO, scrollBar.size ());
2016 2033
2017 scrollBar.state = STATE_MOTION; 2034 scrollBar.state = STATE_MOTION;
2018 break; 2035 break;
2019 2036
2020 case Button1: 2037 case Button1:
2043 else 2060 else
2044 { 2061 {
2045 scr_page ((ev.button == Button1 ? DN : UP), 2062 scr_page ((ev.button == Button1 ? DN : UP),
2046 (nrow 2063 (nrow
2047 * scrollbar_position (ev.y) 2064 * scrollbar_position (ev.y)
2048 / scrollbar_size ())); 2065 / scrollBar.size ()));
2049 } 2066 }
2050 2067
2051 break; 2068 break;
2052 } 2069 }
2053 } 2070 }
2066 reportmode = !! (priv_modes & PrivMode_mouse_report); 2083 reportmode = !! (priv_modes & PrivMode_mouse_report);
2067 2084
2068 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) 2085 if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN)
2069 { 2086 {
2070 scrollBar.state = STATE_IDLE; 2087 scrollBar.state = STATE_IDLE;
2071 scrollbar_show (0); 2088 scrollBar.show (0);
2072 } 2089 }
2073 2090
2074#ifdef SELECTION_SCROLLING 2091#ifdef SELECTION_SCROLLING
2075 sel_scroll_ev.stop(); 2092 sel_scroll_ev.stop();
2076#endif 2093#endif
2159 } 2176 }
2160 else 2177 else
2161# endif 2178# endif
2162 { 2179 {
2163 scr_page (v, i); 2180 scr_page (v, i);
2164 scrollbar_show (1); 2181 scrollBar.show (1);
2165 } 2182 }
2166 } 2183 }
2167 break; 2184 break;
2168#endif 2185#endif
2169 } 2186 }
2170 } 2187 }
2171} 2188}
2172 2189
2173/*}}} */ 2190/*}}} */
2174 2191
2175bool 2192void
2176rxvt_term::cmd_parse () 2193rxvt_term::cmd_parse ()
2177{ 2194{
2178 bool flag = false;
2179 wchar_t ch = NOCHAR; 2195 wchar_t ch = NOCHAR;
2180 char *seq_begin; // remember start of esc-sequence here 2196 char *seq_begin; // remember start of esc-sequence here
2181 2197
2182 for (;;) 2198 for (;;)
2183 { 2199 {
2184 if (ch == NOCHAR) 2200 if (expect_false (ch == NOCHAR))
2185 { 2201 {
2186 seq_begin = cmdbuf_ptr; 2202 seq_begin = cmdbuf_ptr;
2187 ch = next_char (); 2203 ch = next_char ();
2188 2204
2189 if (ch == NOCHAR) 2205 if (ch == NOCHAR)
2190 break; 2206 break;
2191 } 2207 }
2192 2208
2193 if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) 2209 if (expect_true (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT))
2194 { 2210 {
2195 if (!seen_input) 2211 if (expect_false (!seen_input))
2196 { 2212 {
2197 seen_input = 1; 2213 seen_input = 1;
2198 // many badly-written programs (e.g. jed) contain a race condition: 2214 // many badly-written programs (e.g. jed) contain a race condition:
2199 // they first read the screensize and then install a SIGWINCH handler. 2215 // they first read the screensize and then install a SIGWINCH handler.
2200 // some window managers resize the window early, and these programs 2216 // some window managers resize the window early, and these programs
2213 wchar_t *str = buf; 2229 wchar_t *str = buf;
2214 wchar_t *eol = str + min (ncol, UBUFSIZ); 2230 wchar_t *eol = str + min (ncol, UBUFSIZ);
2215 2231
2216 for (;;) 2232 for (;;)
2217 { 2233 {
2218 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2234 if (expect_false (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)))
2219 break; 2235 break;
2220 2236
2221 *str++ = ch; 2237 *str++ = ch;
2222 2238
2223 if (ch == C0_LF || str >= eol) 2239 if (expect_false (ch == C0_LF || str >= eol))
2224 { 2240 {
2225 if (ch == C0_LF) 2241 if (ch == C0_LF)
2226 nlines++; 2242 nlines++;
2227 2243
2228 refresh_count++; 2244 refresh_count++;
2277 * What the heck we'll cheat and only refresh less than every page-full. 2293 * What the heck we'll cheat and only refresh less than every page-full.
2278 * if skipScroll is enabled. 2294 * if skipScroll is enabled.
2279 */ 2295 */
2280 if (refreshnow) 2296 if (refreshnow)
2281 { 2297 {
2282 flag = true;
2283 scr_refresh (); 2298 scr_refresh ();
2284 want_refresh = 1; 2299 want_refresh = 1;
2285 } 2300 }
2286
2287 } 2301 }
2288 else 2302 else
2289 { 2303 {
2290 try 2304 try
2291 { 2305 {
2299 } 2313 }
2300 2314
2301 ch = NOCHAR; 2315 ch = NOCHAR;
2302 } 2316 }
2303 } 2317 }
2304
2305 return flag;
2306} 2318}
2307 2319
2308// read the next character 2320// read the next character
2309wchar_t 2321wchar_t
2310rxvt_term::next_char () NOTHROW 2322rxvt_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
2324 cmdbuf_ptr = cmdbuf_endp; 2336 cmdbuf_ptr = cmdbuf_endp;
2325 break; 2337 break;
2326 } 2338 }
2327 2339
2328 if (len == (size_t)-1) 2340 if (len == (size_t)-1)
2341 {
2342 mbstate.reset (); // reset now undefined conversion state
2329 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2343 return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2344 }
2330 2345
2331 // assume wchar == unicode 2346 // assume wchar == unicode
2332 cmdbuf_ptr += len; 2347 cmdbuf_ptr += len;
2333 return wc & UNICODE_MASK; 2348 return wc & UNICODE_MASK;
2334 } 2349 }
2378/*----------------------------------------------------------------------*/ 2393/*----------------------------------------------------------------------*/
2379#ifdef PRINTPIPE 2394#ifdef PRINTPIPE
2380FILE * 2395FILE *
2381rxvt_term::popen_printer () 2396rxvt_term::popen_printer ()
2382{ 2397{
2383 FILE *stream = popen (rs[Rs_print_pipe], "w"); 2398 FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w");
2384 2399
2385 if (stream == NULL) 2400 if (stream == NULL)
2386 rxvt_warn ("can't open printer pipe, not printing.\n"); 2401 rxvt_warn ("can't open printer pipe, not printing.\n");
2387 2402
2388 return stream; 2403 return stream;
2399 * simulate attached vt100 printer 2414 * simulate attached vt100 printer
2400 */ 2415 */
2401void 2416void
2402rxvt_term::process_print_pipe () 2417rxvt_term::process_print_pipe ()
2403{ 2418{
2404 int done; 2419 FILE *fd = popen_printer ();
2405 FILE *fd;
2406 2420
2407 if ((fd = popen_printer ()) == NULL) 2421 if (!fd)
2408 return; 2422 return;
2409 2423
2410 /* 2424 /*
2411 * 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
2412 * is received. 2426 * is received.
2413 */ 2427 */
2414 for (done = 0; !done;) 2428 for (int done = 0; !done; )
2415 { 2429 {
2416 unsigned char buf[8]; 2430 unsigned char buf[8];
2417 unicode_t ch; 2431 unicode_t ch;
2418 unsigned int i, len; 2432 unsigned int i, len;
2419 2433
2564 break; 2578 break;
2565 case 'Z': /* identify the terminal type */ 2579 case 'Z': /* identify the terminal type */
2566 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */ 2580 tt_printf ("\033/Z"); /* I am a VT100 emulating a VT52 */
2567 break; 2581 break;
2568 case '<': /* turn off VT52 mode */ 2582 case '<': /* turn off VT52 mode */
2569 PrivMode (0, PrivMode_vt52); 2583 set_privmode (PrivMode_vt52, 0);
2570 break; 2584 break;
2571 case 'F': /* use special graphics character set */ 2585 case 'F': /* use special graphics character set */
2572 case 'G': /* use regular character set */ 2586 case 'G': /* use regular character set */
2573 /* unimplemented */ 2587 /* unimplemented */
2574 break; 2588 break;
2628 scr_forwardindex (); 2642 scr_forwardindex ();
2629 break; 2643 break;
2630#endif 2644#endif
2631 case '=': 2645 case '=':
2632 case '>': 2646 case '>':
2633 PrivMode ((ch == '='), PrivMode_aplKP); 2647 set_privmode (PrivMode_aplKP, ch == '=');
2634 break; 2648 break;
2635 2649
2636 case C1_40: 2650 case C1_40:
2637 cmd_getc (); 2651 cmd_getc ();
2638 break; 2652 break;
2677 /* 8.3.110: SINGLE CHARACTER INTRODUCER */ 2691 /* 8.3.110: SINGLE CHARACTER INTRODUCER */
2678 case C1_SCI: /* ESC Z */ 2692 case C1_SCI: /* ESC Z */
2679 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); 2693 tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1);
2680 break; /* steal obsolete ESC [ c */ 2694 break; /* steal obsolete ESC [ c */
2681 2695
2682 /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ 2696 /* 8.3.16: CONTROL SEQUENCE INTRODUCER (CSI) */
2683 case C1_CSI: /* ESC [ */ 2697 case C1_CSI: /* ESC [ */
2684 process_csi_seq (); 2698 process_csi_seq ();
2685 break; 2699 break;
2686 2700
2687 /* 8.3.90: OPERATING SYSTEM COMMAND */ 2701 /* 8.3.90: OPERATING SYSTEM COMMAND (OSC) */
2688 case C1_OSC: /* ESC ] */ 2702 case C1_OSC: /* ESC ] */
2689 process_osc_seq (); 2703 process_osc_seq ();
2690 break; 2704 break;
2691 2705
2692 /* 8.3.106: RESET TO INITIAL STATE */ 2706 /* 8.3.106: RESET TO INITIAL STATE (RIS) */
2693 case 'c': 2707 case 'c':
2694 mbstate.reset (); 2708 mbstate.reset ();
2695 scr_poweron (); 2709 scr_poweron ();
2696 scrollbar_show (1); 2710 scrollBar.show (1);
2697 break; 2711 break;
2698 2712
2699 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */ 2713 /* 8.3.79: LOCKING-SHIFT TWO (see ISO2022) */
2700 case 'n': 2714 case 'n':
2701 scr_charset_choose (2); 2715 scr_charset_choose (2);
2752 2766
2753 nargs = 0; 2767 nargs = 0;
2754 2768
2755 priv = 0; 2769 priv = 0;
2756 ch = cmd_getc (); 2770 ch = cmd_getc ();
2757 if (ch >= '<' && ch <= '?') 2771 if ((ch >= '<' && ch <= '?') || ch == '!')
2758 { 2772 {
2759 /* '<' '=' '>' '?' */ 2773 /* '<' '=' '>' '?' '!' */
2760 priv = ch; 2774 priv = ch;
2761 ch = cmd_getc (); 2775 ch = cmd_getc ();
2762 } 2776 }
2763 2777
2764 /* read any numerical arguments */ 2778 /* read any numerical arguments */
2818 2832
2819 case '?': 2833 case '?':
2820 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 2834 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
2821 process_terminal_mode (ch, priv, nargs, arg); 2835 process_terminal_mode (ch, priv, nargs, arg);
2822 break; 2836 break;
2837
2838 case '!':
2839 if (ch == CSI_70)
2840 {
2841 /* DECSTR: soft terminal reset, used by our terminfo since 9.06 */
2842 scr_soft_reset ();
2843
2844 static const int pm_h[] = { 7, 25 };
2845 static const int pm_l[] = { 1, 3, 4, 5, 6, 9, 66, 1000, 1001, 1049 };
2846
2847 process_terminal_mode ('h', 0, sizeof (pm_h) / sizeof (pm_h[0]), pm_h);
2848 process_terminal_mode ('l', 0, sizeof (pm_l) / sizeof (pm_l[0]), pm_l);
2823 } 2849 }
2850 break;
2851 }
2852
2824 return; 2853 return;
2825 } 2854 }
2826 2855
2827 switch (ch) 2856 switch (ch)
2828 { 2857 {
3257 3286
3258/* 3287/*
3259 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) 3288 * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL)
3260 */ 3289 */
3261void 3290void
3262rxvt_term::process_xterm_seq (int op, const char *str, char resp) 3291rxvt_term::process_xterm_seq (int op, char *str, char resp)
3263{ 3292{
3264 int color; 3293 int color;
3265 char *buf, *name; 3294 char *buf, *name;
3266 bool query = str[0] == '?' && !str[1]; 3295 bool query = str[0] == '?' && !str[1];
3267 int saveop = op; 3296 int saveop = op;
3308 3337
3309 XFree (value); 3338 XFree (value);
3310 } 3339 }
3311 else 3340 else
3312 { 3341 {
3313 char *eq = strchr (str, '='); // constness lost, but verified to be ok 3342 char *eq = strchr (str, '=');
3314 3343
3315 if (eq) 3344 if (eq)
3316 { 3345 {
3317 *eq = 0; 3346 *eq = 0;
3318 set_utf8_property (display->atom (str), eq + 1); 3347 set_utf8_property (display->atom (str), eq + 1);
3374 break; 3403 break;
3375 case URxvt_Color_IT: 3404 case URxvt_Color_IT:
3376 process_color_seq (op, Color_IT, str, resp); 3405 process_color_seq (op, Color_IT, str, resp);
3377 break; 3406 break;
3378#endif 3407#endif
3408 case URxvt_Color_border:
3409 process_color_seq (op, Color_border, str, resp);
3410 break;
3379#if ENABLE_TRANSPARENCY 3411#if ENABLE_TRANSPARENCY
3380 case URxvt_Color_tint: 3412 case URxvt_Color_tint:
3381 process_color_seq (op, Color_tint, str, resp); 3413 process_color_seq (op, Color_tint, str, resp);
3382 { 3414 {
3383 bool changed = false; 3415 bool changed = false;
3507 break; 3539 break;
3508#endif 3540#endif
3509 3541
3510#if ENABLE_PERL 3542#if ENABLE_PERL
3511 case URxvt_perl: 3543 case URxvt_perl:
3512 if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) 3544 HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_STR_LEN, &resp, 1, DT_END));
3513 ; // no responses yet
3514 break; 3545 break;
3515#endif 3546#endif
3516 } 3547 }
3517} 3548}
3518/*----------------------------------------------------------------------*/ 3549/*----------------------------------------------------------------------*/
3541 { 3572 {
3542 if (mode == 'r') 3573 if (mode == 'r')
3543 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */ 3574 state = (SavedModes & bit) ? 1 : 0; /* no overlapping */
3544 else 3575 else
3545 state = (mode == 't') ? ! (priv_modes & bit) : mode; 3576 state = (mode == 't') ? ! (priv_modes & bit) : mode;
3546 PrivMode (state, bit); 3577 set_privmode (bit, state);
3547 } 3578 }
3548 3579
3549 return state; 3580 return state;
3550} 3581}
3551 3582
3559 static const struct 3590 static const struct
3560 { 3591 {
3561 const int argval; 3592 const int argval;
3562 const unsigned long bit; 3593 const unsigned long bit;
3563 } argtopriv[] = { 3594 } argtopriv[] = {
3564 { 1, PrivMode_aplCUR }, 3595 { 1, PrivMode_aplCUR }, // DECCKM
3565 { 2, PrivMode_vt52 }, 3596 { 2, PrivMode_vt52 },
3566 { 3, PrivMode_132 }, 3597 { 3, PrivMode_132 }, // DECCOLM
3567 { 4, PrivMode_smoothScroll }, 3598 { 4, PrivMode_smoothScroll }, // DECSCLM
3568 { 5, PrivMode_rVideo }, 3599 { 5, PrivMode_rVideo }, // DECSCNM
3569 { 6, PrivMode_relOrigin }, 3600 { 6, PrivMode_relOrigin }, // DECOM
3570 { 7, PrivMode_Autowrap }, 3601 { 7, PrivMode_Autowrap }, // DECAWM
3571 // 8, bi-directional support mode 3602 // 8, auto-repeat keys // DECARM
3572 { 9, PrivMode_MouseX10 }, 3603 { 9, PrivMode_MouseX10 },
3573 // 18, 19 printing-related 3604 // 18 end FF to printer after print screen
3605 // 19 Print screen prints full screen/scorll region
3574 { 25, PrivMode_VisibleCursor }, 3606 { 25, PrivMode_VisibleCursor }, // cnorm/cvvis/civis
3575#ifdef scrollBar_esc 3607#ifdef scrollBar_esc
3576 { scrollBar_esc, PrivMode_scrollBar }, 3608 { scrollBar_esc, PrivMode_scrollBar },
3577#endif 3609#endif
3578 { 35, PrivMode_ShiftKeys }, // rxvt extension 3610 { 35, PrivMode_ShiftKeys }, // rxvt extension
3611 // 38, tektronix mode // DECTEK
3579 { 40, PrivMode_132OK }, 3612 { 40, PrivMode_132OK },
3580 // 41 xterm more fixes NYI 3613 // 41 xterm more fixes NYI
3581 // 45 margin bell NYI 3614 // 45 margin bell NYI
3582 // 46 start logging 3615 // 46 start logging
3583 { 47, PrivMode_Screen }, 3616 { 47, PrivMode_Screen },
3584 { 66, PrivMode_aplKP }, 3617 { 66, PrivMode_aplKP }, // DECPAM/DECPNM
3585#ifndef NO_BACKSPACE_KEY 3618#ifndef NO_BACKSPACE_KEY
3586 { 67, PrivMode_BackSpace }, 3619 { 67, PrivMode_BackSpace }, // DECBKM
3587#endif 3620#endif
3588 { 1000, PrivMode_MouseX11 }, 3621 { 1000, PrivMode_MouseX11 },
3589 { 1002, PrivMode_MouseBtnEvent }, 3622 { 1002, PrivMode_MouseBtnEvent },
3590 { 1003, PrivMode_MouseAnyEvent }, 3623 { 1003, PrivMode_MouseAnyEvent },
3591 { 1010, PrivMode_TtyOutputInh }, // rxvt extension 3624 { 1010, PrivMode_TtyOutputInh }, // rxvt extension
3630 3663
3631 scr_touch (true); 3664 scr_touch (true);
3632 break; 3665 break;
3633#endif 3666#endif
3634 case 1048: /* alternative cursor save */ 3667 case 1048: /* alternative cursor save */
3635 case 1049:
3636 if (option (Opt_secondaryScreen)) 3668 if (option (Opt_secondaryScreen))
3637 if (mode == 0) 3669 if (mode == 0)
3638 scr_cursor (RESTORE); 3670 scr_cursor (RESTORE);
3639 else if (mode == 1) 3671 else if (mode == 1)
3640 scr_cursor (SAVE); 3672 scr_cursor (SAVE);
3649 case 2: /* VT52 mode */ 3681 case 2: /* VT52 mode */
3650 /* oddball mode. should be set regardless of set/reset 3682 /* oddball mode. should be set regardless of set/reset
3651 * parameter. Return from VT52 mode with an ESC < from 3683 * parameter. Return from VT52 mode with an ESC < from
3652 * within VT52 mode 3684 * within VT52 mode
3653 */ 3685 */
3654 PrivMode (1, PrivMode_vt52); 3686 set_privmode (PrivMode_vt52, 1);
3655 break; 3687 break;
3656 case 3: /* 80/132 */ 3688 case 3: /* 80/132 */
3657 if (priv_modes & PrivMode_132OK) 3689 if (priv_modes & PrivMode_132OK)
3658 {
3659 scr_poweron ();
3660 set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); 3690 set_widthheight ((state ? 132 : 80) * fwidth, 24 * fheight);
3661 }
3662 break; 3691 break;
3663 case 4: /* smooth scrolling */ 3692 case 4: /* smooth scrolling */
3664 set_option (Opt_jumpScroll, !state); 3693 set_option (Opt_jumpScroll, !state);
3665 break; 3694 break;
3666 case 5: /* reverse video */ 3695 case 5: /* reverse video */
3677 if (state) /* orthogonal */ 3706 if (state) /* orthogonal */
3678 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); 3707 priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent);
3679 break; 3708 break;
3680#ifdef scrollBar_esc 3709#ifdef scrollBar_esc
3681 case scrollBar_esc: 3710 case scrollBar_esc:
3682 if (scrollbar_mapping (state)) 3711 if (scrollBar.map (state))
3683 { 3712 {
3684 resize_all_windows (0, 0, 0); 3713 resize_all_windows (0, 0, 0);
3685 scr_touch (true); 3714 scr_touch (true);
3686 } 3715 }
3687 break; 3716 break;
3708 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; 3737 priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent;
3709 vt_emask_mouse = PointerMotionMask; 3738 vt_emask_mouse = PointerMotionMask;
3710 } 3739 }
3711 else 3740 else
3712 vt_emask_mouse = NoEventMask; 3741 vt_emask_mouse = NoEventMask;
3742
3713 vt_select_input (); 3743 vt_select_input ();
3714 break; 3744 break;
3715 case 1010: /* scroll to bottom on TTY output inhibit */ 3745 case 1010: /* scroll to bottom on TTY output inhibit */
3716 set_option (Opt_scrollTtyOutput, !state); 3746 set_option (Opt_scrollTtyOutput, !state);
3717 break; 3747 break;
3718 case 1011: /* scroll to bottom on key press */ 3748 case 1011: /* scroll to bottom on key press */
3719 set_option (Opt_scrollTtyKeypress, state); 3749 set_option (Opt_scrollTtyKeypress, state);
3720 break; 3750 break;
3721 case 1047: /* secondary screen w/ clearing last */ 3751 case 1047: /* secondary screen w/ clearing last */
3722 if (option (Opt_secondaryScreen)) 3752 if (option (Opt_secondaryScreen))
3723 if (current_screen != PRIMARY) 3753 if (!state)
3724 scr_erase_screen (2); 3754 scr_erase_screen (2);
3755
3725 scr_change_screen (state); 3756 scr_change_screen (state);
3726 break; 3757 break;
3727 case 1049: /* secondary screen w/ clearing first */ 3758 case 1049: /* secondary screen w/ clearing first */
3759 if (option (Opt_secondaryScreen))
3760 if (state)
3761 scr_cursor (SAVE);
3762
3728 scr_change_screen (state); 3763 scr_change_screen (state);
3764
3729 if (option (Opt_secondaryScreen)) 3765 if (option (Opt_secondaryScreen))
3730 if (current_screen != PRIMARY) 3766 if (state)
3731 scr_erase_screen (2); 3767 scr_erase_screen (2);
3768 else
3769 scr_cursor (RESTORE);
3732 break; 3770 break;
3733 default: 3771 default:
3734 break; 3772 break;
3735 } 3773 }
3736 } 3774 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines