--- rxvt-unicode/src/command.C 2005/12/21 14:19:19 1.212 +++ rxvt-unicode/src/command.C 2006/01/06 05:28:55 1.241 @@ -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 @@ -143,13 +149,13 @@ for (;;) { - const line_t &l = ROW(-view_start); + const line_t &l = ROW(y - view_start); text_t t = l.t[x]; if (t != NOCHAR || !x) { - iso14755_51 (l.t[x], l.r[x]); + iso14755_51 (l.t[x], l.r[x], x, y); iso14755buf = ISO_14755_54; break; } @@ -157,11 +163,9 @@ 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; } @@ -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,10 +869,13 @@ } } + if (HOOK_INVOKE ((this, HOOK_KEY_PRESS, DT_XEVENT, &ev, DT_STRING_LEN, kbuf, len, DT_END))) + return; + if (len <= 0) return; /* not mapped */ - if (options & Opt_scrollTtyKeypress) + if (OPTION (Opt_scrollTtyKeypress)) if (view_start) { view_start = 0; @@ -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,45 @@ if (want_refresh) { + if (SHOULD_INVOKE (HOOK_LINE_UPDATE)) + { + int row = -view_start; + + while (row > -nsaved && ROW (row - 1).is_longer ()) + --row; + + while (row < -view_start + nrow) + { + int start_row = row; + line_t *l; + + do + { + l = &ROW (row); + + if (!(l->f & LINE_FILTERED)) + { + // 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++; + } + + } + scr_refresh (refresh_type); scrollbar_show (1); #ifdef USE_XIM @@ -962,7 +1030,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 @@ -1047,6 +1115,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 +1140,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 +1148,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; } @@ -1100,7 +1198,7 @@ #ifdef POINTER_BLANK hidden_pointer = 0; - if (options & Opt_pointerBlank) + if (OPTION (Opt_pointerBlank)) pointer_ev.start (NOW + pointerBlankDelay); #endif } @@ -1109,7 +1207,7 @@ void rxvt_term::pointer_blank () { - if (! (options & Opt_pointerBlank)) + if (!OPTION (Opt_pointerBlank)) return; XDefineCursor (display->display, vt, display->blank_cursor); @@ -1217,7 +1315,7 @@ SET_LOCALE (locale); #if defined(CURSOR_BLINK) - if ((options & Opt_cursorBlink) && ev.type == KeyPress) + if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) { if (hidden_cursor) { @@ -1230,7 +1328,7 @@ #endif #if defined(POINTER_BLANK) - if ((options & Opt_pointerBlank) && pointerBlankDelay > 0) + if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) { if (ev.type == MotionNotify || ev.type == ButtonPress @@ -1319,6 +1417,9 @@ } #endif + if (ev.xany.window == vt && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_END))) + break; + #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) if (!(ev.xkey.state & ControlMask)) slip_wheel_ev.stop (); @@ -1436,7 +1537,7 @@ } #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (options & Opt_transparent) + if (OPTION (Opt_transparent)) check_our_parents (); #endif } @@ -1542,7 +1643,9 @@ 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, vt, MotionNotify, &ev)) ; @@ -1647,6 +1750,9 @@ { focus = 1; want_refresh = 1; + + HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + #if USE_XIM if (Input_Context != NULL) { @@ -1655,7 +1761,7 @@ } #endif #if CURSOR_BLINK - if (options & Opt_cursorBlink) + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.start (NOW + BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING @@ -1676,18 +1782,23 @@ 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 #if USE_XIM if (Input_Context != NULL) XUnsetICFocus (Input_Context); #endif #if CURSOR_BLINK - if (options & Opt_cursorBlink) + if (OPTION (Opt_cursorBlink)) cursor_blink_ev.stop (); hidden_cursor = 0; #endif @@ -1721,7 +1832,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; } @@ -1734,6 +1845,7 @@ int reportmode = 0, clickintime; bypass_keystate = ev.state & (ModMetaMask | ShiftMask); + if (!bypass_keystate) reportmode = !! (priv_modes & PrivMode_mouse_report); @@ -1792,48 +1904,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; @@ -2053,6 +2166,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: @@ -2073,7 +2189,7 @@ if (ev.state & ShiftMask) i = 1; - else if (options & Opt_mouseWheelScrollPage) + else if (OPTION (Opt_mouseWheelScrollPage)) i = nrow - 1; else i = 5; @@ -2369,7 +2485,7 @@ pchanged = 0; - if (!(options & Opt_transparent)) + if (!OPTION (Opt_transparent)) return pchanged; /* Don't try any more */ XGetWindowAttributes (disp, display->root, &wrootattr); @@ -2607,7 +2723,7 @@ { bool flag = false; unicode_t ch = NOCHAR; - unsigned char *seq_begin; // remember start of esc-sequence here + char *seq_begin; // remember start of esc-sequence here for (;;) { @@ -2615,10 +2731,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) { @@ -2657,10 +2773,11 @@ refresh_count++; - if (!(options & Opt_jumpScroll) + if (!OPTION (Opt_jumpScroll) || (refresh_count >= refresh_limit * (nrow - 1))) { refreshnow = true; + refresh_count = 0; ch = NOCHAR; break; } @@ -2668,7 +2785,9 @@ // 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_USTRING_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, nlines, str - buf); + nlines = 0; str = buf; eol = str + min (ncol, UBUFSIZ); @@ -2691,7 +2810,8 @@ ch = next_char (); } - scr_add_lines (buf, nlines, str - buf); + if (!HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END))) + scr_add_lines (buf, nlines, str - buf); /* * If there have been a lot of new lines, then update the screen @@ -2701,12 +2821,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 (); } } @@ -2747,11 +2868,11 @@ 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) { @@ -2900,11 +3021,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 (); @@ -3102,8 +3221,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 */ @@ -3357,8 +3475,7 @@ 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 */ @@ -3375,7 +3492,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 */ @@ -3549,7 +3666,7 @@ { char *s; XGetIconName (disp, parent[0], &s); - tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3557,7 +3674,7 @@ { char *s; XFetchName (disp, parent[0], &s); - tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ + tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3570,7 +3687,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; @@ -3613,7 +3730,7 @@ ends_how = (ch == 0x5c ? C0_ESC : ch); - return (unsigned char *)rxvt_wcstombs (string); + return rxvt_wcstombs (string); } /*----------------------------------------------------------------------*/ @@ -3623,7 +3740,7 @@ void rxvt_term::process_dcs_seq () { - unsigned char *s; + char *s; unicode_t eh; /* @@ -3652,18 +3769,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]) { @@ -3679,7 +3796,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; @@ -3843,7 +3960,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 @@ -3869,7 +3986,7 @@ #endif if (query) tt_printf ("\33]%d;%-.250s%c", saveop, - (options & Opt_insecure) && fontset[op - URxvt_font]->fontdesc + OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc ? fontset[op - URxvt_font]->fontdesc : "", resp); else @@ -3885,7 +4002,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); @@ -3896,17 +4013,24 @@ 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_STRING, str, DT_END))) + ; // no responses yet + break; +#endif } } /*----------------------------------------------------------------------*/ @@ -4023,9 +4147,19 @@ /* extra handling for values with state unkept */ switch (arg[i]) { +#if ENABLE_STYLES + case 1021: + if (mode) + SET_OPTION (Opt_intensityStyles); + else + CLR_OPTION (Opt_intensityStyles); + + 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) @@ -4050,10 +4184,10 @@ set_widthheight (((state ? 132 : 80) * fwidth), height); break; case 4: /* smooth scrolling */ - if (state) - options &= ~Opt_jumpScroll; + if (!state) + SET_OPTION (Opt_jumpScroll); else - options |= Opt_jumpScroll; + CLR_OPTION (Opt_jumpScroll); break; case 5: /* reverse video */ scr_rvideo_mode (state); @@ -4104,26 +4238,26 @@ break; /* X11 mouse highlighting */ #endif case 1010: /* scroll to bottom on TTY output inhibit */ - if (state) - options &= ~Opt_scrollTtyOutput; + if (!state) + SET_OPTION (Opt_scrollTtyOutput); else - options |= Opt_scrollTtyOutput; + CLR_OPTION (Opt_scrollTtyOutput); break; case 1011: /* scroll to bottom on key press */ if (state) - options |= Opt_scrollTtyKeypress; + SET_OPTION (Opt_scrollTtyKeypress); else - options &= ~Opt_scrollTtyKeypress; + CLR_OPTION (Opt_scrollTtyKeypress); 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; @@ -4261,7 +4395,7 @@ //case 50: // not variable spacing -#ifndef NO_BRIGHTCOLOR +#if ENABLE_FRILLS case 90: case 91: /* set bright fg color */ case 92: @@ -4283,7 +4417,6 @@ scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif - } } } @@ -4317,7 +4450,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); @@ -4332,8 +4465,11 @@ 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 (pty.pty < 0) + return; + if (v_buflen == 0) { ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); @@ -4345,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; @@ -4374,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) -----------------------*/