--- rxvt-unicode/src/command.C 2005/07/13 02:47:02 1.204 +++ rxvt-unicode/src/command.C 2006/01/09 23:30:01 1.253 @@ -27,7 +27,7 @@ * Copyright (c) 2001 Marius Gedminas * - Ctrl/Mod4+Tab works like Meta+Tab (options) * Copyright (c) 2003 Rob McMullen - * Copyright (c) 2003-2005 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,11 +45,17 @@ *----------------------------------------------------------------------*/ /*{{{ includes: */ -#include "../config.h" /* NECESSARY */ -#include "rxvt.h" /* NECESSARY */ +#include "../config.h" +#include "rxvt.h" +#include "rxvtperl.h" #include "version.h" #include "command.h" +#if HAVE_SCHED_YIELD +#undef HAVE_SCHED_YIELD // disabled for the time being +//# include +#endif + #ifdef KEYSYM_RESOURCE # include "keyboard.h" #endif @@ -137,31 +143,29 @@ x = Pixel2Col (x); y = Pixel2Row (y); - if (x < 0 || x >= TermWin.ncol - || y < 0 || y >= TermWin.nrow) + if (!IN_RANGE_EXC (x, 0, ncol) + || !IN_RANGE_EXC (y, 0, nrow)) return; for (;;) { - text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; + const line_t &l = ROW(y - view_start); + + text_t t = l.t[x]; if (t != NOCHAR || !x) { - iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], - screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); + iso14755_51 (l.t[x], l.r[x], x, y); iso14755buf = ISO_14755_54; break; } x--; } - } -#endif -#if ENABLE_OVERLAY void -rxvt_term::iso14755_51 (unicode_t ch, rend_t r) +rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) { rxvt_fontset *fs = FONTSET (r); rxvt_font *f = (*fs)[fs->find_font (ch)]; @@ -170,7 +174,7 @@ fname = rxvt_utf8towcs (f->name); -#if ENABLE_COMBINING +# if ENABLE_COMBINING if (IS_COMPOSE (ch)) { len = rxvt_composite.expand (ch, 0); @@ -178,7 +182,7 @@ rxvt_composite.expand (ch, chr); } else -#endif +# endif { ch2 = ch; @@ -187,9 +191,30 @@ len = 1; } + char attr[80]; // plenty + + sprintf (attr, "%08x = fg %d bg %d%s%s%s%s%s%s", + (int)r, + fgcolor_of (r), bgcolor_of (r), + r & RS_Bold ? " bold" : "", + r & RS_Italic ? " italic" : "", + r & RS_Blink ? " blink" : "", + r & RS_RVid ? " rvid" : "", + r & RS_Uline ? " uline" : "", + r & RS_Careful ? " careful" : ""); + int width = wcswidth (fname, wcslen (fname)); - scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); + max_it (width, 8+5); // for char + hey + max_it (width, strlen (attr)); + + if (y >= 0) + { + y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; + x = 0; + } + + scr_overlay_new (x, y, width, len + 2); r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); @@ -202,22 +227,23 @@ sprintf (buf, "%8x", ch); scr_overlay_set (0, y, buf); scr_overlay_set (9, y, '='); -#if !UNICODE3 +# if !UNICODE3 if (ch >= 0x10000) ch = 0xfffd; -#endif +# endif scr_overlay_set (11, y, ch, r); scr_overlay_set (12, y, NOCHAR, r); } - scr_overlay_set (0, len, fname); + scr_overlay_set (0, len , attr); + scr_overlay_set (0, len + 1, fname); free (fname); -#if ENABLE_COMBINING +# if ENABLE_COMBINING if (alloc) delete [] alloc; -#endif +# endif } #endif @@ -244,7 +270,7 @@ } if (len > 0) - tt_write ((unsigned char *)mb, len); + tt_write (mb, len); else scr_bell (); } @@ -282,7 +308,7 @@ static int debug_key = 1; /* accessible by a debugger only */ #endif int valid_keysym; - unsigned char kbuf[KBUFSZ]; + char kbuf[KBUFSZ]; /* * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an @@ -310,7 +336,7 @@ #if 0 #ifdef X_HAVE_UTF8_STRING if (enc_utf8 && 0) // currently disabled, doesn't seem to work, nor is useful - len = Xutf8LookupString (Input_Context, &ev, (char *)kbuf, + len = Xutf8LookupString (Input_Context, &ev, kbuf, KBUFSZ, &keysym, &status_return); else #endif @@ -357,7 +383,7 @@ else #endif { - len = XLookupString (&ev, (char *)kbuf, KBUFSZ, &keysym, &compose); + len = XLookupString (&ev, kbuf, KBUFSZ, &keysym, &compose); valid_keysym = keysym != NoSymbol; } @@ -368,7 +394,7 @@ return; #endif - if (TermWin.saveLines) + if (saveLines) { #ifdef UNSHIFTED_SCROLLKEYS if (!ctrl && !meta) @@ -379,9 +405,9 @@ int lnsppg; #ifdef PAGING_CONTEXT_LINES - lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES; + lnsppg = nrow - PAGING_CONTEXT_LINES; #else - lnsppg = TermWin.nrow * 4 / 5; + lnsppg = nrow * 4 / 5; #endif if (keysym == XK_Prior) { @@ -831,7 +857,7 @@ /* set 8-bit on */ if (meta && (meta_char == 0x80)) { - unsigned char *ch; + char *ch; for (ch = kbuf; ch < kbuf + len; ch++) *ch |= 0x80; @@ -843,13 +869,16 @@ } } + if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_INT, keysym, DT_STR_LEN, kbuf, len, DT_END))) + return; + if (len <= 0) return; /* not mapped */ - if (options & Opt_scrollTtyKeypress) - if (TermWin.view_start) + if (OPTION (Opt_scrollTtyKeypress)) + if (view_start) { - TermWin.view_start = 0; + view_start = 0; want_refresh = 1; } @@ -874,7 +903,7 @@ #endif ) { - const unsigned char ch = C0_ESC; + const char ch = C0_ESC; tt_write (&ch, 1); } @@ -896,7 +925,7 @@ /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ /* attempt to `write' count to the input buffer */ unsigned int -rxvt_term::cmd_write (const unsigned char *str, unsigned int count) +rxvt_term::cmd_write (const char *str, unsigned int count) { unsigned int n, s; @@ -943,6 +972,46 @@ if (want_refresh) { + if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) + { + int row = -view_start; + int end_row = row + nrow; + + while (row > -nsaved && ROW (row - 1).is_longer ()) + --row; + + do + { + int start_row = row; + line_t *l; + + do + { + l = &ROW (row++); + + if (l->f & LINE_FILTERED) + row++; + else + { + // line not filtered, mark it as filtered + l->f |= LINE_FILTERED; + while (l->is_longer ()) + { + l = &ROW (++row); + l->f |= LINE_FILTERED; + } + + // and filter it + HOOK_INVOKE ((this, HOOK_LINE_UPDATE, DT_INT, start_row, DT_END)); + + break; + } + } + while (l->is_longer () && row < end_row); + } + while (++row < end_row); + } + scr_refresh (refresh_type); scrollbar_show (1); #ifdef USE_XIM @@ -962,7 +1031,7 @@ display->flush (); if (want_refresh && !flush_ev.active) - flush_ev.start (NOW + 0.01); + flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally } void @@ -1036,8 +1105,8 @@ || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) : scr_page (UP, mouse_slip_wheel_speed)) { - if (TermWin.view_start == TermWin.nscrolled || - TermWin.view_start == 0) + if (view_start == nsaved || + view_start == 0) mouse_slip_wheel_speed = 0; refresh_type |= SMOOTH_REFRESH; @@ -1047,6 +1116,24 @@ } #endif +#if HAVE_SCHED_YIELD +static struct event_handler +{ + check_watcher cw_yield; + + void yield (check_watcher &w) + { + sched_yield (); + w.stop (); + } + + event_handler () + : cw_yield (this, &event_handler::yield) + { + } +} event_handler; +#endif + bool rxvt_term::pty_fill () { @@ -1054,7 +1141,7 @@ if (CBUFSIZ == n) { - rxvt_warn ("pty_fill on full buffer, draining input, continuing.\n"); + rxvt_warn ("PLEASE REPORT: pty_fill on full buffer, draining input, continuing.\n"); n = 0; } @@ -1062,15 +1149,27 @@ cmdbuf_ptr = cmdbuf_base; cmdbuf_endp = cmdbuf_ptr + n; - n = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); + ssize_t r = read (pty.pty, cmdbuf_endp, CBUFSIZ - n); - if (n > 0) + if (r > 0) { - cmdbuf_endp += n; + cmdbuf_endp += r; return true; } - else if (n < 0 && errno != EAGAIN) - destroy (); + else if (r < 0 && (errno == EAGAIN || errno == EINTR)) + { +#if HAVE_SCHED_YIELD + if (display->is_local) + event_handler.cw_yield.start (); +#endif + } + else + { + pty_ev.stop (); + + if (!OPTION (Opt_hold)) + destroy (); + } return false; } @@ -1094,13 +1193,13 @@ void rxvt_term::pointer_unblank () { - XDefineCursor (display->display, TermWin.vt, TermWin_cursor); + XDefineCursor (display->display, vt, TermWin_cursor); recolour_cursor (); #ifdef POINTER_BLANK hidden_pointer = 0; - if (options & Opt_pointerBlank) + if (OPTION (Opt_pointerBlank)) pointer_ev.start (NOW + pointerBlankDelay); #endif } @@ -1109,10 +1208,10 @@ void rxvt_term::pointer_blank () { - if (! (options & Opt_pointerBlank)) + if (!OPTION (Opt_pointerBlank)) return; - XDefineCursor (display->display, TermWin.vt, display->blank_cursor); + XDefineCursor (display->display, vt, display->blank_cursor); XFlush (display->display); hidden_pointer = 1; @@ -1216,33 +1315,6 @@ SET_R (this); SET_LOCALE (locale); -#if defined(CURSOR_BLINK) - if ((options & Opt_cursorBlink) && ev.type == KeyPress) - { - if (hidden_cursor) - { - hidden_cursor = 0; - want_refresh = 1; - } - - cursor_blink_ev.start (NOW + BLINK_INTERVAL); - } -#endif - -#if defined(POINTER_BLANK) - if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) - { - if (ev.type == MotionNotify - || ev.type == ButtonPress - || ev.type == ButtonRelease) - if (hidden_pointer) - pointer_unblank (); - - if (ev.type == KeyPress && hidden_pointer == 0) - pointer_blank (); - } -#endif - Window unused_root, unused_child; int unused_root_x, unused_root_y; unsigned int unused_mask; @@ -1259,10 +1331,10 @@ case KeyRelease: { -#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 - KeySym ks; +#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL + KeySym keysym; - ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ + keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ #endif #if ENABLE_FRILLS || ISO_14755 @@ -1277,20 +1349,20 @@ // iso14755 part 5.2 handling: release time // first: controls if ((ev.xkey.state & ControlMask) - && ((ks >= 0x40 && ks <= 0x5f) - || (ks >= 0x61 && ks <= 0x7f))) + && ((keysym >= 0x40 && keysym <= 0x5f) + || (keysym >= 0x61 && keysym <= 0x7f))) { - iso14755buf = ISO_14755_51 | 0x2400 | (ks & 0x1f); + iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); commit_iso14755 (); - return; // case-break; + goto skip_switch; } for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) - if (i[0] == ks) + if (i[0] == keysym) { iso14755buf = ISO_14755_51 | i[1]; commit_iso14755 (); - return; // case-break; + goto skip_switch; } scr_bell (); @@ -1319,10 +1391,14 @@ } #endif + if (ev.xany.window == vt + && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) + break; + #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) if (!(ev.xkey.state & ControlMask)) slip_wheel_ev.stop (); - else if (ks == XK_Control_L || ks == XK_Control_R) + else if (keysym == XK_Control_L || keysym == XK_Control_R) mouse_slip_wheel_speed = 0; #endif break; @@ -1424,26 +1500,19 @@ break; case ConfigureNotify: - if (ev.xconfigure.window == TermWin.parent[0]) + if (ev.xconfigure.window == parent[0]) { - int height, width; - - do - { /* Wrap lots of configures into one */ - width = ev.xconfigure.width; - height = ev.xconfigure.height; - D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); - } - while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); + while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)) + ; - if (szHint.width != width || szHint.height != height) + if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) { seen_resize = 1; - resize_all_windows (width, height, 1); + resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); } #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (options & Opt_transparent) + if (OPTION (Opt_transparent)) check_our_parents (); #endif } @@ -1469,18 +1538,20 @@ selection_send (ev.xselectionrequest); break; - case UnmapNotify: - TermWin.mapped = 0; + case MapNotify: + mapped = 1; #ifdef TEXT_BLINK - text_blink_ev.stop (); + text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); #endif + HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; - case MapNotify: - TermWin.mapped = 1; + case UnmapNotify: + mapped = 0; #ifdef TEXT_BLINK - text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + text_blink_ev.stop (); #endif + HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; #ifdef TRANSPARENT @@ -1491,16 +1562,16 @@ case GraphicsExpose: case Expose: - if (ev.xany.window == TermWin.vt) + if (ev.xany.window == vt) { do scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); - while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); + while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)); ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; - while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) + while (XCheckTypedWindowEvent (disp, vt, ev.xany.type, &ev)) scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); @@ -1526,7 +1597,7 @@ #endif #ifdef TRANSPARENT - if (am_transparent && ev.xany.window == TermWin.parent[0]) + if (am_transparent && ev.xany.window == parent[0]) XClearWindow (disp, ev.xany.window); #endif } @@ -1547,14 +1618,16 @@ if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) break; - if (ev.xany.window == TermWin.vt) + if (ev.xany.window == vt) { - if (ev.xbutton.state & (Button1Mask | Button3Mask)) + if (HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) + ; // nop + else if (ev.xbutton.state & (Button1Mask | Button3Mask)) { - while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) + while (XCheckTypedWindowEvent (disp, vt, MotionNotify, &ev)) ; - XQueryPointer (disp, TermWin.vt, + XQueryPointer (disp, vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &ev.xbutton.x, &ev.xbutton.y, @@ -1576,8 +1649,8 @@ ev.xbutton.state & Button3Mask ? 2 : 0); #ifdef SELECTION_SCROLLING - if (ev.xbutton.y < TermWin.int_bwidth - || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) + if (ev.xbutton.y < int_bwidth + || Pixel2Row (ev.xbutton.y) > (nrow-1)) { int dist; @@ -1595,21 +1668,21 @@ selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; /* calc number of lines to scroll */ - if (ev.xbutton.y < TermWin.int_bwidth) + if (ev.xbutton.y < int_bwidth) { scroll_selection_dir = UP; - dist = TermWin.int_bwidth - ev.xbutton.y; + dist = int_bwidth - ev.xbutton.y; } else { scroll_selection_dir = DN; - dist = ev.xbutton.y - (TermWin.int_bwidth + TermWin.height); + dist = ev.xbutton.y - (int_bwidth + height); } scroll_selection_lines = Pixel2Height (dist) / SELECTION_SCROLL_LINE_SPEEDUP + 1; - MIN_IT (scroll_selection_lines, + min_it (scroll_selection_lines, SELECTION_SCROLL_MAX_LINES); } else @@ -1645,27 +1718,59 @@ } break; } + +skip_switch: ; + +#if defined(CURSOR_BLINK) + if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) + { + if (hidden_cursor) + { + hidden_cursor = 0; + want_refresh = 1; + } + + cursor_blink_ev.start (NOW + BLINK_INTERVAL); + } +#endif + +#if defined(POINTER_BLANK) + if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) + { + if (ev.type == MotionNotify + || ev.type == ButtonPress + || ev.type == ButtonRelease) + if (hidden_pointer) + pointer_unblank (); + + if (ev.type == KeyPress && hidden_pointer == 0) + pointer_blank (); + } +#endif } void rxvt_term::focus_in () { - if (!TermWin.focus) + if (!focus) { - TermWin.focus = 1; + focus = 1; want_refresh = 1; -#ifdef USE_XIM + + HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + +#if USE_XIM if (Input_Context != NULL) { IMSetStatusPosition (); XSetICFocus (Input_Context); } #endif -#ifdef CURSOR_BLINK - if (options & Opt_cursorBlink) +#if CURSOR_BLINK + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.start (NOW + BLINK_INTERVAL); #endif -#ifdef OFF_FOCUS_FADING +#if OFF_FOCUS_FADING if (rs[Rs_fade]) { pix_colors = pix_colors_focused; @@ -1678,27 +1783,32 @@ void rxvt_term::focus_out () { - if (TermWin.focus) + if (focus) { - TermWin.focus = 0; + focus = 0; want_refresh = 1; + HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if ENABLE_FRILLS || ISO_14755 - iso14755buf = 0; -#endif -#if ENABLE_OVERLAY - scr_overlay_off (); + if (iso14755buf) + { + iso14755buf = 0; +# if ENABLE_OVERLAY + scr_overlay_off (); +# endif + } #endif -#ifdef USE_XIM +#if USE_XIM if (Input_Context != NULL) XUnsetICFocus (Input_Context); #endif -#ifdef CURSOR_BLINK - if (options & Opt_cursorBlink) +#if CURSOR_BLINK + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.stop (); hidden_cursor = 0; #endif -#ifdef OFF_FOCUS_FADING +#if OFF_FOCUS_FADING if (rs[Rs_fade]) { pix_colors = pix_colors_unfocused; @@ -1728,7 +1838,7 @@ /* FALLTHROUGH */ case ReparentNotify: - if ((options & Opt_transparent) && check_our_parents () && am_transparent) + if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) want_refresh = want_full_refresh = 1; break; } @@ -1741,13 +1851,14 @@ int reportmode = 0, clickintime; bypass_keystate = ev.state & (ModMetaMask | ShiftMask); + if (!bypass_keystate) reportmode = !! (priv_modes & PrivMode_mouse_report); /* * VT window processing of button press */ - if (ev.window == TermWin.vt) + if (ev.window == vt) { #if ISO_14755 // 5.4 @@ -1770,6 +1881,7 @@ { /* same button, within alloted time */ MEvent.clicks++; + if (MEvent.clicks > 1) { /* only report double clicks */ @@ -1799,48 +1911,49 @@ if (ev.button != MEvent.button) MEvent.clicks = 0; - switch (ev.button) - { - case Button1: - /* allow meta + click to select rectangular areas */ - /* should be done in screen.C */ + if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) + switch (ev.button) + { + case Button1: + /* allow meta + click to select rectangular areas */ + /* should be done in screen.C */ #if ENABLE_FRILLS - selection.rect = !!(ev.state & ModMetaMask); + selection.rect = !!(ev.state & ModMetaMask); #else - selection.rect = false; + selection.rect = false; #endif - /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) - { - if (MEvent.button == Button1 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - } - else - { - if (MEvent.button == Button1 && clickintime) - MEvent.clicks++; - else - MEvent.clicks = 1; + /* allow shift+left click to extend selection */ + if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) + { + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); + } + else + { + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; + else + MEvent.clicks = 1; - selection_click (MEvent.clicks, ev.x, ev.y); - } + selection_click (MEvent.clicks, ev.x, ev.y); + } - MEvent.button = Button1; - break; + MEvent.button = Button1; + break; - case Button3: - if (MEvent.button == Button3 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); + case Button3: + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); - MEvent.button = Button3; - break; - } - } + MEvent.button = Button3; + break; + } + } MEvent.time = ev.time; return; @@ -1962,15 +2075,15 @@ { if (scrollbar_above_slider (ev.y)) # ifdef RXVT_SCROLL_FULL - scr_page (UP, TermWin.nrow - 1); + scr_page (UP, nrow - 1); # else - scr_page (UP, TermWin.nrow / 4); + scr_page (UP, nrow / 4); # endif else if (scrollbar_below_slider (ev.y)) # ifdef RXVT_SCROLL_FULL - scr_page (DN, TermWin.nrow - 1); + scr_page (DN, nrow - 1); # else - scr_page (DN, TermWin.nrow / 4); + scr_page (DN, nrow / 4); # endif else scrollBar.setMotion (); @@ -1978,7 +2091,7 @@ else { scr_page ((ev.button == Button1 ? DN : UP), - (TermWin.nrow + (nrow * scrollbar_position (ev.y) / scrollbar_size ())); } @@ -1986,8 +2099,10 @@ break; } } + return; } + #if MENUBAR /* * Menubar window processing of button press @@ -2020,7 +2135,7 @@ sel_scroll_ev.stop(); #endif - if (ev.window == TermWin.vt) + if (ev.window == vt) { #if ISO_14755 // 5.4 @@ -2060,6 +2175,9 @@ && ev.button == Button1 && MEvent.clicks <= 1) selection_extend (ev.x, ev.y, 0); + if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) + return; + switch (ev.button) { case Button1: @@ -2080,8 +2198,8 @@ if (ev.state & ShiftMask) i = 1; - else if (options & Opt_mouseWheelScrollPage) - i = TermWin.nrow - 1; + else if (OPTION (Opt_mouseWheelScrollPage)) + i = nrow - 1; else i = 5; @@ -2089,8 +2207,8 @@ if (ev.state & ControlMask) { 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 (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; + if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; if (slip_wheel_ev.at < NOW) slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; @@ -2376,20 +2494,20 @@ pchanged = 0; - if (!(options & Opt_transparent)) + if (!OPTION (Opt_transparent)) return pchanged; /* Don't try any more */ XGetWindowAttributes (disp, display->root, &wrootattr); rootdepth = wrootattr.depth; - XGetWindowAttributes (disp, TermWin.parent[0], &wattr); + XGetWindowAttributes (disp, parent[0], &wattr); if (rootdepth != wattr.depth) { if (am_transparent) { pchanged = 1; - XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); + XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); am_transparent = am_pixmap_trans = 0; } @@ -2440,7 +2558,7 @@ GC gc; XGCValues gcvalue; - XTranslateCoordinates (disp, TermWin.parent[0], display->root, + XTranslateCoordinates (disp, parent[0], display->root, 0, 0, &sx, &sy, &cr); nw = (unsigned int)szHint.width; nh = (unsigned int)szHint.height; @@ -2460,8 +2578,8 @@ sy = 0; } - MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); - MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); + min_it (nw, (unsigned int) (wrootattr.width - sx)); + min_it (nh, (unsigned int) (wrootattr.height - sy)); XSync (disp, False); allowedxerror = -1; @@ -2476,10 +2594,10 @@ if (am_transparent && am_pixmap_trans) { pchanged = 1; - if (TermWin.pixmap != None) + if (pixmap != None) { - XFreePixmap (disp, TermWin.pixmap); - TermWin.pixmap = None; + XFreePixmap (disp, pixmap); + pixmap = None; } } @@ -2487,8 +2605,8 @@ } else { - if (TermWin.pixmap != None) - XFreePixmap (disp, TermWin.pixmap); + if (pixmap != None) + XFreePixmap (disp, pixmap); #if TINTING if (ISSET_PIXCOLOR (Color_tint)) @@ -2502,15 +2620,15 @@ } #endif - TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, + pixmap = XCreatePixmap (disp, vt, szHint.width, szHint.height, image->depth); - gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); - XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, + gc = XCreateGC (disp, vt, 0UL, &gcvalue); + XPutImage (disp, pixmap, gc, image, 0, 0, nx, ny, image->width, image->height); XFreeGC (disp, gc); XDestroyImage (image); - XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); - XClearWindow (disp, TermWin.parent[0]); + XSetWindowBackgroundPixmap (disp, parent[0], pixmap); + XClearWindow (disp, parent[0]); if (!am_transparent || !am_pixmap_trans) pchanged = 1; @@ -2520,21 +2638,21 @@ } if (am_pixmap_trans) - XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); + XSetWindowBackgroundPixmap (disp, vt, ParentRelative); else { unsigned int n; /* * InheritPixmap transparency */ - for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) + for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) { - oldp = TermWin.parent[i]; - XQueryTree (disp, TermWin.parent[i - 1], &root, - &TermWin.parent[i], &list, &n); + oldp = parent[i]; + XQueryTree (disp, parent[i - 1], &root, + &parent[i], &list, &n); XFree (list); - if (TermWin.parent[i] == display->root) + if (parent[i] == display->root) { if (oldp != None) pchanged = 1; @@ -2542,7 +2660,7 @@ break; } - if (oldp != TermWin.parent[i]) + if (oldp != parent[i]) pchanged = 1; } @@ -2552,19 +2670,19 @@ { for (; n < (unsigned int)i; n++) { - XGetWindowAttributes (disp, TermWin.parent[n], &wattr); + XGetWindowAttributes (disp, parent[n], &wattr); if (wattr.depth != rootdepth || wattr.c_class == InputOnly) { - n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; + n = (int) (sizeof (parent) / sizeof (Window)) + 1; break; } } } - if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) + if (n > (int) (sizeof (parent) / sizeof (parent[0]))) { - XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); - XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); + XSetWindowBackground (disp, parent[0], pix_colors_focused[Color_border]); + XSetWindowBackground (disp, vt, pix_colors_focused[Color_bg]); am_transparent = 0; /* XXX: also turn off Opt_transparent? */ } @@ -2577,16 +2695,16 @@ #endif for (n = 0; n < (unsigned int)i; n++) { - XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); - XClearWindow (disp, TermWin.parent[n]); + XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); + XClearWindow (disp, parent[n]); } - XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); + XSetWindowBackgroundPixmap (disp, vt, ParentRelative); am_transparent = 1; } - for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) - TermWin.parent[i] = None; + for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) + parent[i] = None; } if (scrollBar.win) @@ -2613,8 +2731,8 @@ rxvt_term::cmd_parse () { bool flag = false; - unicode_t ch = NOCHAR; - unsigned char *seq_begin; // remember start of esc-sequence here + wchar_t ch = NOCHAR; + char *seq_begin; // remember start of esc-sequence here for (;;) { @@ -2622,10 +2740,10 @@ { seq_begin = cmdbuf_ptr; ch = next_char (); - } - if (ch == NOCHAR) // TODO: improve - break; + if (ch == NOCHAR) + break; + } if (!IS_CONTROL (ch) || ch == C0_LF || ch == C0_CR || ch == C0_HT) { @@ -2644,11 +2762,11 @@ } /* Read a text string from the input buffer */ - unicode_t buf[UBUFSIZ]; + wchar_t buf[UBUFSIZ]; bool refreshnow = false; int nlines = 0; - unicode_t *str = buf; - unicode_t *eol = str + min (TermWin.ncol, UBUFSIZ); + wchar_t *str = buf; + wchar_t *eol = str + min (ncol, UBUFSIZ); for (;;) { @@ -2659,24 +2777,29 @@ if (ch == C0_LF || str >= eol) { - nlines++; + if (ch == C0_LF) + nlines++; + refresh_count++; - if (!(options & Opt_jumpScroll) - || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) + if (!OPTION (Opt_jumpScroll) + || (refresh_count >= refresh_limit * (nrow - 1))) { refreshnow = true; + refresh_count = 0; ch = NOCHAR; break; } - // scr_add_lines only works for nlines <= TermWin.nrow - 1. - if (nlines >= TermWin.nrow - 1) + // scr_add_lines only works for nlines <= nrow - 1. + if (nlines >= nrow - 1) { - scr_add_lines (buf, nlines, str - buf); + if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, str - buf, nlines); + nlines = 0; str = buf; - eol = str + min (TermWin.ncol, UBUFSIZ); + eol = str + min (ncol, UBUFSIZ); } if (str >= eol) @@ -2687,7 +2810,7 @@ break; } else - eol = min (eol + TermWin.ncol, buf + UBUFSIZ); + eol = min (eol + ncol, buf + UBUFSIZ); } } @@ -2696,7 +2819,8 @@ ch = next_char (); } - scr_add_lines (buf, nlines, str - buf); + if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, str - buf, nlines); /* * If there have been a lot of new lines, then update the screen @@ -2706,12 +2830,13 @@ */ if (refreshnow) { - if ((options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) + if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) refresh_limit++; else { flag = true; scr_refresh (refresh_type); + flush_ev.stop (); } } @@ -2736,27 +2861,18 @@ 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 +wchar_t rxvt_term::next_char () { while (cmdbuf_ptr < cmdbuf_endp) { // assume 7-bit to be ascii ALWAYS - if (*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) + if ((unsigned char)*cmdbuf_ptr <= 0x7f && *cmdbuf_ptr != 0x1b) return *cmdbuf_ptr++; wchar_t wc; - size_t len = mbrtowc (&wc, (char *)cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); + size_t len = mbrtowc (&wc, cmdbuf_ptr, cmdbuf_endp - cmdbuf_ptr, mbstate); if (len == (size_t)-2) { @@ -2766,7 +2882,7 @@ } if (len == (size_t)-1) - return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through + return (unsigned char)*cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through // assume wchar == unicode cmdbuf_ptr += len; @@ -2776,15 +2892,24 @@ return NOCHAR; } +// read the next octet +uint32_t +rxvt_term::next_octet () +{ + return cmdbuf_ptr < cmdbuf_endp + ? (unsigned char)*cmdbuf_ptr++ + : NOCHAR; +} + /* rxvt_cmd_getc () - Return next input character */ /* * Return the next input character after first passing any keyboard input * to the command. */ -unicode_t +wchar_t rxvt_term::cmd_getc () { - unicode_t c = next_char (); + wchar_t c = next_char (); if (c == NOCHAR) throw out_of_input; @@ -2792,10 +2917,10 @@ return c; } -unicode_t +uint32_t rxvt_term::cmd_get8 () { - unicode_t c = next_octet (); + uint32_t c = next_octet (); if (c == NOCHAR) throw out_of_input; @@ -2905,11 +3030,9 @@ break; case C0_ENQ: /* terminal Status */ if (rs[Rs_answerbackstring]) - tt_write ((const unsigned char *)rs[Rs_answerbackstring], - (unsigned int)strlen (rs[Rs_answerbackstring])); + tt_write (rs [Rs_answerbackstring], strlen (rs [Rs_answerbackstring])); else - tt_write ((unsigned char *)VT100_ANS, - (unsigned int)strlen (VT100_ANS)); + tt_write (VT100_ANS, strlen (VT100_ANS)); break; case C0_BEL: /* bell */ scr_bell (); @@ -3074,8 +3197,8 @@ /* 8.3.87: NEXT LINE */ case C1_NEL: /* ESC E */ { - unicode_t nlcr[] = { C0_LF, C0_CR }; - scr_add_lines (nlcr, 1, 2); + wchar_t nlcr[] = { C0_LF, C0_CR }; + scr_add_lines (nlcr, sizeof (nlcr) / sizeof (nlcr [0]), 1); } break; @@ -3107,8 +3230,7 @@ /* 8.3.110: SINGLE CHARACTER INTRODUCER */ case C1_SCI: /* ESC Z */ - tt_write ((const unsigned char *)ESCZ_ANSWER, - (unsigned int) (sizeof (ESCZ_ANSWER) - 1)); + tt_write (ESCZ_ANSWER, sizeof (ESCZ_ANSWER) - 1); break; /* steal obsolete ESC [ c */ /* 8.3.16: CONTROL SEQUENCE INTRODUCER */ @@ -3358,12 +3480,11 @@ arg[0] = -arg[0]; /* FALLTHROUGH */ case CSI_SU: /* 8.3.148: (1) SCROLL UP */ - scr_scroll_text (screen.tscroll, screen.bscroll, arg[0], 0); + scr_scroll_text (screen.tscroll, screen.bscroll, arg[0]); break; case CSI_DA: /* 8.3.24: (0) DEVICE ATTRIBUTES */ - tt_write ((const unsigned char *)VT100_ANS, - (unsigned int) (sizeof (VT100_ANS) - 1)); + tt_write (VT100_ANS, sizeof (VT100_ANS) - 1); break; case CSI_SGR: /* 8.3.118: (0) SELECT GRAPHIC RENDITION */ @@ -3380,7 +3501,7 @@ scr_report_position (); break; case 7: /* unofficial extension */ - if (options & Opt_insecure) + if (OPTION (Opt_insecure)) tt_printf ("%-.250s\012", rs[Rs_display_name]); break; case 8: /* unofficial extension */ @@ -3493,36 +3614,36 @@ * commands */ case 1: /* deiconify window */ - XMapWindow (disp, TermWin.parent[0]); + XMapWindow (disp, parent[0]); break; case 2: /* iconify window */ - XIconifyWindow (disp, TermWin.parent[0], display->screen); + XIconifyWindow (disp, parent[0], display->screen); break; case 3: /* set position (pixels) */ - XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); + XMoveWindow (disp, parent[0], args[1], args[2]); break; case 4: /* set size (pixels) */ set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); break; case 5: /* raise window */ - XRaiseWindow (disp, TermWin.parent[0]); + XRaiseWindow (disp, parent[0]); break; case 6: /* lower window */ - XLowerWindow (disp, TermWin.parent[0]); + XLowerWindow (disp, parent[0]); break; case 7: /* refresh window */ scr_touch (true); break; case 8: /* set size (chars) */ - set_widthheight ((unsigned int) (args[2] * TermWin.fwidth), - (unsigned int) (args[1] * TermWin.fheight)); + set_widthheight ((unsigned int) (args[2] * fwidth), + (unsigned int) (args[1] * fheight)); break; //case 9: NYI, TODO, restore maximized window or maximize window default: if (args[0] >= 24) /* set height (chars) */ - set_widthheight ((unsigned int)TermWin.width, - (unsigned int) (args[1] * TermWin.fheight)); + set_widthheight ((unsigned int)width, + (unsigned int) (args[1] * fheight)); break; @@ -3530,39 +3651,39 @@ * reports - some output format copied from XTerm */ case 11: /* report window state */ - XGetWindowAttributes (disp, TermWin.parent[0], &wattr); + XGetWindowAttributes (disp, parent[0], &wattr); tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); break; case 13: /* report window position */ - XGetWindowAttributes (disp, TermWin.parent[0], &wattr); - XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, + XGetWindowAttributes (disp, parent[0], &wattr); + XTranslateCoordinates (disp, parent[0], wattr.root, -wattr.border_width, -wattr.border_width, &x, &y, &wdummy); tt_printf ("\033[3;%d;%dt", x, y); break; case 14: /* report window size (pixels) */ - XGetWindowAttributes (disp, TermWin.parent[0], &wattr); + XGetWindowAttributes (disp, parent[0], &wattr); tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); break; case 18: /* report text area size (chars) */ - tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); + tt_printf ("\033[8;%d;%dt", nrow, ncol); break; case 19: /* report window size (chars) */ - tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); + tt_printf ("\033[9;%d;%dt", nrow, ncol); break; case 20: /* report icon label */ { char *s; - XGetIconName (disp, TermWin.parent[0], &s); - tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + XGetIconName (disp, parent[0], &s); + tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; case 21: /* report window title */ { char *s; - XFetchName (disp, TermWin.parent[0], &s); - tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + XFetchName (disp, parent[0], &s); + tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3575,7 +3696,7 @@ * get input up until STRING TERMINATOR (or BEL) * ends_how is terminator used. returned input must be free()'d */ -unsigned char * +char * rxvt_term::get_to_st (unicode_t &ends_how) { unicode_t ch; @@ -3618,7 +3739,7 @@ ends_how = (ch == 0x5c ? C0_ESC : ch); - return (unsigned char *)rxvt_wcstombs (string); + return rxvt_wcstombs (string); } /*----------------------------------------------------------------------*/ @@ -3628,7 +3749,7 @@ void rxvt_term::process_dcs_seq () { - unsigned char *s; + char *s; unicode_t eh; /* @@ -3657,18 +3778,18 @@ if (ch == ';') { - unsigned char *s = get_to_st (eh); + char *s = get_to_st (eh); if (s) { - process_xterm_seq (arg, (char *)s, eh); + process_xterm_seq (arg, s, eh); free (s); } } } void -rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) +rxvt_term::process_color_seq (int report, int color, const char *str, char resp) { if (str[0] == '?' && !str[1]) { @@ -3684,7 +3805,7 @@ * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) */ void -rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) +rxvt_term::process_xterm_seq (int op, const char *str, char resp) { int changed = 0; int color; @@ -3717,7 +3838,7 @@ const char *str = ""; if (prop - && XGetWindowProperty (disp, TermWin.parent[0], + && XGetWindowProperty (disp, parent[0], prop, 0, 1<<16, 0, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &value) == Success @@ -3739,7 +3860,7 @@ set_utf8_property (display->atom (str), eq + 1); } else - XDeleteProperty (disp, TermWin.parent[0], + XDeleteProperty (disp, parent[0], display->atom (str)); } break; @@ -3848,7 +3969,7 @@ #ifdef MENUBAR case URxvt_Menu: - if (options & Opt_insecure) + if (OPTION (Opt_insecure)) menubar_dispatch (const_cast(str)); // casting away constness is checked break; #endif @@ -3874,8 +3995,8 @@ #endif if (query) tt_printf ("\33]%d;%-.250s%c", saveop, - (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc - ? TermWin.fontset[op - URxvt_font]->fontdesc : "", + OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc + ? fontset[op - URxvt_font]->fontdesc : "", resp); else { @@ -3890,7 +4011,7 @@ #if ENABLE_FRILLS case URxvt_locale: if (query) - tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); + tt_printf ("\33]%d;%-.250s%c", URxvt_locale, OPTION (Opt_insecure) ? locale : "", resp); else { set_locale (str); @@ -3901,15 +4022,22 @@ case URxvt_view_up: case URxvt_view_down: - int lines = atoi (str); + { + int lines = atoi (str); - if (lines) - scr_page (op == URxvt_view_up ? UP : DN, lines); - else - { + if (lines) + scr_page (op == URxvt_view_up ? UP : DN, lines); + else scr_erase_savelines (); - } + } + + break; +#endif +#if ENABLE_PERL + case URxvt_perl: + if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) + ; // no responses yet break; #endif } @@ -4028,9 +4156,16 @@ /* extra handling for values with state unkept */ switch (arg[i]) { +#if ENABLE_STYLES + case 1021: + set_option (Opt_intensityStyles, mode); + + scr_touch (true); + break; +#endif case 1048: /* alternative cursor save */ case 1049: - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (mode == 0) scr_cursor (RESTORE); else if (mode == 1) @@ -4052,13 +4187,10 @@ break; case 3: /* 80/132 */ if (priv_modes & PrivMode_132OK) - set_widthheight (((state ? 132 : 80) * TermWin.fwidth), TermWin.height); + set_widthheight (((state ? 132 : 80) * fwidth), height); break; case 4: /* smooth scrolling */ - if (state) - options &= ~Opt_jumpScroll; - else - options |= Opt_jumpScroll; + set_option (Opt_jumpScroll, !state); break; case 5: /* reverse video */ scr_rvideo_mode (state); @@ -4109,26 +4241,20 @@ break; /* X11 mouse highlighting */ #endif case 1010: /* scroll to bottom on TTY output inhibit */ - if (state) - options &= ~Opt_scrollTtyOutput; - else - options |= Opt_scrollTtyOutput; + set_option (Opt_scrollTtyOutput, !state); break; case 1011: /* scroll to bottom on key press */ - if (state) - options |= Opt_scrollTtyKeypress; - else - options &= ~Opt_scrollTtyKeypress; + set_option (Opt_scrollTtyKeypress, state); break; case 1047: /* secondary screen w/ clearing last */ - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); scr_change_screen (state); break; case 1049: /* secondary screen w/ clearing first */ scr_change_screen (state); - if (options & Opt_secondaryScreen) + if (OPTION (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); break; @@ -4266,7 +4392,7 @@ //case 50: // not variable spacing -#ifndef NO_BRIGHTCOLOR +#if ENABLE_FRILLS case 90: case 91: /* set bright fg color */ case 92: @@ -4288,7 +4414,6 @@ scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif - } } } @@ -4322,7 +4447,7 @@ rxvt_term::tt_printf (const char *fmt,...) { va_list arg_ptr; - unsigned char buf[256]; + char buf[256]; va_start (arg_ptr, fmt); vsnprintf ((char *)buf, 256, fmt, arg_ptr); @@ -4337,8 +4462,14 @@ const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT void -rxvt_term::tt_write (const unsigned char *data, unsigned int len) +rxvt_term::tt_write (const char *data, unsigned int len) { + if (HOOK_INVOKE ((this, HOOK_TT_WRITE, DT_STR_LEN, data, len, DT_END))) + return; + + if (pty.pty < 0) + return; + if (v_buflen == 0) { ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); @@ -4350,7 +4481,7 @@ len -= written; } - v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); + v_buffer = (char *)realloc (v_buffer, v_buflen + len); memcpy (v_buffer + v_buflen, data, len); v_buflen += len; @@ -4379,8 +4510,7 @@ memmove (v_buffer, v_buffer + written, v_buflen); } else if (written != -1 || (errno != EAGAIN && errno != EINTR)) - // original code just ignores this... - destroy (); + pty_ev.set (EVENT_READ); } /*----------------------- end-of-file (C source) -----------------------*/