--- rxvt-unicode/src/command.C 2004/04/02 19:09:52 1.90 +++ rxvt-unicode/src/command.C 2004/08/10 22:36:30 1.120 @@ -1,5 +1,5 @@ /*--------------------------------*-C-*---------------------------------* - * File: command.c + * File: command.C *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. @@ -308,7 +308,7 @@ break; #ifdef XK_KP_Left - case XK_KP_Up: /* \033Ox or standard */ + case XK_KP_Up: /* \033Ox or standard */ case XK_KP_Down: /* \033Or or standard */ case XK_KP_Right: /* \033Ov or standard */ case XK_KP_Left: /* \033Ot or standard */ @@ -663,7 +663,6 @@ want_full_refresh = 0; scr_clear (); scr_touch (false); - want_refresh = 1; } #endif @@ -674,10 +673,11 @@ #ifdef USE_XIM IMSendSpot (); #endif - } display->flush (); + + flush_ev.stop (); } void @@ -686,6 +686,20 @@ SET_R (this); SET_LOCALE (locale); + display->flush (); + + if (want_refresh && !flush_ev.active) + flush_ev.start (NOW + 0.01); +} + +void +rxvt_term::flush_cb (time_watcher &w) +{ + SET_R (this); + SET_LOCALE (locale); + + refresh_limit = 1; + refresh_count = 0; flush (); } @@ -713,11 +727,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,38 +807,27 @@ 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 void rxvt_term::pointer_unblank () { XDefineCursor (display->display, TermWin.vt, TermWin_cursor); recolour_cursor (); +#ifdef POINTER_BLANK hidden_pointer = 0; if (Options & Opt_pointerBlank) pointer_ev.start (NOW + pointerBlankDelay); +#endif } +#ifdef POINTER_BLANK void rxvt_term::pointer_blank () { @@ -981,11 +1033,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 +1067,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 +1083,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); } @@ -1038,7 +1091,7 @@ break; case MappingNotify: - XRefreshKeyboardMapping (& (ev.xmapping)); + XRefreshKeyboardMapping (&ev.xmapping); break; /* @@ -1079,6 +1132,15 @@ if (Options & Opt_cursorBlink) cursor_blink_ev.start (NOW + BLINK_INTERVAL); #endif +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + PixColors = PixColorsFocused; + set_colorfgbg (); + scr_clear (); + scr_touch (true); + } +#endif } break; @@ -1097,6 +1159,15 @@ cursor_blink_ev.stop (); hidden_cursor = 0; #endif +#ifdef OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + PixColors = PixColorsUnFocused; + set_colorfgbg (); + scr_clear (); + scr_touch (true); + } +#endif } break; @@ -1115,22 +1186,14 @@ while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); if (szHint.width != width || szHint.height != height) - { - D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height)); - resize_all_windows (width, height, 1); - } -#ifdef DEBUG_SIZE - else - { - D_SIZE ((stderr, "Size: Not resizing")); - } -#endif + resize_all_windows (width, height, 1); + #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ if (Options & Opt_transparent) { check_our_parents (); if (am_transparent) - want_full_refresh = 1; + want_refresh = want_full_refresh = 1; } #endif } @@ -1174,28 +1237,28 @@ case Expose: if (ev.xany.window == TermWin.vt) { -#ifdef NO_SLOW_LINK_SUPPORT - scr_expose (ev.xexpose.x, ev.xexpose.y, - ev.xexpose.width, ev.xexpose.height, False); -#else - // don't understand this, so commented it out - scr_expose (ev.xexpose.x, ev.xexpose.y, - ev.xexpose.width, ev.xexpose.height, False); - //scr_expose (ev.xexpose.x, 0, - // ev.xexpose.width, TermWin.height, False); -#endif - want_refresh = 1; + do + scr_expose (ev.xexpose.x, ev.xexpose.y, + ev.xexpose.width, ev.xexpose.height, False); + while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); + + ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; + + while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) + scr_expose (ev.xexpose.x, ev.xexpose.y, + ev.xexpose.width, ev.xexpose.height, False); + + scr_refresh (refresh_type); } else { 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 (); @@ -1205,6 +1268,11 @@ if (menubar_visible () && isMenuBarWindow (ev.xany.window)) menubar_expose (); #endif + +#ifdef TRANSPARENT + if (am_transparent && ev.xany.window == TermWin.parent[0]) + XClearWindow (display->display, ev.xany.window); +#endif } break; @@ -1248,13 +1316,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 +1352,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 @@ -1347,7 +1414,7 @@ /* FALLTHROUGH */ case ReparentNotify: if ((Options & Opt_transparent) && check_our_parents () && am_transparent) - want_full_refresh = 1; + want_refresh = want_full_refresh = 1; break; #endif } @@ -1513,7 +1580,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)) { @@ -1539,11 +1606,12 @@ csrO = scrollBar.bot - scrollBar.top; break; } + if (scrollBar.style == R_SB_XTERM || scrollbar_above_slider (ev.y) || scrollbar_below_slider (ev.y)) - scr_move_to ( scrollbar_position (ev.y) - csrO, - scrollbar_size ()); + scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); + scrollBar.setMotion (); break; @@ -1577,6 +1645,7 @@ * scrollbar_position (ev.y) / scrollbar_size ())); } + break; } } @@ -1610,7 +1679,8 @@ } #ifdef SELECTION_SCROLLING - pending_scroll_selection=0; + if (sel_scroll_ev.active) + sel_scroll_ev.stop(); #endif if (ev.window == TermWin.vt) { @@ -1662,37 +1732,48 @@ 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; + if (mouse_slip_wheel_speed < -TermWin.nrow) mouse_slip_wheel_speed = -TermWin.nrow; + if (mouse_slip_wheel_speed > +TermWin.nrow) mouse_slip_wheel_speed = +TermWin.nrow; + + if (slip_wheel_ev.at < NOW) + slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; + + slip_wheel_ev.start (); } + else + { # endif # ifdef JUMP_MOUSE_WHEEL - scr_page (v, i); - scr_refresh (SMOOTH_REFRESH); - scrollbar_show (1); -# else - while (i--) - { - scr_page (v, 1); + scr_page (v, i); scr_refresh (SMOOTH_REFRESH); scrollbar_show (1); - } +# else + while (i--) + { + scr_page (v, 1); + scr_refresh (SMOOTH_REFRESH); + scrollbar_show (1); + } # endif - +# ifdef MOUSE_SLIP_WHEELING + } +#endif } break; #endif - } } #ifdef MENUBAR @@ -1703,238 +1784,234 @@ #ifdef TRANSPARENT #if TINTING -/* shading taken from eterm-0.9.2 */ -/* RGB 15 */ +/* taken from aterm-0.4.2 */ + +typedef uint32_t RUINT32T; -static void -shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm) +void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm) { - unsigned char *ptr; - int x, y; + int sh_r, sh_g, sh_b; + RUINT32T mask_r, mask_g, mask_b; + RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; + unsigned int lower_lim_r, lower_lim_g, lower_lim_b; + unsigned int upper_lim_r, upper_lim_g, upper_lim_b; + int i; - ptr = (unsigned char *)data + (w * sizeof(uint16_t)); - if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { - /* No saturation */ - for (y = h; --y >= 0;) { - for (x = -w; x < 0; x++) { - int r, g, b; - - b = ((uint16_t *) ptr)[x]; - r = (b & 0x7c00) * rm; - g = (b & 0x3e0) * gm; - b = (b & 0x1f) * bm; - ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) - | ((g >> 8) & 0x3e0) - | ((b >> 8) & 0x1f); - } - ptr += bpl; - } - } else { - for (y = h; --y >= 0;) { - for (x = -w; x < 0; x++) { - int r, g, b; - - b = ((uint16_t *) ptr)[x]; - r = (b & 0x7c00) * rm; - g = (b & 0x3e0) * gm; - b = (b & 0x1f) * bm; - r |= (!(r >> 15) - 1); - g |= (!(g >> 10) - 1); - b |= (!(b >> 5) - 1); - ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) - | ((g >> 8) & 0x3e0) - | ((b >> 8) & 0x1f); - } - ptr += bpl; - } - } -} - -/* RGB 16 */ -static void -shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm) -{ - unsigned char *ptr; - int x, y; - - ptr = (unsigned char *)data + (w * sizeof(uint16_t)); - if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { - /* No saturation */ - for (y = h; --y >= 0;) { - for (x = -w; x < 0; x++) { - int r, g, b; - - b = ((uint16_t *) ptr)[x]; - r = (b & 0xf800) * rm; - g = (b & 0x7e0) * gm; - b = (b & 0x1f) * bm; - ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800) - | ((g >> 8) & 0x7e0) - | ((b >> 8) & 0x1f); - } - ptr += bpl; - } - } else { - for (y = h; --y >= 0;) { - for (x = -w; x < 0; x++) { - int r, g, b; - - b = ((uint16_t *) ptr)[x]; - r = (b & 0xf800) * rm; - g = (b & 0x7e0) * gm; - b = (b & 0x1f) * bm; - r |= (!(r >> 16) - 1); - g |= (!(g >> 11) - 1); - b |= (!(b >> 5) - 1); - ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800) - | ((g >> 8) & 0x7e0) - | ((b >> 8) & 0x1f); - } - ptr += bpl; - } - } -} - -/* RGB 24 */ -static void -shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm) -{ - unsigned char *ptr; - int x, y; - - ptr = (unsigned char *)data + (w * 3); - if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { - /* No saturation */ - for (y = h; --y >= 0;) { - for (x = -(w * 3); x < 0; x += 3) { - int r, g, b; - - if (byteorder.big_endian()) { - r = (ptr[x + 0] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 2] * bm) >> 8; - ptr[x + 0] = r; - ptr[x + 1] = g; - ptr[x + 2] = b; - } else { - r = (ptr[x + 2] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 0] * bm) >> 8; - ptr[x + 2] = r; - ptr[x + 1] = g; - ptr[x + 0] = b; - } - } - ptr += bpl; - } - } else { - for (y = h; --y >= 0;) { - for (x = -(w * 3); x < 0; x += 3) { - int r, g, b; - - if (byteorder.big_endian()) { - r = (ptr[x + 0] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 2] * bm) >> 8; - - r |= (!(r >> 8) - 1); - g |= (!(g >> 8) - 1); - b |= (!(b >> 8) - 1); - - ptr[x + 0] = r; - ptr[x + 1] = g; - ptr[x + 2] = b; - } else { - r = (ptr[x + 2] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 0] * bm) >> 8; - - r |= (!(r >> 8) - 1); - g |= (!(g >> 8) - 1); - b |= (!(b >> 8) - 1); - - ptr[x + 2] = r; - ptr[x + 1] = g; - ptr[x + 0] = b; - } - } - ptr += bpl; - } - } -} - -/* RGB 32 */ -static void -shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm) -{ - unsigned char *ptr; - int x, y; - - ptr = (unsigned char *)data + (w * 4); - if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { - /* No saturation */ - for (y = h; --y >= 0;) { - if (byteorder.big_endian()) { - for (x = -(w * 4); x < 0; x += 4) { - int r, g, b; - - r = (ptr[x + 1] * rm) >> 8; - g = (ptr[x + 2] * gm) >> 8; - b = (ptr[x + 3] * bm) >> 8; - ptr[x + 1] = r; - ptr[x + 2] = g; - ptr[x + 3] = b; - } - } else { - for (x = -(w * 4); x < 0; x += 4) { - int r, g, b; - - r = (ptr[x + 2] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 0] * bm) >> 8; - ptr[x + 2] = r; - ptr[x + 1] = g; - ptr[x + 0] = b; - } - } - ptr += bpl; - } - } else { - for (y = h; --y >= 0;) { - for (x = -(w * 4); x < 0; x += 4) { - int r, g, b; - - if (byteorder.big_endian()) { - r = (ptr[x + 1] * rm) >> 8; - g = (ptr[x + 2] * gm) >> 8; - b = (ptr[x + 3] * bm) >> 8; - - r |= (!(r >> 8) - 1); - g |= (!(g >> 8) - 1); - b |= (!(b >> 8) - 1); - - ptr[x + 1] = r; - ptr[x + 2] = g; - ptr[x + 3] = b; - } else { - r = (ptr[x + 2] * rm) >> 8; - g = (ptr[x + 1] * gm) >> 8; - b = (ptr[x + 0] * bm) >> 8; - - r |= (!(r >> 8) - 1); - g |= (!(g >> 8) - 1); - b |= (!(b >> 8) - 1); - - ptr[x + 2] = r; - ptr[x + 1] = g; - ptr[x + 0] = b; - } - } - ptr += bpl; + Visual* visual = display->visual; + + if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; + + /* for convenience */ + mask_r = visual->red_mask; + mask_g = visual->green_mask; + mask_b = visual->blue_mask; + + /* boring lookup table pre-initialization */ + switch (srcImage->bits_per_pixel) { + case 15: + if ((mask_r != 0x7c00) || + (mask_g != 0x03e0) || + (mask_b != 0x001f)) + return; + lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); + lookup_r = lookup; + lookup_g = lookup+32; + lookup_b = lookup+32+32; + sh_r = 10; + sh_g = 5; + sh_b = 0; + break; + case 16: + if ((mask_r != 0xf800) || + (mask_g != 0x07e0) || + (mask_b != 0x001f)) + return; + lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); + lookup_r = lookup; + lookup_g = lookup+32; + lookup_b = lookup+32+64; + sh_r = 11; + sh_g = 5; + sh_b = 0; + break; + case 24: + if ((mask_r != 0xff0000) || + (mask_g != 0x00ff00) || + (mask_b != 0x0000ff)) + return; + lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); + lookup_r = lookup; + lookup_g = lookup+256; + lookup_b = lookup+256+256; + sh_r = 16; + sh_g = 8; + sh_b = 0; + break; + case 32: + if ((mask_r != 0xff0000) || + (mask_g != 0x00ff00) || + (mask_b != 0x0000ff)) + return; + lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); + lookup_r = lookup; + lookup_g = lookup+256; + lookup_b = lookup+256+256; + sh_r = 16; + sh_g = 8; + sh_b = 0; + break; + default: + return; /* we do not support this color depth */ + } + + /* prepare limits for color transformation (each channel is handled separately) */ + if (shade < 0) { + shade = -shade; + if (shade < 0) shade = 0; + if (shade > 100) shade = 100; + + lower_lim_r = 65535-rm; + lower_lim_g = 65535-gm; + lower_lim_b = 65535-bm; + + lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); + lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); + lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); + + upper_lim_r = upper_lim_g = upper_lim_b = 65535; + } else { + if (shade < 0) shade = 0; + if (shade > 100) shade = 100; + + lower_lim_r = lower_lim_g = lower_lim_b = 0; + + upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); + upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); + upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); + } + + /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ + if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) + { + unsigned int tmp; + + tmp = lower_lim_r; + lower_lim_r = lower_lim_b; + lower_lim_b = tmp; + + tmp = upper_lim_r; + upper_lim_r = upper_lim_b; + upper_lim_b = tmp; + } + + /* fill our lookup tables */ + for (i = 0; i <= mask_r>>sh_r; i++) + { + RUINT32T tmp; + tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); + tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); + lookup_r[i] = (tmp/65535)<>sh_g; i++) + { + RUINT32T tmp; + tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); + tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); + lookup_g[i] = (tmp/65535)<>sh_b; i++) + { + RUINT32T tmp; + tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); + tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); + lookup_b[i] = (tmp/65535)<bits_per_pixel) + { + case 15: + { + unsigned short *p1, *pf, *p, *pl; + p1 = (unsigned short *) srcImage->data; + pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); + while (p1 < pf) + { + p = p1; + pl = p1 + srcImage->width; + for (; p < pl; p++) + { + *p = lookup_r[(*p & 0x7c00)>>10] | + lookup_g[(*p & 0x03e0)>> 5] | + lookup_b[(*p & 0x001f)]; } + p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); + } + break; } -} + case 16: + { + unsigned short *p1, *pf, *p, *pl; + p1 = (unsigned short *) srcImage->data; + pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); + while (p1 < pf) + { + p = p1; + pl = p1 + srcImage->width; + for (; p < pl; p++) + { + *p = lookup_r[(*p & 0xf800)>>11] | + lookup_g[(*p & 0x07e0)>> 5] | + lookup_b[(*p & 0x001f)]; + } + p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); + } + break; + } + case 24: + { + unsigned char *p1, *pf, *p, *pl; + p1 = (unsigned char *) srcImage->data; + pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); + while (p1 < pf) + { + p = p1; + pl = p1 + srcImage->width * 3; + for (; p < pl; p += 3) + { + p[0] = lookup_r[(p[0] & 0xff0000)>>16]; + p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; + p[2] = lookup_r[(p[2] & 0x0000ff)]; + } + p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); + } + break; + } + case 32: + { + RUINT32T *p1, *pf, *p, *pl; + p1 = (RUINT32T *) srcImage->data; + pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); + + while (p1 < pf) + { + p = p1; + pl = p1 + srcImage->width; + for (; p < pl; p++) + { + *p = lookup_r[(*p & 0xff0000)>>16] | + lookup_g[(*p & 0x00ff00)>> 8] | + lookup_b[(*p & 0x0000ff)] | + (*p & ~0xffffff); + } + p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); + } + break; + } + } + free (lookup); +} #endif /* @@ -1967,7 +2044,7 @@ if (am_transparent) { pchanged = 1; - XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); + XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); am_transparent = am_pixmap_trans = 0; } @@ -1993,12 +2070,16 @@ 0L, 1L, False, XA_PIXMAP, &atype, &aformat, &nitems, &bytes_after, &prop) == Success); - if (!i || prop == NULL) + if (!i || prop == NULL +#if TINTING + || !rs[Rs_color + Color_tint] +#endif + ) have_pixmap = 0; else { have_pixmap = 1; - rootpixmap = * ((Pixmap *)prop); + rootpixmap = *(Pixmap *)prop; XFree (prop); } @@ -2065,20 +2146,12 @@ #if TINTING if (ISSET_PIXCOLOR (Color_tint)) { - unsigned short shade, rm, gm, bm; - - PixColors[Color_tint].get (display, rm, gm, bm); + unsigned short rm, gm, bm; + int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; - rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... + PixColorsFocused[Color_tint].get (display, rm, gm, bm); - /* Determine bitshift and bitmask values */ - switch (image->bits_per_pixel) - { - case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; - case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; - case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; - case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break; - } + ShadeXImage (display, image, shade, rm, gm, bm); } #endif @@ -2089,8 +2162,8 @@ nx, ny, image->width, image->height); XFreeGC (display->display, gc); XDestroyImage (image); - XSetWindowBackgroundPixmap (display->display, TermWin.vt, - TermWin.pixmap); + XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); + XClearWindow (display->display, TermWin.parent[0]); if (!am_transparent || !am_pixmap_trans) pchanged = 1; @@ -2145,8 +2218,8 @@ if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) { D_X ((stderr, "InheritPixmap Turning off")); - XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); - XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); + XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]); + XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]); am_transparent = 0; /* XXX: also turn off Opt_transparent? */ } @@ -2159,7 +2232,10 @@ #endif D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); for (n = 0; n < (unsigned int)i; n++) - XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); + { + XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); + XClearWindow (display->display, TermWin.parent[n]); + } XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); am_transparent = 1; @@ -2169,6 +2245,15 @@ TermWin.parent[i] = None; } + // this is experimental + if (scrollBar.win) + { + XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); + XClearWindow (display->display, scrollBar.win); + scrollBar.setIdle (); + scrollbar_show (0); + } + return pchanged; } #endif @@ -2193,7 +2278,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]; @@ -2201,33 +2286,27 @@ int nlines = 0; unicode_t *str = buf; - *str++ = ch; - for (;;) { - 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++; - if (! (Options & Opt_jumpScroll) - || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) + if (!(Options & Opt_jumpScroll) + || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) { refreshnow = true; - flag = true; ch = NOCHAR; break; } - // scr_add_lines only works for nlines < TermWin.nrow - 1. + // scr_add_lines only works for nlines <= TermWin.nrow - 1. if (nlines >= TermWin.nrow - 1) { scr_add_lines (buf, nlines, str - buf); @@ -2241,6 +2320,9 @@ ch = NOCHAR; break; } + + seq_begin = cmdbuf_ptr; + ch = next_char (); } scr_add_lines (buf, nlines, str - buf); @@ -2250,16 +2332,16 @@ * What the heck I'll cheat and only refresh less than every page-full. * the number of pages between refreshes is refresh_limit, which * is incremented here because we must be doing flat-out scrolling. - * - * refreshing should be correct for small scrolls, because of the - * time-out */ if (refreshnow) { if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) refresh_limit++; - - scr_refresh (refresh_type); + else + { + flag = true; + scr_refresh (refresh_type); + } } } @@ -2283,6 +2365,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 +2421,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 +2564,7 @@ scr_charset_choose (0); break; +#ifdef EIGHT_BIT_CONTROLS // 8-bit controls case 0x90: /* DCS */ process_dcs_seq (); @@ -2472,6 +2575,7 @@ case 0x9d: /* CSI */ process_osc_seq (); break; +#endif } } /*}}} */ @@ -2599,7 +2703,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 +2774,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 +3198,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'; @@ -3198,7 +3299,7 @@ if (Options & Opt_insecure) { unsigned short r, g, b; - PixColors[color].get (display, r, g, b); + PixColorsFocused[color].get (display, r, g, b); tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); } } @@ -3313,7 +3414,7 @@ if (Options & Opt_insecure) { unsigned short r, g, b; - PixColors[color + minCOLOR].get (display, r, g, b); + PixColorsFocused[color + minCOLOR].get (display, r, g, b); tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); } } @@ -3696,21 +3797,35 @@ case 1: rendset = 1, rendstyle = RS_Bold; break; + //case 2: // faint or second colour case 4: rendset = 1, rendstyle = RS_Uline; break; - case 5: + case 5: // slowly blinking + case 6: // rapidly blinking 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 9: // crossed out + //case 10: // scoansi acs off, primary font + //case 11: // scoansi acs on, first alt font + //case 12: // scoansi acs on, |0x80, second alt font + //... + //case 19: // ninth alt font + //case 20: // gothic + case 21: // disable bold, faint + rendset = 0, rendstyle = RS_Bold; + break; case 22: rendset = 0, rendstyle = RS_Bold; break; + //case 23: disable italic case 24: rendset = 0, rendstyle = RS_Uline; break; @@ -3720,9 +3835,8 @@ case 27: rendset = 0, rendstyle = RS_RVid; break; - case 28: - // visible. NYI - break; + //case 28: // visible. NYI + //case 29: // not crossed-out } if (rendset != -1) @@ -3809,7 +3923,7 @@ } /*}}} */ -/*{{{ process Rob Nation's own graphics mode sequences */ +/*{{{ (do not) process Rob Nation's own graphics mode sequences */ void rxvt_term::process_graphics () {