1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: command.c |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
7 | * - original version |
7 | * - original version |
… | |
… | |
672 | scr_refresh (refresh_type); |
672 | scr_refresh (refresh_type); |
673 | scrollbar_show (1); |
673 | scrollbar_show (1); |
674 | #ifdef USE_XIM |
674 | #ifdef USE_XIM |
675 | IMSendSpot (); |
675 | IMSendSpot (); |
676 | #endif |
676 | #endif |
677 | |
|
|
678 | } |
677 | } |
679 | |
678 | |
680 | display->flush (); |
679 | display->flush (); |
681 | } |
680 | } |
682 | |
681 | |
… | |
… | |
711 | w.start (w.at + TEXT_BLINK_INTERVAL); |
710 | w.start (w.at + TEXT_BLINK_INTERVAL); |
712 | } |
711 | } |
713 | } |
712 | } |
714 | #endif |
713 | #endif |
715 | |
714 | |
|
|
715 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
716 | void |
|
|
717 | rxvt_term::cont_scroll_cb (time_watcher &w) |
|
|
718 | { |
|
|
719 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
|
|
720 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
|
|
721 | { |
|
|
722 | refresh_type |= SMOOTH_REFRESH; |
|
|
723 | want_refresh = 1; |
|
|
724 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
725 | } |
|
|
726 | } |
|
|
727 | #endif |
|
|
728 | |
|
|
729 | #ifdef SELECTION_SCROLLING |
|
|
730 | void |
|
|
731 | rxvt_term::sel_scroll_cb (time_watcher &w) |
|
|
732 | { |
|
|
733 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
|
|
734 | { |
|
|
735 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
|
|
736 | refresh_type |= SMOOTH_REFRESH; |
|
|
737 | want_refresh = 1; |
|
|
738 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
739 | } |
|
|
740 | } |
|
|
741 | #endif |
|
|
742 | |
|
|
743 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
744 | void |
|
|
745 | rxvt_term::slip_wheel_cb (time_watcher &w) |
|
|
746 | { |
|
|
747 | if (mouse_slip_wheel_speed == 0 |
|
|
748 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
749 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
750 | { |
|
|
751 | refresh_type |= SMOOTH_REFRESH; |
|
|
752 | want_refresh = 1; |
|
|
753 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
|
|
754 | } |
|
|
755 | } |
|
|
756 | #endif |
|
|
757 | |
716 | bool |
758 | bool |
717 | rxvt_term::pty_fill () |
759 | rxvt_term::pty_fill () |
718 | { |
760 | { |
719 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
761 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
|
|
762 | |
|
|
763 | if (CBUFSIZ == n) |
|
|
764 | { |
|
|
765 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
|
|
766 | n = 0; |
|
|
767 | } |
720 | |
768 | |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
769 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
722 | cmdbuf_ptr = cmdbuf_base; |
770 | cmdbuf_ptr = cmdbuf_base; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
771 | cmdbuf_endp = cmdbuf_ptr + n; |
724 | |
772 | |
… | |
… | |
742 | SET_LOCALE (locale); |
790 | SET_LOCALE (locale); |
743 | |
791 | |
744 | if (revents & EVENT_WRITE) |
792 | if (revents & EVENT_WRITE) |
745 | tt_write (0, 0); |
793 | tt_write (0, 0); |
746 | else if (revents & EVENT_READ) |
794 | else if (revents & EVENT_READ) |
747 | { |
|
|
748 | // loop, but don't allow a single term to monopolize us |
795 | // loop, but don't allow a single term to monopolize us |
749 | // the number of loops is fully arbitrary, and thus wrong |
|
|
750 | while (pty_fill ()) |
796 | while (pty_fill ()) |
751 | { |
|
|
752 | if (!seen_input) |
|
|
753 | { |
|
|
754 | seen_input = 1; |
|
|
755 | /* once we know the shell is running, send the screen size. Again! */ |
|
|
756 | // I don't know why, btw. |
|
|
757 | tt_winch (); |
|
|
758 | } |
|
|
759 | |
|
|
760 | if (cmd_parse ()) |
797 | if (cmd_parse ()) |
761 | break; |
798 | break; |
762 | } |
|
|
763 | } |
|
|
764 | } |
799 | } |
765 | |
800 | |
766 | #ifdef POINTER_BLANK |
801 | #ifdef POINTER_BLANK |
767 | void |
802 | void |
768 | rxvt_term::pointer_unblank () |
803 | rxvt_term::pointer_unblank () |
… | |
… | |
979 | break; |
1014 | break; |
980 | |
1015 | |
981 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1016 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
982 | case KeyRelease: |
1017 | case KeyRelease: |
983 | { |
1018 | { |
984 | if (! (ev.xkey.state & ControlMask)) |
1019 | if (!(ev.xkey.state & ControlMask)) |
985 | mouse_slip_wheel_speed = 0; |
1020 | slip_wheel_ev.stop (); |
986 | else |
1021 | else |
987 | { |
1022 | { |
988 | KeySym ks; |
1023 | KeySym ks; |
989 | |
1024 | |
990 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
1025 | ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); |
991 | if (ks == XK_Control_L || ks == XK_Control_R) |
1026 | if (ks == XK_Control_L || ks == XK_Control_R) |
992 | mouse_slip_wheel_speed = 0; |
1027 | mouse_slip_wheel_speed = 0; |
993 | } |
1028 | } |
… | |
… | |
1013 | && (ev.xclient.data.l[0] == DndFile |
1048 | && (ev.xclient.data.l[0] == DndFile |
1014 | || ev.xclient.data.l[0] == DndDir |
1049 | || ev.xclient.data.l[0] == DndDir |
1015 | || ev.xclient.data.l[0] == DndLink)) |
1050 | || ev.xclient.data.l[0] == DndLink)) |
1016 | { |
1051 | { |
1017 | /* Get Dnd data */ |
1052 | /* Get Dnd data */ |
1018 | Atom ActualType; |
1053 | Atom ActualType; |
1019 | int ActualFormat; |
1054 | int ActualFormat; |
1020 | unsigned char *data; |
1055 | unsigned char *data; |
1021 | unsigned long Size, RemainingBytes; |
1056 | unsigned long Size, RemainingBytes; |
1022 | |
1057 | |
1023 | XGetWindowProperty (display->display, display->root, |
1058 | XGetWindowProperty (display->display, display->root, |
1024 | xa[XA_DNDSELECTION], |
1059 | xa[XA_DNDSELECTION], |
1025 | 0L, 1000000L, |
1060 | 0L, 1000000L, |
1026 | False, AnyPropertyType, |
1061 | False, AnyPropertyType, |
… | |
… | |
1029 | &data); |
1064 | &data); |
1030 | XChangeProperty (display->display, display->root, |
1065 | XChangeProperty (display->display, display->root, |
1031 | XA_CUT_BUFFER0, XA_STRING, |
1066 | XA_CUT_BUFFER0, XA_STRING, |
1032 | 8, PropModeReplace, |
1067 | 8, PropModeReplace, |
1033 | data, STRLEN (data)); |
1068 | data, STRLEN (data)); |
|
|
1069 | XFree (data); |
1034 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1070 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1035 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1071 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1036 | } |
1072 | } |
1037 | #endif /* OFFIX_DND */ |
1073 | #endif /* OFFIX_DND */ |
1038 | break; |
1074 | break; |
… | |
… | |
1176 | { |
1212 | { |
1177 | #ifdef NO_SLOW_LINK_SUPPORT |
1213 | #ifdef NO_SLOW_LINK_SUPPORT |
1178 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1214 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1179 | ev.xexpose.width, ev.xexpose.height, False); |
1215 | ev.xexpose.width, ev.xexpose.height, False); |
1180 | #else |
1216 | #else |
1181 | // don't understand this, so commented it out |
1217 | // I don't understand this, so I changed it :) |
1182 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1218 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1183 | ev.xexpose.width, ev.xexpose.height, False); |
1219 | ev.xexpose.width, ev.xexpose.height, False); |
1184 | //scr_expose (ev.xexpose.x, 0, |
1220 | //scr_expose (ev.xexpose.x, 0, |
1185 | // ev.xexpose.width, TermWin.height, False); |
1221 | // ev.xexpose.width, TermWin.height, False); |
1186 | #endif |
1222 | #endif |
… | |
… | |
1188 | } |
1224 | } |
1189 | else |
1225 | else |
1190 | { |
1226 | { |
1191 | XEvent unused_event; |
1227 | XEvent unused_event; |
1192 | |
1228 | |
1193 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1229 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1194 | Expose, |
1230 | ; |
1195 | &unused_event)) ; |
|
|
1196 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1231 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1197 | GraphicsExpose, |
1232 | ; |
1198 | &unused_event)) ; |
1233 | |
1199 | if (isScrollbarWindow (ev.xany.window)) |
1234 | if (isScrollbarWindow (ev.xany.window)) |
1200 | { |
1235 | { |
1201 | scrollBar.setIdle (); |
1236 | scrollBar.setIdle (); |
1202 | scrollbar_show (0); |
1237 | scrollbar_show (0); |
1203 | } |
1238 | } |
… | |
… | |
1246 | if (ev.xbutton.y < TermWin.int_bwidth |
1281 | if (ev.xbutton.y < TermWin.int_bwidth |
1247 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1282 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1248 | { |
1283 | { |
1249 | int dist; |
1284 | int dist; |
1250 | |
1285 | |
1251 | pending_scroll_selection=1; |
|
|
1252 | |
|
|
1253 | /* don't clobber the current delay if we are |
1286 | /* don't clobber the current delay if we are |
1254 | * already in the middle of scrolling. |
1287 | * already in the middle of scrolling. |
1255 | */ |
1288 | */ |
1256 | if (scroll_selection_delay<=0) |
1289 | if (!sel_scroll_ev.active) |
1257 | scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; |
1290 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1258 | |
1291 | |
1259 | /* save the event params so we can highlight |
1292 | /* save the event params so we can highlight |
1260 | * the selection in the pending-scroll loop |
1293 | * the selection in the pending-scroll loop |
1261 | */ |
1294 | */ |
1262 | selection_save_x=ev.xbutton.x; |
1295 | selection_save_x=ev.xbutton.x; |
… | |
… | |
1284 | else |
1317 | else |
1285 | { |
1318 | { |
1286 | /* we are within the text window, so we |
1319 | /* we are within the text window, so we |
1287 | * shouldn't be scrolling |
1320 | * shouldn't be scrolling |
1288 | */ |
1321 | */ |
1289 | pending_scroll_selection = 0; |
1322 | if (sel_scroll_ev.active) |
|
|
1323 | sel_scroll_ev.stop(); |
1290 | } |
1324 | } |
1291 | #endif |
1325 | #endif |
1292 | #ifdef MOUSE_THRESHOLD |
1326 | #ifdef MOUSE_THRESHOLD |
1293 | |
1327 | |
1294 | } |
1328 | } |
… | |
… | |
1511 | upordown = 1; /* down */ |
1545 | upordown = 1; /* down */ |
1512 | } |
1546 | } |
1513 | if (upordown) |
1547 | if (upordown) |
1514 | { |
1548 | { |
1515 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1549 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1516 | scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; |
1550 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1517 | #endif |
1551 | #endif |
1518 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1552 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1519 | { |
1553 | { |
1520 | if (upordown < 0) |
1554 | if (upordown < 0) |
1521 | scrollBar.setUp (); |
1555 | scrollBar.setUp (); |
… | |
… | |
1608 | refresh_type &= ~SMOOTH_REFRESH; |
1642 | refresh_type &= ~SMOOTH_REFRESH; |
1609 | #endif |
1643 | #endif |
1610 | |
1644 | |
1611 | } |
1645 | } |
1612 | #ifdef SELECTION_SCROLLING |
1646 | #ifdef SELECTION_SCROLLING |
1613 | pending_scroll_selection=0; |
1647 | if (sel_scroll_ev.active) |
|
|
1648 | sel_scroll_ev.stop(); |
1614 | #endif |
1649 | #endif |
1615 | if (ev.window == TermWin.vt) |
1650 | if (ev.window == TermWin.vt) |
1616 | { |
1651 | { |
1617 | if (reportmode) |
1652 | if (reportmode) |
1618 | { |
1653 | { |
… | |
… | |
1660 | case Button5: |
1695 | case Button5: |
1661 | { |
1696 | { |
1662 | int i; |
1697 | int i; |
1663 | page_dirn v; |
1698 | page_dirn v; |
1664 | |
1699 | |
1665 | v = (ev.button == Button4) ? UP : DN; |
1700 | v = ev.button == Button4 ? UP : DN; |
|
|
1701 | |
1666 | if (ev.state & ShiftMask) |
1702 | if (ev.state & ShiftMask) |
1667 | i = 1; |
1703 | i = 1; |
1668 | else if ((Options & Opt_mouseWheelScrollPage)) |
1704 | else if (Options & Opt_mouseWheelScrollPage) |
1669 | i = TermWin.nrow - 1; |
1705 | i = TermWin.nrow - 1; |
1670 | else |
1706 | else |
1671 | i = 5; |
1707 | i = 5; |
|
|
1708 | |
1672 | # ifdef MOUSE_SLIP_WHEELING |
1709 | # ifdef MOUSE_SLIP_WHEELING |
1673 | if (ev.state & ControlMask) |
1710 | if (ev.state & ControlMask) |
1674 | { |
1711 | { |
1675 | mouse_slip_wheel_speed += (v ? -1 : 1); |
1712 | mouse_slip_wheel_speed += v ? -1 : 1; |
1676 | mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; |
1713 | slip_wheel_ev.start (NOW + SCROLLBAR_CONTINUOUS_DELAY); |
1677 | } |
1714 | } |
1678 | # endif |
1715 | # endif |
1679 | # ifdef JUMP_MOUSE_WHEEL |
1716 | # ifdef JUMP_MOUSE_WHEEL |
1680 | scr_page (v, i); |
1717 | scr_page (v, i); |
1681 | scr_refresh (SMOOTH_REFRESH); |
1718 | scr_refresh (SMOOTH_REFRESH); |
… | |
… | |
1996 | if (!i || prop == NULL) |
2033 | if (!i || prop == NULL) |
1997 | have_pixmap = 0; |
2034 | have_pixmap = 0; |
1998 | else |
2035 | else |
1999 | { |
2036 | { |
2000 | have_pixmap = 1; |
2037 | have_pixmap = 1; |
2001 | rootpixmap = * ((Pixmap *)prop); |
2038 | rootpixmap = *(Pixmap *)prop; |
2002 | XFree (prop); |
2039 | XFree (prop); |
2003 | } |
2040 | } |
2004 | |
2041 | |
2005 | if (have_pixmap) |
2042 | if (have_pixmap) |
2006 | { |
2043 | { |
… | |
… | |
2191 | } |
2228 | } |
2192 | |
2229 | |
2193 | if (ch == NOCHAR) // TODO: improve |
2230 | if (ch == NOCHAR) // TODO: improve |
2194 | break; |
2231 | break; |
2195 | |
2232 | |
2196 | if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') |
2233 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2197 | { |
2234 | { |
2198 | /* Read a text string from the input buffer */ |
2235 | /* Read a text string from the input buffer */ |
2199 | unicode_t buf[UBUFSIZ]; |
2236 | unicode_t buf[UBUFSIZ]; |
2200 | bool refreshnow = false; |
2237 | bool refreshnow = false; |
2201 | int nlines = 0; |
2238 | int nlines = 0; |
… | |
… | |
2206 | for (;;) |
2243 | for (;;) |
2207 | { |
2244 | { |
2208 | seq_begin = cmdbuf_ptr; |
2245 | seq_begin = cmdbuf_ptr; |
2209 | ch = next_char (); |
2246 | ch = next_char (); |
2210 | |
2247 | |
2211 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) |
2248 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2212 | break; |
2249 | break; |
2213 | |
2250 | |
2214 | *str++ = ch; |
2251 | *str++ = ch; |
2215 | |
2252 | |
2216 | if (ch == '\n') |
2253 | if (ch == C0_LF) |
2217 | { |
2254 | { |
2218 | nlines++; |
2255 | nlines++; |
2219 | refresh_count++; |
2256 | refresh_count++; |
2220 | |
2257 | |
2221 | if (! (Options & Opt_jumpScroll) |
2258 | if (! (Options & Opt_jumpScroll) |
… | |
… | |
2256 | */ |
2293 | */ |
2257 | if (refreshnow) |
2294 | if (refreshnow) |
2258 | { |
2295 | { |
2259 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2296 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2260 | refresh_limit++; |
2297 | refresh_limit++; |
2261 | |
2298 | else |
2262 | scr_refresh (refresh_type); |
2299 | scr_refresh (refresh_type); |
2263 | } |
2300 | } |
2264 | |
2301 | |
2265 | } |
2302 | } |
2266 | else |
2303 | else |
2267 | { |
2304 | { |
… | |
… | |
2281 | } |
2318 | } |
2282 | |
2319 | |
2283 | return flag; |
2320 | return flag; |
2284 | } |
2321 | } |
2285 | |
2322 | |
|
|
2323 | // read the next octet |
|
|
2324 | unicode_t |
|
|
2325 | rxvt_term::next_octet () |
|
|
2326 | { |
|
|
2327 | return cmdbuf_ptr < cmdbuf_endp |
|
|
2328 | ? *cmdbuf_ptr++ |
|
|
2329 | : NOCHAR; |
|
|
2330 | } |
|
|
2331 | |
2286 | // read the next character |
2332 | // read the next character |
2287 | unicode_t |
2333 | unicode_t |
2288 | rxvt_term::next_char () |
2334 | rxvt_term::next_char () |
2289 | { |
2335 | { |
2290 | while (cmdbuf_ptr < cmdbuf_endp) |
2336 | while (cmdbuf_ptr < cmdbuf_endp) |
… | |
… | |
2321 | */ |
2367 | */ |
2322 | unicode_t |
2368 | unicode_t |
2323 | rxvt_term::cmd_getc () |
2369 | rxvt_term::cmd_getc () |
2324 | { |
2370 | { |
2325 | unicode_t c = next_char (); |
2371 | unicode_t c = next_char (); |
|
|
2372 | |
|
|
2373 | if (c == NOCHAR) |
|
|
2374 | throw out_of_input; |
|
|
2375 | |
|
|
2376 | return c; |
|
|
2377 | } |
|
|
2378 | |
|
|
2379 | unicode_t |
|
|
2380 | rxvt_term::cmd_get8 () |
|
|
2381 | { |
|
|
2382 | unicode_t c = next_octet (); |
2326 | |
2383 | |
2327 | if (c == NOCHAR) |
2384 | if (c == NOCHAR) |
2328 | throw out_of_input; |
2385 | throw out_of_input; |
2329 | |
2386 | |
2330 | return c; |
2387 | return c; |
… | |
… | |
2460 | break; |
2517 | break; |
2461 | case C0_SI: /* shift in - acs */ |
2518 | case C0_SI: /* shift in - acs */ |
2462 | scr_charset_choose (0); |
2519 | scr_charset_choose (0); |
2463 | break; |
2520 | break; |
2464 | |
2521 | |
|
|
2522 | #ifdef EIGHT_BIT_CONTROLS |
2465 | // 8-bit controls |
2523 | // 8-bit controls |
2466 | case 0x90: /* DCS */ |
2524 | case 0x90: /* DCS */ |
2467 | process_dcs_seq (); |
2525 | process_dcs_seq (); |
2468 | break; |
2526 | break; |
2469 | case 0x9b: /* CSI */ |
2527 | case 0x9b: /* CSI */ |
2470 | process_csi_seq (); |
2528 | process_csi_seq (); |
2471 | break; |
2529 | break; |
2472 | case 0x9d: /* CSI */ |
2530 | case 0x9d: /* CSI */ |
2473 | process_osc_seq (); |
2531 | process_osc_seq (); |
2474 | break; |
2532 | break; |
|
|
2533 | #endif |
2475 | } |
2534 | } |
2476 | } |
2535 | } |
2477 | /*}}} */ |
2536 | /*}}} */ |
2478 | |
2537 | |
2479 | |
2538 | |
… | |
… | |
2597 | break; |
2656 | break; |
2598 | |
2657 | |
2599 | /* 8.3.87: NEXT LINE */ |
2658 | /* 8.3.87: NEXT LINE */ |
2600 | case C1_NEL: /* ESC E */ |
2659 | case C1_NEL: /* ESC E */ |
2601 | { |
2660 | { |
2602 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2661 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2603 | scr_add_lines (nlcr, 1, 2); |
2662 | scr_add_lines (nlcr, 1, 2); |
2604 | } |
2663 | } |
2605 | break; |
2664 | break; |
2606 | |
2665 | |
2607 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2666 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2668 | |
2727 | |
2669 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2728 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2670 | /* *INDENT-OFF* */ |
2729 | /* *INDENT-OFF* */ |
2671 | enum { |
2730 | enum { |
2672 | CSI_ICH = 0x40, |
2731 | CSI_ICH = 0x40, |
2673 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2732 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2674 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2733 | CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , |
2675 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2734 | CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, |
2676 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2735 | CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, |
2677 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2736 | CSI_HPA, CSI_HPR, CSI_REP, CSI_DA , CSI_VPA, CSI_VPR, CSI_HVP, CSI_TBC, |
2678 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
2737 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
… | |
… | |
3092 | #endif |
3151 | #endif |
3093 | |
3152 | |
3094 | /*----------------------------------------------------------------------*/ |
3153 | /*----------------------------------------------------------------------*/ |
3095 | /* |
3154 | /* |
3096 | * get input up until STRING TERMINATOR (or BEL) |
3155 | * get input up until STRING TERMINATOR (or BEL) |
3097 | * ends_how is terminator used. returned input must be free ()d |
3156 | * ends_how is terminator used. returned input must be free()'d |
3098 | */ |
3157 | */ |
3099 | unsigned char * |
3158 | unsigned char * |
3100 | rxvt_term::get_to_st (unicode_t &ends_how) |
3159 | rxvt_term::get_to_st (unicode_t &ends_how) |
3101 | { |
3160 | { |
3102 | int seen_esc = 0; /* seen escape? */ |
3161 | unicode_t prev = 0, ch; |
3103 | unsigned int n = 0; |
3162 | unsigned int n = 0; |
3104 | unsigned char *s; |
3163 | unsigned char *s; |
3105 | unicode_t ch; |
|
|
3106 | unsigned char string[STRING_MAX]; |
3164 | unsigned char string[STRING_MAX]; |
3107 | |
3165 | |
3108 | while ((ch = cmd_getc ())) |
3166 | while ((ch = cmd_getc ()) != NOCHAR) |
3109 | { |
3167 | { |
3110 | if (ch == C0_BEL || ch == CHAR_ST) |
3168 | if (prev == C0_ESC) |
3111 | break; |
3169 | { |
3112 | |
|
|
3113 | if (seen_esc) |
|
|
3114 | if (ch == 0x5c) /* 7bit ST */ |
3170 | if (ch == 0x5c) /* 7bit ST */ |
3115 | break; |
3171 | break; |
3116 | else |
3172 | else |
3117 | return NULL; |
3173 | return NULL; |
3118 | |
|
|
3119 | if (ch == C0_ESC) |
|
|
3120 | { |
3174 | } |
3121 | seen_esc = 1; |
3175 | else if (ch == C0_BEL || ch == CHAR_ST) |
3122 | continue; |
3176 | break; |
3123 | } |
3177 | else if (ch < 0x20) |
3124 | else if (ch == '\t') |
|
|
3125 | ch = ' '; /* translate '\t' to space */ |
|
|
3126 | else if (ch < 0x20 && (ch != 0x0a && ch != 0x0d)) |
|
|
3127 | return NULL; /* other control character - exit */ |
3178 | return NULL; /* other control character - exit */ |
3128 | |
3179 | |
3129 | if (n >= sizeof (string) - 1) |
3180 | if (n >= sizeof (string) - 1) |
3130 | // stop at some sane length |
3181 | // stop at some sane length |
3131 | return NULL; |
3182 | return NULL; |
3132 | |
3183 | |
|
|
3184 | if (ch == C0_SYN) |
|
|
3185 | { |
|
|
3186 | string[n++] = cmd_get8 (); |
|
|
3187 | prev = 0; |
|
|
3188 | } |
|
|
3189 | else |
3133 | string[n++] = ch; |
3190 | string[n++] = prev = ch; |
3134 | seen_esc = 0; |
|
|
3135 | } |
3191 | } |
3136 | |
3192 | |
3137 | string[n++] = '\0'; |
3193 | string[n++] = '\0'; |
3138 | |
3194 | |
3139 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
3195 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
… | |
… | |
3700 | rendset = 1, rendstyle = RS_Uline; |
3756 | rendset = 1, rendstyle = RS_Uline; |
3701 | break; |
3757 | break; |
3702 | case 5: |
3758 | case 5: |
3703 | rendset = 1, rendstyle = RS_Blink; |
3759 | rendset = 1, rendstyle = RS_Blink; |
3704 | break; |
3760 | break; |
|
|
3761 | //case 6: // scoansi light background |
3705 | case 7: |
3762 | case 7: |
3706 | rendset = 1, rendstyle = RS_RVid; |
3763 | rendset = 1, rendstyle = RS_RVid; |
3707 | break; |
3764 | break; |
3708 | case 8: |
3765 | case 8: |
3709 | // invisible. NYI |
3766 | // invisible. NYI |
|
|
3767 | break; |
|
|
3768 | //case 10: // scoansi acs off |
|
|
3769 | //case 11: // scoansi acs on |
|
|
3770 | //case 12: // scoansi acs on, |0x80 |
|
|
3771 | case 21: // disable bold, blink and invis (some terminals use this) |
|
|
3772 | rendset = 0, rendstyle = RS_Bold | RS_Blink; |
3710 | break; |
3773 | break; |
3711 | case 22: |
3774 | case 22: |
3712 | rendset = 0, rendstyle = RS_Bold; |
3775 | rendset = 0, rendstyle = RS_Bold; |
3713 | break; |
3776 | break; |
3714 | case 24: |
3777 | case 24: |
… | |
… | |
3807 | } |
3870 | } |
3808 | } |
3871 | } |
3809 | } |
3872 | } |
3810 | /*}}} */ |
3873 | /*}}} */ |
3811 | |
3874 | |
3812 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3875 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
3813 | void |
3876 | void |
3814 | rxvt_term::process_graphics () |
3877 | rxvt_term::process_graphics () |
3815 | { |
3878 | { |
3816 | unicode_t ch, cmd = cmd_getc (); |
3879 | unicode_t ch, cmd = cmd_getc (); |
3817 | |
3880 | |