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 | |
… | |
… | |
715 | |
714 | |
716 | bool |
715 | bool |
717 | rxvt_term::pty_fill () |
716 | rxvt_term::pty_fill () |
718 | { |
717 | { |
719 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
718 | ssize_t n = cmdbuf_endp - cmdbuf_ptr; |
|
|
719 | |
|
|
720 | if (CBUFSIZ == n) |
|
|
721 | { |
|
|
722 | rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); |
|
|
723 | n = 0; |
|
|
724 | } |
720 | |
725 | |
721 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
726 | memmove (cmdbuf_base, cmdbuf_ptr, n); |
722 | cmdbuf_ptr = cmdbuf_base; |
727 | cmdbuf_ptr = cmdbuf_base; |
723 | cmdbuf_endp = cmdbuf_ptr + n; |
728 | cmdbuf_endp = cmdbuf_ptr + n; |
724 | |
729 | |
… | |
… | |
742 | SET_LOCALE (locale); |
747 | SET_LOCALE (locale); |
743 | |
748 | |
744 | if (revents & EVENT_WRITE) |
749 | if (revents & EVENT_WRITE) |
745 | tt_write (0, 0); |
750 | tt_write (0, 0); |
746 | else if (revents & EVENT_READ) |
751 | else if (revents & EVENT_READ) |
747 | { |
|
|
748 | // loop, but don't allow a single term to monopolize us |
752 | // 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 ()) |
753 | 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 ()) |
754 | if (cmd_parse ()) |
761 | break; |
755 | break; |
762 | } |
|
|
763 | } |
|
|
764 | } |
756 | } |
765 | |
757 | |
766 | #ifdef POINTER_BLANK |
758 | #ifdef POINTER_BLANK |
767 | void |
759 | void |
768 | rxvt_term::pointer_unblank () |
760 | rxvt_term::pointer_unblank () |
… | |
… | |
1013 | && (ev.xclient.data.l[0] == DndFile |
1005 | && (ev.xclient.data.l[0] == DndFile |
1014 | || ev.xclient.data.l[0] == DndDir |
1006 | || ev.xclient.data.l[0] == DndDir |
1015 | || ev.xclient.data.l[0] == DndLink)) |
1007 | || ev.xclient.data.l[0] == DndLink)) |
1016 | { |
1008 | { |
1017 | /* Get Dnd data */ |
1009 | /* Get Dnd data */ |
1018 | Atom ActualType; |
1010 | Atom ActualType; |
1019 | int ActualFormat; |
1011 | int ActualFormat; |
1020 | unsigned char *data; |
1012 | unsigned char *data; |
1021 | unsigned long Size, RemainingBytes; |
1013 | unsigned long Size, RemainingBytes; |
1022 | |
1014 | |
1023 | XGetWindowProperty (display->display, display->root, |
1015 | XGetWindowProperty (display->display, display->root, |
1024 | xa[XA_DNDSELECTION], |
1016 | xa[XA_DNDSELECTION], |
1025 | 0L, 1000000L, |
1017 | 0L, 1000000L, |
1026 | False, AnyPropertyType, |
1018 | False, AnyPropertyType, |
… | |
… | |
1029 | &data); |
1021 | &data); |
1030 | XChangeProperty (display->display, display->root, |
1022 | XChangeProperty (display->display, display->root, |
1031 | XA_CUT_BUFFER0, XA_STRING, |
1023 | XA_CUT_BUFFER0, XA_STRING, |
1032 | 8, PropModeReplace, |
1024 | 8, PropModeReplace, |
1033 | data, STRLEN (data)); |
1025 | data, STRLEN (data)); |
|
|
1026 | XFree (data); |
1034 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1027 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1035 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1028 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1036 | } |
1029 | } |
1037 | #endif /* OFFIX_DND */ |
1030 | #endif /* OFFIX_DND */ |
1038 | break; |
1031 | break; |
… | |
… | |
1176 | { |
1169 | { |
1177 | #ifdef NO_SLOW_LINK_SUPPORT |
1170 | #ifdef NO_SLOW_LINK_SUPPORT |
1178 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1171 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1179 | ev.xexpose.width, ev.xexpose.height, False); |
1172 | ev.xexpose.width, ev.xexpose.height, False); |
1180 | #else |
1173 | #else |
1181 | // don't understand this, so commented it out |
1174 | // I don't understand this, so I changed it :) |
1182 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1175 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1183 | ev.xexpose.width, ev.xexpose.height, False); |
1176 | ev.xexpose.width, ev.xexpose.height, False); |
1184 | //scr_expose (ev.xexpose.x, 0, |
1177 | //scr_expose (ev.xexpose.x, 0, |
1185 | // ev.xexpose.width, TermWin.height, False); |
1178 | // ev.xexpose.width, TermWin.height, False); |
1186 | #endif |
1179 | #endif |
… | |
… | |
1188 | } |
1181 | } |
1189 | else |
1182 | else |
1190 | { |
1183 | { |
1191 | XEvent unused_event; |
1184 | XEvent unused_event; |
1192 | |
1185 | |
1193 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1186 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1194 | Expose, |
1187 | ; |
1195 | &unused_event)) ; |
|
|
1196 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, |
1188 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1197 | GraphicsExpose, |
1189 | ; |
1198 | &unused_event)) ; |
1190 | |
1199 | if (isScrollbarWindow (ev.xany.window)) |
1191 | if (isScrollbarWindow (ev.xany.window)) |
1200 | { |
1192 | { |
1201 | scrollBar.setIdle (); |
1193 | scrollBar.setIdle (); |
1202 | scrollbar_show (0); |
1194 | scrollbar_show (0); |
1203 | } |
1195 | } |
… | |
… | |
1996 | if (!i || prop == NULL) |
1988 | if (!i || prop == NULL) |
1997 | have_pixmap = 0; |
1989 | have_pixmap = 0; |
1998 | else |
1990 | else |
1999 | { |
1991 | { |
2000 | have_pixmap = 1; |
1992 | have_pixmap = 1; |
2001 | rootpixmap = * ((Pixmap *)prop); |
1993 | rootpixmap = *(Pixmap *)prop; |
2002 | XFree (prop); |
1994 | XFree (prop); |
2003 | } |
1995 | } |
2004 | |
1996 | |
2005 | if (have_pixmap) |
1997 | if (have_pixmap) |
2006 | { |
1998 | { |
… | |
… | |
2191 | } |
2183 | } |
2192 | |
2184 | |
2193 | if (ch == NOCHAR) // TODO: improve |
2185 | if (ch == NOCHAR) // TODO: improve |
2194 | break; |
2186 | break; |
2195 | |
2187 | |
2196 | if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') |
2188 | if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) |
2197 | { |
2189 | { |
2198 | /* Read a text string from the input buffer */ |
2190 | /* Read a text string from the input buffer */ |
2199 | unicode_t buf[UBUFSIZ]; |
2191 | unicode_t buf[UBUFSIZ]; |
2200 | bool refreshnow = false; |
2192 | bool refreshnow = false; |
2201 | int nlines = 0; |
2193 | int nlines = 0; |
… | |
… | |
2206 | for (;;) |
2198 | for (;;) |
2207 | { |
2199 | { |
2208 | seq_begin = cmdbuf_ptr; |
2200 | seq_begin = cmdbuf_ptr; |
2209 | ch = next_char (); |
2201 | ch = next_char (); |
2210 | |
2202 | |
2211 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) |
2203 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2212 | break; |
2204 | break; |
2213 | |
2205 | |
2214 | *str++ = ch; |
2206 | *str++ = ch; |
2215 | |
2207 | |
2216 | if (ch == '\n') |
2208 | if (ch == C0_LF) |
2217 | { |
2209 | { |
2218 | nlines++; |
2210 | nlines++; |
2219 | refresh_count++; |
2211 | refresh_count++; |
2220 | |
2212 | |
2221 | if (! (Options & Opt_jumpScroll) |
2213 | if (! (Options & Opt_jumpScroll) |
… | |
… | |
2256 | */ |
2248 | */ |
2257 | if (refreshnow) |
2249 | if (refreshnow) |
2258 | { |
2250 | { |
2259 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2251 | if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
2260 | refresh_limit++; |
2252 | refresh_limit++; |
2261 | |
2253 | else |
2262 | scr_refresh (refresh_type); |
2254 | scr_refresh (refresh_type); |
2263 | } |
2255 | } |
2264 | |
2256 | |
2265 | } |
2257 | } |
2266 | else |
2258 | else |
2267 | { |
2259 | { |
… | |
… | |
2597 | break; |
2589 | break; |
2598 | |
2590 | |
2599 | /* 8.3.87: NEXT LINE */ |
2591 | /* 8.3.87: NEXT LINE */ |
2600 | case C1_NEL: /* ESC E */ |
2592 | case C1_NEL: /* ESC E */ |
2601 | { |
2593 | { |
2602 | unicode_t nlcr[] = { L'\n', L'\r' }; |
2594 | unicode_t nlcr[] = { C0_LF, C0_CR }; |
2603 | scr_add_lines (nlcr, 1, 2); |
2595 | scr_add_lines (nlcr, 1, 2); |
2604 | } |
2596 | } |
2605 | break; |
2597 | break; |
2606 | |
2598 | |
2607 | /* kidnapped escape sequence: Should be 8.3.48 */ |
2599 | /* kidnapped escape sequence: Should be 8.3.48 */ |
… | |
… | |
2668 | |
2660 | |
2669 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2661 | /*{{{ process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' */ |
2670 | /* *INDENT-OFF* */ |
2662 | /* *INDENT-OFF* */ |
2671 | enum { |
2663 | enum { |
2672 | CSI_ICH = 0x40, |
2664 | CSI_ICH = 0x40, |
2673 | CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, |
2665 | 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 , |
2666 | 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, |
2667 | 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, |
2668 | 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, |
2669 | 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, |
2670 | CSI_SM , CSI_MC , CSI_HPB, CSI_VPB, CSI_RM , CSI_SGR, CSI_DSR, CSI_DAQ, |
… | |
… | |
3092 | #endif |
3084 | #endif |
3093 | |
3085 | |
3094 | /*----------------------------------------------------------------------*/ |
3086 | /*----------------------------------------------------------------------*/ |
3095 | /* |
3087 | /* |
3096 | * get input up until STRING TERMINATOR (or BEL) |
3088 | * get input up until STRING TERMINATOR (or BEL) |
3097 | * ends_how is terminator used. returned input must be free ()d |
3089 | * ends_how is terminator used. returned input must be free()'d |
3098 | */ |
3090 | */ |
3099 | unsigned char * |
3091 | unsigned char * |
3100 | rxvt_term::get_to_st (unicode_t &ends_how) |
3092 | rxvt_term::get_to_st (unicode_t &ends_how) |
3101 | { |
3093 | { |
3102 | int seen_esc = 0; /* seen escape? */ |
3094 | int seen_esc = 0; /* seen escape? */ |
… | |
… | |
3119 | if (ch == C0_ESC) |
3111 | if (ch == C0_ESC) |
3120 | { |
3112 | { |
3121 | seen_esc = 1; |
3113 | seen_esc = 1; |
3122 | continue; |
3114 | continue; |
3123 | } |
3115 | } |
3124 | else if (ch == '\t') |
3116 | else if (ch == C0_HT) |
3125 | ch = ' '; /* translate '\t' to space */ |
3117 | ch = ' '; /* translate '\t' to space */ |
3126 | else if (ch < 0x20 && (ch != 0x0a && ch != 0x0d)) |
3118 | else if (ch < 0x20 && (ch != C0_LF && ch != C0_CR)) |
3127 | return NULL; /* other control character - exit */ |
3119 | return NULL; /* other control character - exit */ |
3128 | |
3120 | |
3129 | if (n >= sizeof (string) - 1) |
3121 | if (n >= sizeof (string) - 1) |
3130 | // stop at some sane length |
3122 | // stop at some sane length |
3131 | return NULL; |
3123 | return NULL; |
… | |
… | |
3700 | rendset = 1, rendstyle = RS_Uline; |
3692 | rendset = 1, rendstyle = RS_Uline; |
3701 | break; |
3693 | break; |
3702 | case 5: |
3694 | case 5: |
3703 | rendset = 1, rendstyle = RS_Blink; |
3695 | rendset = 1, rendstyle = RS_Blink; |
3704 | break; |
3696 | break; |
|
|
3697 | //case 6: // scoansi light background |
3705 | case 7: |
3698 | case 7: |
3706 | rendset = 1, rendstyle = RS_RVid; |
3699 | rendset = 1, rendstyle = RS_RVid; |
3707 | break; |
3700 | break; |
3708 | case 8: |
3701 | case 8: |
3709 | // invisible. NYI |
3702 | // invisible. NYI |
|
|
3703 | break; |
|
|
3704 | //case 10: // scoansi acs off |
|
|
3705 | //case 11: // scoansi acs on |
|
|
3706 | //case 12: // scoansi acs on, |0x80 |
|
|
3707 | case 21: // disable bold, blink and invis (some terminals use this) |
|
|
3708 | rendset = 0, rendstyle = RS_Bold | RS_Blink; |
3710 | break; |
3709 | break; |
3711 | case 22: |
3710 | case 22: |
3712 | rendset = 0, rendstyle = RS_Bold; |
3711 | rendset = 0, rendstyle = RS_Bold; |
3713 | break; |
3712 | break; |
3714 | case 24: |
3713 | case 24: |
… | |
… | |
3807 | } |
3806 | } |
3808 | } |
3807 | } |
3809 | } |
3808 | } |
3810 | /*}}} */ |
3809 | /*}}} */ |
3811 | |
3810 | |
3812 | /*{{{ process Rob Nation's own graphics mode sequences */ |
3811 | /*{{{ (do not) process Rob Nation's own graphics mode sequences */ |
3813 | void |
3812 | void |
3814 | rxvt_term::process_graphics () |
3813 | rxvt_term::process_graphics () |
3815 | { |
3814 | { |
3816 | unicode_t ch, cmd = cmd_getc (); |
3815 | unicode_t ch, cmd = cmd_getc (); |
3817 | |
3816 | |