--- rxvt-unicode/src/command.C 2004/04/02 19:09:52 1.90 +++ rxvt-unicode/src/command.C 2004/07/26 18:01:19 1.97 @@ -1,5 +1,5 @@ /*--------------------------------*-C-*---------------------------------* - * File: command.c + * File: command.C *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. @@ -674,7 +674,6 @@ #ifdef USE_XIM IMSendSpot (); #endif - } display->flush (); @@ -713,11 +712,60 @@ } #endif +#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING +void +rxvt_term::cont_scroll_cb (time_watcher &w) +{ + if ((scrollbar_isUp() || scrollbar_isDn()) && + scr_page (scrollbar_isUp() ? UP : DN, 1)) + { + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; + w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); + } +} +#endif + +#ifdef SELECTION_SCROLLING +void +rxvt_term::sel_scroll_cb (time_watcher &w) +{ + if (scr_page (scroll_selection_dir, scroll_selection_lines)) + { + selection_extend (selection_save_x, selection_save_y, selection_save_state); + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; + w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); + } +} +#endif + +#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) +void +rxvt_term::slip_wheel_cb (time_watcher &w) +{ + if (mouse_slip_wheel_speed == 0 + || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) + : scr_page (UP, mouse_slip_wheel_speed)) + { + refresh_type |= SMOOTH_REFRESH; + want_refresh = 1; + w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); + } +} +#endif + bool rxvt_term::pty_fill () { ssize_t n = cmdbuf_endp - cmdbuf_ptr; + if (CBUFSIZ == n) + { + rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); + n = 0; + } + memmove (cmdbuf_base, cmdbuf_ptr, n); cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; @@ -744,23 +792,10 @@ if (revents & EVENT_WRITE) tt_write (0, 0); else if (revents & EVENT_READ) - { - // loop, but don't allow a single term to monopolize us - // the number of loops is fully arbitrary, and thus wrong - while (pty_fill ()) - { - if (!seen_input) - { - seen_input = 1; - /* once we know the shell is running, send the screen size. Again! */ - // I don't know why, btw. - tt_winch (); - } - - if (cmd_parse ()) - break; - } - } + // loop, but don't allow a single term to monopolize us + while (pty_fill ()) + if (cmd_parse ()) + break; } #ifdef POINTER_BLANK @@ -981,11 +1016,11 @@ #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) case KeyRelease: { - if (! (ev.xkey.state & ControlMask)) - mouse_slip_wheel_speed = 0; + if (!(ev.xkey.state & ControlMask)) + slip_wheel_ev.stop (); else { - KeySym ks; + KeySym ks; ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0); if (ks == XK_Control_L || ks == XK_Control_R) @@ -1015,10 +1050,10 @@ || ev.xclient.data.l[0] == DndLink)) { /* Get Dnd data */ - Atom ActualType; - int ActualFormat; - unsigned char *data; - unsigned long Size, RemainingBytes; + Atom ActualType; + int ActualFormat; + unsigned char *data; + unsigned long Size, RemainingBytes; XGetWindowProperty (display->display, display->root, xa[XA_DNDSELECTION], @@ -1031,6 +1066,7 @@ XA_CUT_BUFFER0, XA_STRING, 8, PropModeReplace, data, STRLEN (data)); + XFree (data); selection_paste (display->root, XA_CUT_BUFFER0, True); XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); } @@ -1178,7 +1214,7 @@ scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); #else - // don't understand this, so commented it out + // I don't understand this, so I changed it :) scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); //scr_expose (ev.xexpose.x, 0, @@ -1190,12 +1226,11 @@ { XEvent unused_event; - while (XCheckTypedWindowEvent (display->display, ev.xany.window, - Expose, - &unused_event)) ; - while (XCheckTypedWindowEvent (display->display, ev.xany.window, - GraphicsExpose, - &unused_event)) ; + while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) + ; + while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) + ; + if (isScrollbarWindow (ev.xany.window)) { scrollBar.setIdle (); @@ -1248,13 +1283,11 @@ { int dist; - pending_scroll_selection=1; - /* don't clobber the current delay if we are * already in the middle of scrolling. */ - if (scroll_selection_delay<=0) - scroll_selection_delay=SCROLLBAR_CONTINUOUS_DELAY; + if (!sel_scroll_ev.active) + sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); /* save the event params so we can highlight * the selection in the pending-scroll loop @@ -1286,7 +1319,8 @@ /* we are within the text window, so we * shouldn't be scrolling */ - pending_scroll_selection = 0; + if (sel_scroll_ev.active) + sel_scroll_ev.stop(); } #endif #ifdef MOUSE_THRESHOLD @@ -1513,7 +1547,7 @@ if (upordown) { #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING - scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY; + cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); #endif if (scr_page (upordown < 0 ? UP : DN, 1)) { @@ -1610,7 +1644,8 @@ } #ifdef SELECTION_SCROLLING - pending_scroll_selection=0; + if (sel_scroll_ev.active) + sel_scroll_ev.stop(); #endif if (ev.window == TermWin.vt) { @@ -1662,18 +1697,20 @@ int i; page_dirn v; - v = (ev.button == Button4) ? UP : DN; + v = ev.button == Button4 ? UP : DN; + if (ev.state & ShiftMask) i = 1; - else if ((Options & Opt_mouseWheelScrollPage)) + else if (Options & Opt_mouseWheelScrollPage) i = TermWin.nrow - 1; else i = 5; + # ifdef MOUSE_SLIP_WHEELING if (ev.state & ControlMask) { - mouse_slip_wheel_speed += (v ? -1 : 1); - mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY; + mouse_slip_wheel_speed += v ? -1 : 1; + slip_wheel_ev.start (NOW + SCROLLBAR_CONTINUOUS_DELAY); } # endif # ifdef JUMP_MOUSE_WHEEL @@ -1998,7 +2035,7 @@ else { have_pixmap = 1; - rootpixmap = * ((Pixmap *)prop); + rootpixmap = *(Pixmap *)prop; XFree (prop); } @@ -2193,7 +2230,7 @@ if (ch == NOCHAR) // TODO: improve break; - if (!IS_CONTROL (ch) || ch == '\t' || ch == '\n' || ch == '\r') + if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) { /* Read a text string from the input buffer */ unicode_t buf[UBUFSIZ]; @@ -2208,12 +2245,12 @@ seq_begin = cmdbuf_ptr; ch = next_char (); - if (ch == NOCHAR || (IS_CONTROL (ch) && ch != '\t' && ch != '\n' && ch != '\r')) + if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) break; *str++ = ch; - if (ch == '\n') + if (ch == C0_LF) { nlines++; refresh_count++; @@ -2258,8 +2295,8 @@ { if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) refresh_limit++; - - scr_refresh (refresh_type); + else + scr_refresh (refresh_type); } } @@ -2283,6 +2320,15 @@ return flag; } +// read the next octet +unicode_t +rxvt_term::next_octet () +{ + return cmdbuf_ptr < cmdbuf_endp + ? *cmdbuf_ptr++ + : NOCHAR; +} + // read the next character unicode_t rxvt_term::next_char () @@ -2330,6 +2376,17 @@ return c; } +unicode_t +rxvt_term::cmd_get8 () +{ + unicode_t c = next_octet (); + + if (c == NOCHAR) + throw out_of_input; + + return c; +} + /*{{{ print pipe */ /*----------------------------------------------------------------------*/ #ifdef PRINTPIPE @@ -2462,6 +2519,7 @@ scr_charset_choose (0); break; +#ifdef EIGHT_BIT_CONTROLS // 8-bit controls case 0x90: /* DCS */ process_dcs_seq (); @@ -2472,6 +2530,7 @@ case 0x9d: /* CSI */ process_osc_seq (); break; +#endif } } /*}}} */ @@ -2599,7 +2658,7 @@ /* 8.3.87: NEXT LINE */ case C1_NEL: /* ESC E */ { - unicode_t nlcr[] = { L'\n', L'\r' }; + unicode_t nlcr[] = { C0_LF, C0_CR }; scr_add_lines (nlcr, 1, 2); } break; @@ -2670,7 +2729,7 @@ /* *INDENT-OFF* */ enum { CSI_ICH = 0x40, - CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, + CSI_CUU, CSI_CUD, CSI_CUF, CSI_CUB, CSI_CNL, CSI_CPL, CSI_CHA, CSI_CUP, CSI_CHT, CSI_ED , CSI_EL , CSI_IL , CSI_DL , CSI_EF , CSI_EA , CSI_DCH, CSI_SEE, CSI_CPR, CSI_SU , CSI_SD , CSI_NP , CSI_PP , CSI_CTC, CSI_ECH, CSI_CVT, CSI_CBT, CSI_SRS, CSI_PTX, CSI_SDS, CSI_SIMD, CSI_5F, @@ -3094,44 +3153,41 @@ /*----------------------------------------------------------------------*/ /* * get input up until STRING TERMINATOR (or BEL) - * ends_how is terminator used. returned input must be free ()d + * ends_how is terminator used. returned input must be free()'d */ unsigned char * rxvt_term::get_to_st (unicode_t &ends_how) { - int seen_esc = 0; /* seen escape? */ + unicode_t prev = 0, ch; unsigned int n = 0; unsigned char *s; - unicode_t ch; unsigned char string[STRING_MAX]; - while ((ch = cmd_getc ())) + while ((ch = cmd_getc ()) != NOCHAR) { - if (ch == C0_BEL || ch == CHAR_ST) - break; - - if (seen_esc) - if (ch == 0x5c) /* 7bit ST */ - break; - else - return NULL; - - if (ch == C0_ESC) + if (prev == C0_ESC) { - seen_esc = 1; - continue; + if (ch == 0x5c) /* 7bit ST */ + break; + else + return NULL; } - else if (ch == '\t') - ch = ' '; /* translate '\t' to space */ - else if (ch < 0x20 && (ch != 0x0a && ch != 0x0d)) + else if (ch == C0_BEL || ch == CHAR_ST) + break; + else if (ch < 0x20) return NULL; /* other control character - exit */ if (n >= sizeof (string) - 1) // stop at some sane length return NULL; - string[n++] = ch; - seen_esc = 0; + if (ch == C0_SYN) + { + string[n++] = cmd_get8 (); + prev = 0; + } + else + string[n++] = prev = ch; } string[n++] = '\0'; @@ -3702,12 +3758,19 @@ case 5: rendset = 1, rendstyle = RS_Blink; break; + //case 6: // scoansi light background case 7: rendset = 1, rendstyle = RS_RVid; break; case 8: // invisible. NYI break; + //case 10: // scoansi acs off + //case 11: // scoansi acs on + //case 12: // scoansi acs on, |0x80 + case 21: // disable bold, blink and invis (some terminals use this) + rendset = 0, rendstyle = RS_Bold | RS_Blink; + break; case 22: rendset = 0, rendstyle = RS_Bold; break; @@ -3809,7 +3872,7 @@ } /*}}} */ -/*{{{ process Rob Nation's own graphics mode sequences */ +/*{{{ (do not) process Rob Nation's own graphics mode sequences */ void rxvt_term::process_graphics () {