From 8e41db2cc6fa944a40ce4dbad30a6be4d6316c52 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 25 Aug 2004 03:47:20 +0000 Subject: [PATCH 1/1] *** empty log message *** --- doc/rxvt.7.pod | 78 ++++++++---- src/command.C | 161 +++++++++++++++---------- src/init.C | 362 +++++++++++++++---------------------------------------- src/rxvt.h | 117 +++++++++++------- src/rxvtlib.h.in | 82 ++++++------- src/screen.C | 300 +++++++++++++++++++++++++++++++-------------- src/version.h | 10 +- 7 files changed, 575 insertions(+), 535 deletions(-) diff --git a/doc/rxvt.7.pod b/doc/rxvt.7.pod index 266ed67..58bad11 100644 --- a/doc/rxvt.7.pod +++ b/doc/rxvt.7.pod @@ -1,3 +1,25 @@ +=head1 NAME + +RXVT TECHNICAL REFERENCE - command sequences and background information + +=head1 SYNOPSIS + + # set a new font set + printf '\33]50;%s\007' 9x15,xft:Kochi" Mincho" + + # change the locale and tell rxvt-unicode about it + export LC_CTYPE=ja_JP.EUC-JP; printf "\33]701;$LC_CTYPE\007" + + # set window title + printf '\33]2;%s\007' "new window title" + +=head1 DESCRIPTION + +The rest of this document describes various technical aspects of +B. First the description of supported command sequences, +followed by menu and pixmap support and last by a description of all +features selectable at C time. + =head1 RXVT TECHNICAL REFERENCE =head1 Definitions @@ -151,11 +173,11 @@ Invoke the G2 Character Set (LS2) Invoke the G3 Character Set (LS3) -=item B<< C(C >> +=item B<< C ( C> >> Designate G0 Character Set (ISO 2022), see below for values of C. -=item B<< C)C >> +=item B<< C ) C> >> Designate G1 Character Set (ISO 2022), see below for values of C. @@ -332,21 +354,22 @@ Tab Clear (TBC) =end table +=item B<< C >> + +Set Mode (SM). See B<< C >> sequence for description of C. + =item B<< C >> -Printing +Printing. See also the C resource. =begin table + B<< C >> print screen (MC0) B<< C >> disable transparent print mode (MC4) - B<< C >> enable transparent print mode (MC5) I + B<< C >> enable transparent print mode (MC5) =end table -=item B<< C >> - -Set Mode (SM). See next sequence for description of C. - =item B<< C >> Reset Mode (RM) @@ -381,12 +404,12 @@ Character Attributes (SGR) B<< C >> Normal (default) B<< C >> On / Off Bold (bright fg) - B<< C >> On / Off Italic (NYI) + B<< C >> On / Off Italic B<< C >> On / Off Underline B<< C >> On / Off Slow Blink (bright bg) B<< C >> On / Off Rapid Blink (bright bg) - B<< C >> On / Off Invisible (NYI) - B<< C >> On / Off Inverse + B<< C >> On / Off Inverse + B<< C >> On / Off Invisible (NYI) B<< C >> fg/bg Black B<< C >> fg/bg Red B<< C >> fg/bg Green @@ -394,6 +417,7 @@ Character Attributes (SGR) B<< C >> fg/bg Blue B<< C >> fg/bg Magenta B<< C >> fg/bg Cyan + B<< C >> set fg/bg to color #m (ISO 8613-6) B<< C >> fg/bg White B<< C >> fg/bg Default B<< C >> fg/bg Bright Black @@ -747,8 +771,13 @@ B can be escaped by prefixing it with SYN (0x16, ^V). B<< C >> Set fontset to B<< C >>, with the following special values of B<< C >> (B) B<< C<#+n> >> change up B<< C >> B<< C<#-n> >> change down B<< C >> if B<< C >> is missing of 0, a value of 1 is used I change to font0 B<< C >> change to font B<< C >> B<< C >> Log all scrollback buffer and all of screen to B<< C >> B<< C >> Change current locale to B<< C >>, or, if B<< C >> is B<< C >>, return the current locale (@@RXVT_NAME@@ extension) - B<< C >> find font for character, used for debugging (@@RXVT_NAME@@ extension) - B<< C >> menubar command B<< C >> I (@@RXVT_NAME@@ extension) + B<< C >> Menubar command B<< C >> I (rxvt-unicode extension) + B<< C >> Change colour of italic characters to B<< C >> + B<< C >> Change background pixmap tint colour to B<< C >> + B<< C >> Set normal fontset to B<< C >>. Same as C. + B<< C >> Set bold fontset to B<< C >>. Similar to C. + B<< C >> Set italic fontset to B<< C >>. Similar to C. + B<< C >> Set bold-italic fontset to B<< C >>. Similar to C. =end table @@ -1435,13 +1464,19 @@ Add support for Xft (anti-aliases, among others) fonts. Xft fonts are slower and require lots of memory, but as long as you don't use them, you don't pay for them. +=item --enable-font-styles + +Add support for B, I and B<< I >> font +styles. The fonts can be set manually or automatically. + =item --with-codesets=NAME,... -Compile in support for additional codeset (encoding) groups. These codeset -tables are currently only used for driving X11 core fonts, they are not -required for Xft fonts. Compiling them in will make your binary bigger -(together about 700kB), but it doesn't increase memory usage unless you -use an X11 font requiring one of these encodings. +Compile in support for additional codeset (encoding) groups (eu, vn are +always compiled in, which includes most 8-bit character sets). These +codeset tables are currently only used for driving X11 core fonts, they +are not required for Xft fonts. Compiling them in will make your binary +bigger (together about 700kB), but it doesn't increase memory usage unless +you use an X11 font requiring one of these encodings. =begin table @@ -1662,13 +1697,6 @@ Add smart growth/shrink behaviour when changing font size via from hot keys. This should keep in a fixed position the rxvt corner which is closest to a corner of the screen. -=item --enable-256-color - -Add support for 256 colours rather than the base 16 colours. - -This option will likely go away in the future. Speak up if you don't want -this. - =item --enable-cursor-blink Add support for a blinking cursor. diff --git a/src/command.C b/src/command.C index 3cd5077..338e812 100644 --- a/src/command.C +++ b/src/command.C @@ -135,7 +135,8 @@ rxvt_term::iso14755_54 (int x, int y) if (t != NOCHAR || !x) { - iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); + iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], + screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); iso14755buf = ISO_14755_54; break; } @@ -148,9 +149,11 @@ rxvt_term::iso14755_54 (int x, int y) #if ENABLE_OVERLAY void -rxvt_term::iso14755_51 (wchar_t ch) +rxvt_term::iso14755_51 (unicode_t ch, rend_t r) { - wchar_t *chr, *alloc; + rxvt_fontset *fs = FONTSET (r); + rxvt_font *f = (*fs)[fs->find_font (ch)]; + wchar_t *chr, *alloc, ch2; int len; #if ENABLE_COMBINING @@ -163,12 +166,18 @@ rxvt_term::iso14755_51 (wchar_t ch) else #endif { + ch2 = ch; + alloc = 0; - chr = &ch; + chr = &ch2; len = 1; } - scr_overlay_new (0, -1, 8 + 5, len); + int width = strlen (f->name); + + scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); + + r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); for (int y = 0; y < len; y++) { @@ -183,10 +192,12 @@ rxvt_term::iso14755_51 (wchar_t ch) if (ch >= 0x10000) ch = 0xfffd; #endif - scr_overlay_set (11, y, ch); - scr_overlay_set (12, y, NOCHAR); + scr_overlay_set (11, y, ch, r); + scr_overlay_set (12, y, NOCHAR, r); } + scr_overlay_set (0, len, f->name); + #if ENABLE_COMBINING if (alloc) delete [] alloc; @@ -1139,10 +1150,9 @@ rxvt_term::mouse_report (XButtonEvent &ev) #ifdef MOUSE_REPORT_DOUBLECLICK key_state += ((MEvent.clicks > 1) ? 32 : 0); #endif - } -#ifdef DEBUG_MOUSEREPORT +#if DEBUG_MOUSEREPORT fprintf (stderr, "Mouse ["); if (key_state & 16) fputc ('C', stderr); @@ -1156,12 +1166,12 @@ rxvt_term::mouse_report (XButtonEvent &ev) button_number, x + 1, y + 1); -#else +#endif + tt_printf ("\033[M%c%c%c", (32 + button_number + key_state), (32 + x + 1), (32 + y + 1)); -#endif } #ifdef USING_W11LIB @@ -1229,7 +1239,7 @@ rxvt_term::x_cb (XEvent &ev) case KeyRelease: { -#if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) +#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 KeySym ks; ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ @@ -1390,9 +1400,7 @@ rxvt_term::x_cb (XEvent &ev) if (rs[Rs_fade]) { pix_colors = pix_colors_focused; - set_colorfgbg (); - scr_clear (); - scr_touch (true); + scr_recolour (); } #endif @@ -1404,6 +1412,13 @@ rxvt_term::x_cb (XEvent &ev) { TermWin.focus = 0; want_refresh = 1; + +#if ENABLE_FRILLS || ISO_14755 + iso14755buf = 0; +#endif +#if ENABLE_OVERLAY + scr_overlay_off (); +#endif #ifdef USE_XIM if (Input_Context != NULL) XUnsetICFocus (Input_Context); @@ -1417,12 +1432,9 @@ rxvt_term::x_cb (XEvent &ev) if (rs[Rs_fade]) { pix_colors = pix_colors_unfocused; - set_colorfgbg (); - scr_clear (); - scr_touch (true); + scr_recolour (); } #endif - } break; @@ -1440,7 +1452,10 @@ rxvt_term::x_cb (XEvent &ev) while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); if (szHint.width != width || szHint.height != height) - resize_all_windows (width, height, 1); + { + seen_resize = 1; + resize_all_windows (width, height, 1); + } #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ if (options & Opt_transparent) @@ -2517,11 +2532,9 @@ rxvt_term::check_our_parents () 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); } @@ -2559,7 +2572,11 @@ rxvt_term::cmd_parse () // they first read the screensize and then install a SIGWINCH handler. // some window managers resize the window early, and these programs // then sometimes get the size wrong. - kill (-cmd_pid, SIGWINCH); + // unfortunately other programs are even more buggy and dislike + // being sent SIGWINCH, so only do it when we were in fact being + // resized. + if (seen_resize) + kill (-cmd_pid, SIGWINCH); } /* Read a text string from the input buffer */ @@ -3489,36 +3506,40 @@ rxvt_term::process_window_ops (const int *args, unsigned int nargs) unsigned char * rxvt_term::get_to_st (unicode_t &ends_how) { - unicode_t prev = 0, ch; + unicode_t seen_esc = 0, ch; unsigned int n = 0; unsigned char *s; unsigned char string[STRING_MAX]; while ((ch = cmd_getc ()) != NOCHAR) { - if (prev == C0_ESC) + if (seen_esc) { if (ch == 0x5c) /* 7bit ST */ break; else return NULL; } + else if (ch == C0_ESC) + { + seen_esc = 1; + continue; + } else if (ch == C0_BEL || ch == CHAR_ST) break; else if (ch < 0x20) return NULL; /* other control character - exit */ + seen_esc = 0; + if (n >= sizeof (string) - 1) // stop at some sane length return NULL; if (ch == C0_SYN) - { - string[n++] = cmd_get8 (); - prev = 0; - } + string[n++] = cmd_get8 (); else - string[n++] = prev = ch; + string[n++] = ch; } string[n++] = '\0'; @@ -3622,6 +3643,7 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) int color; char *buf, *name; bool query = str[0] == '?' && !str[1]; + int saveop = op; assert (str != NULL); switch (op) @@ -3723,6 +3745,9 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) case XTerm_Color_BD: process_color_seq (XTerm_Color_BD, Color_BD, str, resp); break; + case XTerm_Color_IT: + process_color_seq (XTerm_Color_IT, Color_IT, str, resp); + break; case XTerm_Color_UL: process_color_seq (XTerm_Color_UL, Color_UL, str, resp); break; @@ -3730,6 +3755,14 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) process_color_seq (XTerm_Color_RV, Color_RV, str, resp); break; #endif +#if TRANSPARENT || TINTING + case XTerm_Color_tint: + process_color_seq (XTerm_Color_tint, Color_tint, str, resp); + check_our_parents (); + if (am_transparent) + want_full_refresh = want_refresh = 1; + break; +#endif case XTerm_Pixmap: if (*str != ';') @@ -3769,13 +3802,26 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) break; case XTerm_font: + op = URxvt_font; + case URxvt_font: +#if ENABLE_STYLES + case URxvt_boldFont: + case URxvt_italicFont: + case URxvt_boldItalicFont: +#endif if (query) - tt_printf ("\33]%d;%-.250s%c", XTerm_font, - (options & Opt_insecure) && TermWin.fontset->fontdesc - ? TermWin.fontset->fontdesc : "", + tt_printf ("\33]%d;%-.250s%c", saveop, + (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc + ? TermWin.fontset[op - URxvt_font]->fontdesc : "", resp); else - change_font (str); + { + const char *&res = rs[Rs_font + (op - URxvt_font)]; + + res = strdup (str); + allocated.push_back ((void *)res); + set_fonts (); + } break; #if ENABLE_FRILLS @@ -3790,16 +3836,6 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) # endif } break; - - case XTerm_findfont: - { - int fid = TermWin.fontset->find_font (atoi (str)); - tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, - fid, - (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "", - resp); - } - break; #endif #ifdef MENUBAR @@ -3937,6 +3973,7 @@ rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), u switch (arg[i]) { case 1048: /* alternative cursor save */ + case 1049: if (options & Opt_secondaryScreen) if (mode == 0) scr_cursor (RESTORE); @@ -4071,8 +4108,10 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) case 1: rendset = 1, rendstyle = RS_Bold; break; - //case 2: // faint or second colour - //case 3: // italic + //case 2: // low intensity + case 3: + rendset = 1, rendstyle = RS_Italic; + break; case 4: rendset = 1, rendstyle = RS_Uline; break; @@ -4094,20 +4133,22 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) //... //case 19: // ninth alt font //case 20: // gothic - case 21: // disable bold, faint + case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) rendset = 0, rendstyle = RS_Bold; break; - case 22: + case 22: // normal intensity rendset = 0, rendstyle = RS_Bold; break; - //case 23: disable italic + case 23: // disable italic + rendset = 0, rendstyle = RS_Italic; + break; case 24: rendset = 0, rendstyle = RS_Uline; break; case 25: rendset = 0, rendstyle = RS_Blink; break; - case 26: + case 26: // variable spacing (iso 8613) rendset = 0, rendstyle = RS_Blink; break; case 27: @@ -4135,15 +4176,13 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) case 37: scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); break; -#ifdef TTY_256COLOR - case 38: + case 38: // set fg color, ISO 8613-6 if (nargs > i + 2 && arg[i + 1] == 5) { scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); i += 2; } break; -#endif case 39: /* default fg */ scr_color (Color_fg, Color_fg); break; @@ -4158,19 +4197,19 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) case 47: scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); break; -#ifdef TTY_256COLOR - case 48: + case 48: // set bg color, ISO 8613-6 if (nargs > i + 2 && arg[i + 1] == 5) { scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); i += 2; } break; -#endif case 49: /* default bg */ scr_color (Color_bg, Color_bg); break; + //case 50: // not variable spacing + #ifndef NO_BRIGHTCOLOR case 90: case 91: /* set bright fg color */ @@ -4180,8 +4219,7 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) case 95: case 96: case 97: - scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), - Color_fg); + scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); break; case 100: case 101: /* set bright bg color */ @@ -4191,8 +4229,7 @@ rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) case 105: case 106: case 107: - scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), - Color_bg); + scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); break; #endif @@ -4244,7 +4281,7 @@ rxvt_term::tt_printf (const char *fmt,...) void rxvt_term::tt_write (const unsigned char *data, unsigned int len) { - enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT + const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT if (len) { @@ -4268,7 +4305,7 @@ rxvt_term::tt_write (const unsigned char *data, unsigned int len) for (;;) { - int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen)); + int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); if (written > 0) { diff --git a/src/init.C b/src/init.C index d3ea2af..42e4033 100644 --- a/src/init.C +++ b/src/init.C @@ -69,248 +69,81 @@ const char *const def_colorName[] = "Magenta", /* 5/13: bright magenta (#FF00FF) */ "Cyan", /* 6/14: bright cyan (#00FFFF) */ "White", /* 7/15: bright white (#FFFFFF) */ -#ifdef TTY_256COLOR - "rgbi:0/0/0", /* default 16-255 color table */ - "rgbi:0/0/.2", /* consists of 6 6x6 colour cubes */ - "rgbi:0/0/.4", /* and a 24 greyscale ramp w/o */ - "rgbi:0/0/.6", /* black or white */ - "rgbi:0/0/.8", - "rgbi:0/0/1", - "rgbi:0/.2/0", - "rgbi:0/.2/.2", - "rgbi:0/.2/.4", - "rgbi:0/.2/.6", - "rgbi:0/.2/.8", - "rgbi:0/.2/1", - "rgbi:0/.4/0", - "rgbi:0/.4/.2", - "rgbi:0/.4/.4", - "rgbi:0/.4/.6", - "rgbi:0/.4/.8", - "rgbi:0/.4/1", - "rgbi:0/.6/0", - "rgbi:0/.6/.2", - "rgbi:0/.6/.4", - "rgbi:0/.6/.6", - "rgbi:0/.6/.8", - "rgbi:0/.6/1", - "rgbi:0/.8/0", - "rgbi:0/.8/.2", - "rgbi:0/.8/.4", - "rgbi:0/.8/.6", - "rgbi:0/.8/.8", - "rgbi:0/.8/1", - "rgbi:0/1/0", - "rgbi:0/1/.2", - "rgbi:0/1/.4", - "rgbi:0/1/.6", - "rgbi:0/1/.8", - "rgbi:0/1/1", - "rgbi:.2/0/0", - "rgbi:.2/0/.2", - "rgbi:.2/0/.4", - "rgbi:.2/0/.6", - "rgbi:.2/0/.8", - "rgbi:.2/0/1", - "rgbi:.2/.2/0", - "rgbi:.2/.2/.2", - "rgbi:.2/.2/.4", - "rgbi:.2/.2/.6", - "rgbi:.2/.2/.8", - "rgbi:.2/.2/1", - "rgbi:.2/.4/0", - "rgbi:.2/.4/.2", - "rgbi:.2/.4/.4", - "rgbi:.2/.4/.6", - "rgbi:.2/.4/.8", - "rgbi:.2/.4/1", - "rgbi:.2/.6/0", - "rgbi:.2/.6/.2", - "rgbi:.2/.6/.4", - "rgbi:.2/.6/.6", - "rgbi:.2/.6/.8", - "rgbi:.2/.6/1", - "rgbi:.2/.8/0", - "rgbi:.2/.8/.2", - "rgbi:.2/.8/.4", - "rgbi:.2/.8/.6", - "rgbi:.2/.8/.8", - "rgbi:.2/.8/1", - "rgbi:.2/1/0", - "rgbi:.2/1/.2", - "rgbi:.2/1/.4", - "rgbi:.2/1/.6", - "rgbi:.2/1/.8", - "rgbi:.2/1/1", - "rgbi:.4/0/0", - "rgbi:.4/0/.2", - "rgbi:.4/0/.4", - "rgbi:.4/0/.6", - "rgbi:.4/0/.8", - "rgbi:.4/0/1", - "rgbi:.4/.2/0", - "rgbi:.4/.2/.2", - "rgbi:.4/.2/.4", - "rgbi:.4/.2/.6", - "rgbi:.4/.2/.8", - "rgbi:.4/.2/1", - "rgbi:.4/.4/0", - "rgbi:.4/.4/.2", - "rgbi:.4/.4/.4", - "rgbi:.4/.4/.6", - "rgbi:.4/.4/.8", - "rgbi:.4/.4/1", - "rgbi:.4/.6/0", - "rgbi:.4/.6/.2", - "rgbi:.4/.6/.4", - "rgbi:.4/.6/.6", - "rgbi:.4/.6/.8", - "rgbi:.4/.6/1", - "rgbi:.4/.8/0", - "rgbi:.4/.8/.2", - "rgbi:.4/.8/.4", - "rgbi:.4/.8/.6", - "rgbi:.4/.8/.8", - "rgbi:.4/.8/1", - "rgbi:.4/1/0", - "rgbi:.4/1/.2", - "rgbi:.4/1/.4", - "rgbi:.4/1/.6", - "rgbi:.4/1/.8", - "rgbi:.4/1/1", - "rgbi:.6/0/0", - "rgbi:.6/0/.2", - "rgbi:.6/0/.4", - "rgbi:.6/0/.6", - "rgbi:.6/0/.8", - "rgbi:.6/0/1", - "rgbi:.6/.2/0", - "rgbi:.6/.2/.2", - "rgbi:.6/.2/.4", - "rgbi:.6/.2/.6", - "rgbi:.6/.2/.8", - "rgbi:.6/.2/1", - "rgbi:.6/.4/0", - "rgbi:.6/.4/.2", - "rgbi:.6/.4/.4", - "rgbi:.6/.4/.6", - "rgbi:.6/.4/.8", - "rgbi:.6/.4/1", - "rgbi:.6/.6/0", - "rgbi:.6/.6/.2", - "rgbi:.6/.6/.4", - "rgbi:.6/.6/.6", - "rgbi:.6/.6/.8", - "rgbi:.6/.6/1", - "rgbi:.6/.8/0", - "rgbi:.6/.8/.2", - "rgbi:.6/.8/.4", - "rgbi:.6/.8/.6", - "rgbi:.6/.8/.8", - "rgbi:.6/.8/1", - "rgbi:.6/1/0", - "rgbi:.6/1/.2", - "rgbi:.6/1/.4", - "rgbi:.6/1/.6", - "rgbi:.6/1/.8", - "rgbi:.6/1/1", - "rgbi:.8/0/0", - "rgbi:.8/0/.2", - "rgbi:.8/0/.4", - "rgbi:.8/0/.6", - "rgbi:.8/0/.8", - "rgbi:.8/0/1", - "rgbi:.8/.2/0", - "rgbi:.8/.2/.2", - "rgbi:.8/.2/.4", - "rgbi:.8/.2/.6", - "rgbi:.8/.2/.8", - "rgbi:.8/.2/1", - "rgbi:.8/.4/0", - "rgbi:.8/.4/.2", - "rgbi:.8/.4/.4", - "rgbi:.8/.4/.6", - "rgbi:.8/.4/.8", - "rgbi:.8/.4/1", - "rgbi:.8/.6/0", - "rgbi:.8/.6/.2", - "rgbi:.8/.6/.4", - "rgbi:.8/.6/.6", - "rgbi:.8/.6/.8", - "rgbi:.8/.6/1", - "rgbi:.8/.8/0", - "rgbi:.8/.8/.2", - "rgbi:.8/.8/.4", - "rgbi:.8/.8/.6", - "rgbi:.8/.8/.8", - "rgbi:.8/.8/1", - "rgbi:.8/1/0", - "rgbi:.8/1/.2", - "rgbi:.8/1/.4", - "rgbi:.8/1/.6", - "rgbi:.8/1/.8", - "rgbi:.8/1/1", - "rgbi:1/0/0", - "rgbi:1/0/.2", - "rgbi:1/0/.4", - "rgbi:1/0/.6", - "rgbi:1/0/.8", - "rgbi:1/0/1", - "rgbi:1/.2/0", - "rgbi:1/.2/.2", - "rgbi:1/.2/.4", - "rgbi:1/.2/.6", - "rgbi:1/.2/.8", - "rgbi:1/.2/1", - "rgbi:1/.4/0", - "rgbi:1/.4/.2", - "rgbi:1/.4/.4", - "rgbi:1/.4/.6", - "rgbi:1/.4/.8", - "rgbi:1/.4/1", - "rgbi:1/.6/0", - "rgbi:1/.6/.2", - "rgbi:1/.6/.4", - "rgbi:1/.6/.6", - "rgbi:1/.6/.8", - "rgbi:1/.6/1", - "rgbi:1/.8/0", - "rgbi:1/.8/.2", - "rgbi:1/.8/.4", - "rgbi:1/.8/.6", - "rgbi:1/.8/.8", - "rgbi:1/.8/1", - "rgbi:1/1/0", - "rgbi:1/1/.2", - "rgbi:1/1/.4", - "rgbi:1/1/.6", - "rgbi:1/1/.8", - "rgbi:1/1/1", - "rgb:08/08/08", - "rgb:12/12/12", - "rgb:1c/1c/1c", - "rgb:26/26/26", - "rgb:30/30/30", - "rgb:3a/3a/3a", - "rgb:44/44/44", - "rgb:4e/4e/4e", - "rgb:58/58/58", - "rgb:62/62/62", - "rgb:6c/6c/6c", - "rgb:76/76/76", - "rgb:80/80/80", - "rgb:8a/8a/8a", - "rgb:94/94/94", - "rgb:9e/9e/9e", - "rgb:a8/a8/a8", - "rgb:b2/b2/b2", - "rgb:bc/bc/bc", - "rgb:c6/c6/c6", + + // 88 xterm colours + "rgb:00/00/00", + "rgb:00/00/8b", + "rgb:00/00/cd", + "rgb:00/00/ff", + "rgb:00/8b/00", + "rgb:00/8b/8b", + "rgb:00/8b/cd", + "rgb:00/8b/ff", + "rgb:00/cd/00", + "rgb:00/cd/8b", + "rgb:00/cd/cd", + "rgb:00/cd/ff", + "rgb:00/ff/00", + "rgb:00/ff/8b", + "rgb:00/ff/cd", + "rgb:00/ff/ff", + "rgb:8b/00/00", + "rgb:8b/00/8b", + "rgb:8b/00/cd", + "rgb:8b/00/ff", + "rgb:8b/8b/00", + "rgb:8b/8b/8b", + "rgb:8b/8b/cd", + "rgb:8b/8b/ff", + "rgb:8b/cd/00", + "rgb:8b/cd/8b", + "rgb:8b/cd/cd", + "rgb:8b/cd/ff", + "rgb:8b/ff/00", + "rgb:8b/ff/8b", + "rgb:8b/ff/cd", + "rgb:8b/ff/ff", + "rgb:cd/00/00", + "rgb:cd/00/8b", + "rgb:cd/00/cd", + "rgb:cd/00/ff", + "rgb:cd/8b/00", + "rgb:cd/8b/8b", + "rgb:cd/8b/cd", + "rgb:cd/8b/ff", + "rgb:cd/cd/00", + "rgb:cd/cd/8b", + "rgb:cd/cd/cd", + "rgb:cd/cd/ff", + "rgb:cd/ff/00", + "rgb:cd/ff/8b", + "rgb:cd/ff/cd", + "rgb:cd/ff/ff", + "rgb:ff/00/00", + "rgb:ff/00/8b", + "rgb:ff/00/cd", + "rgb:ff/00/ff", + "rgb:ff/8b/00", + "rgb:ff/8b/8b", + "rgb:ff/8b/cd", + "rgb:ff/8b/ff", + "rgb:ff/cd/00", + "rgb:ff/cd/8b", + "rgb:ff/cd/cd", + "rgb:ff/cd/ff", + "rgb:ff/ff/00", + "rgb:ff/ff/8b", + "rgb:ff/ff/cd", + "rgb:ff/ff/ff", + "rgb:2e/2e/2e", + "rgb:5c/5c/5c", + "rgb:73/73/73", + "rgb:8b/8b/8b", + "rgb:a2/a2/a2", + "rgb:b9/b9/b9", "rgb:d0/d0/d0", - "rgb:da/da/da", - "rgb:e4/e4/e4", - "rgb:ee/ee/ee", -#endif + "rgb:e7/e7/e7", + #ifndef NO_CURSORCOLOR COLOR_CURSOR_BACKGROUND, COLOR_CURSOR_FOREGROUND, @@ -320,6 +153,7 @@ const char *const def_colorName[] = NULL, /* Color_border */ #ifndef NO_BOLD_UNDERLINE_REVERSE NULL, /* Color_BD */ + NULL, /* Color_IT */ NULL, /* Color_UL */ NULL, /* Color_RV */ #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ @@ -388,10 +222,6 @@ rxvt_term::init_vars () TermWin.saveLines = SAVELINES; numpix_colors = TOTAL_COLORS; -#ifndef NO_BRIGHTCOLOR - colorfgbg = DEFAULT_RSTYLE; -#endif - refresh_limit = 1; refresh_type = SLOW_REFRESH; prev_nrow = prev_ncol = 0; @@ -601,8 +431,7 @@ rxvt_term::init_resources (int argc, const char *const *argv) } #ifdef HAVE_SCROLLBARS - setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], - rs[Rs_scrollBar_thickness]); + setup_scrollbar (rs[Rs_scrollBar_align], rs[Rs_scrollstyle], rs[Rs_scrollBar_thickness]); #endif #ifdef XTERM_REVERSE_VIDEO @@ -642,6 +471,9 @@ rxvt_term::init_resources (int argc, const char *const *argv) color_aliases (Color_RV); #endif /* ! NO_BOLD_UNDERLINE_REVERSE */ + if (!rs[Rs_color + Color_border]) + rs[Rs_color + Color_border] = rs[Rs_color + Color_bg]; + return cmd_argv; } @@ -987,7 +819,6 @@ rxvt_term::color_aliases (int idx) rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i]; return; #endif - } if (i >= 0 && i <= 7) /* normal colors */ @@ -1115,12 +946,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) /* grab colors before netscape does */ Get_Colours (); - if (!change_font (rs[Rs_font])) - { - fprintf (stderr, "unable to load a base font, please provide one using -fn fontname\n"); - destroy (); - return; - } + if (!set_fonts ()) + rxvt_fatal ("unable to load base fontset, please specify one using -fn, aborting.\n"); window_calc (0, 0); old_width = szHint.width; @@ -1129,8 +956,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) /* sub-window placement & size in rxvt_resize_subwindows () */ #ifdef PREFER_24BIT - attributes.background_pixel = pix_colors[Color_bg]; - attributes.border_pixel = pix_colors[Color_border]; + attributes.background_pixel = pix_colors_focused[Color_border]; + attributes.border_pixel = pix_colors_focused[Color_border]; attributes.colormap = display->cmap; TermWin.parent[0] = XCreateWindow (display->display, DefaultRootWindow (display->display), szHint.x, szHint.y, @@ -1144,8 +971,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) szHint.x, szHint.y, szHint.width, szHint.height, TermWin.ext_bwidth, - pix_colors[Color_border], - pix_colors[Color_bg]); + pix_colors_focused[Color_border], + pix_colors_focused[Color_border]); #endif process_xterm_seq (XTerm_title, rs[Rs_title], CHAR_ST); @@ -1171,7 +998,7 @@ rxvt_term::create_windows (int argc, const char *const *argv) XSelectInput (display->display, TermWin.parent[0], KeyPressMask -#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) +#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ENABLE_FRILLS || ISO_14755 | KeyReleaseMask #endif | FocusChangeMask | VisibilityChangeMask @@ -1182,8 +1009,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) #if ENABLE_FRILLS if (mwmhints.flags) { - prop = XInternAtom(display->display, "_MOTIF_WM_HINTS", False); - XChangeProperty(display->display, TermWin.parent[0], prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); + prop = XInternAtom (display->display, "_MOTIF_WM_HINTS", False); + XChangeProperty (display->display, TermWin.parent[0], prop, prop, 32, PropModeReplace, (unsigned char *) &mwmhints, PROP_MWM_HINTS_ELEMENTS); } #endif @@ -1215,8 +1042,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) TermWin_TotalWidth (), TermWin_TotalHeight (), 0, - pix_colors[Color_fg], - pix_colors[Color_bg]); + pix_colors_focused[Color_fg], + pix_colors_focused[Color_bg]); #ifdef DEBUG_X XStoreName (display->display, TermWin.vt, "vt window"); #endif @@ -1246,8 +1073,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) TermWin_TotalWidth (), menuBar_TotalHeight (), 0, - pix_colors[Color_fg], - pix_colors[Color_scroll]); + pix_colors_focused[Color_fg], + pix_colors_focused[Color_scroll]); #ifdef DEBUG_X XStoreName (display->display, menuBar.win, "menubar"); @@ -1276,8 +1103,9 @@ rxvt_term::create_windows (int argc, const char *const *argv) p++; scale_pixmap (p); } + set_bgPixmap (rs[Rs_backgroundPixmap]); - scr_touch (True); + scr_touch (true); } #endif @@ -1305,6 +1133,8 @@ rxvt_term::create_windows (int argc, const char *const *argv) if (rs[Rs_fade]) pix_colors = pix_colors_unfocused; #endif + + scr_recolour (); } /* ------------------------------------------------------------------------- * diff --git a/src/rxvt.h b/src/rxvt.h index 6a7ff91..ef52f34 100644 --- a/src/rxvt.h +++ b/src/rxvt.h @@ -125,7 +125,7 @@ struct grwin_t; /* If we're using either the rxvt scrollbar or menu bars, keep the * scrollColor resource. */ -#if defined(RXVT_SCROLLBAR) || defined(MENUBAR) +#if defined(RXVT_SCROLLBAR) || defined(MENUBAR) || defined(PLAIN_SCROLLBAR) # define KEEP_SCROLLCOLOR 1 #else # undef KEEP_SCROLLCOLOR @@ -185,7 +185,7 @@ typedef struct _mwmhints { # define COLORTERMENVFULL COLORTERMENV #endif #ifndef TERMENV -# define TERMENV "rxvt" +# define TERMENV "rxvt-unicode" #endif #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR) @@ -352,20 +352,36 @@ enum { #define RS_None 0 /* Normal */ -#define RS_fgMask 0x000001FFUL /* 512 colors */ -#define RS_bgMask 0x0003FE00UL /* 512 colors */ -#define RS_Bold 0x00040000UL /* bold */ -#define RS_Italic 0x00080000UL -#define RS_Blink 0x00100000UL /* blink */ -#define RS_RVid 0x00200000UL /* reverse video */ -#define RS_Uline 0x00400000UL /* underline */ +#define RS_fgMask 0x0000007fUL /* 128 colors */ +#define RS_bgMask 0x00003f80UL /* 128 colors */ -#define RS_fontCount 512 -#define RS_fontMask 0xff800000UL /* plenty(?) of fonts */ -#define RS_fontShift 23 +// font styles +#define RS_Bold 0x00004000UL // value 1 +#define RS_Italic 0x00008000UL // value 2 -#define RS_baseattrMask (RS_Bold|RS_Blink|RS_RVid|RS_Uline) -#define RS_attrMask (RS_baseattrMask|RS_fontMask) +// fake styles +#define RS_Blink 0x00010000UL /* blink */ +#define RS_RVid 0x00020000UL /* reverse video */ +#define RS_Uline 0x00040000UL /* underline */ + +// 5 bits still to go + +// other flags +#define RS_Careful 0x80000000UL /* be careful when drawing these */ + +#define RS_styleCount 4 +#define RS_styleMask (RS_Bold | RS_Italic) +#define RS_styleShift 14 + +#define RS_baseattrMask (RS_Italic | RS_Bold | RS_Blink | RS_RVid | RS_Uline) +#define RS_attrMask (RS_baseattrMask | RS_fontMask) + +#define RS_fontCount 127 // not 127 or 256, see rxvtfont.h +#define RS_fontMask 0xff000000UL // plenty(?) of fonts, includes RS_Careful +#define RS_fontShift 24 + +#define DEFAULT_RSTYLE (RS_None | Color_fg | (Color_bg << Color_Bits)) +#define OVERLAY_RSTYLE (RS_None | Color_Black | (Color_Yellow << Color_Bits)) #define Sel_none 0 /* Not waiting */ #define Sel_normal 0x01 /* normal selection */ @@ -421,8 +437,14 @@ enum { XTerm_restoreBG = 49, // change default bg color XTerm_dumpscreen = 55, // dump scrollback and all of screen XTerm_locale = 701, // change locale - XTerm_findfont = 702, // find font of given character (in decimal) XTerm_Menu = 703, // set menu item + XTerm_Color_IT = 704, // change actual 'Italic' colour + XTerm_Color_tint = 705, // change actual tint colour + + URxvt_font = 710, + URxvt_boldFont = 711, + URxvt_italicFont = 712, + URxvt_boldItalicFont = 713, }; /* Words starting with `Color_' are colours. Others are counts */ @@ -461,10 +483,8 @@ enum colour_list { #else Color_White = maxCOLOR, #endif -#ifdef TTY_256COLOR - min256COLOR = Color_White + 1, - max256COLOR = minCOLOR + 255, -#endif + minTermCOLOR = Color_White + 1, + maxTermCOLOR = Color_White + 72, #ifndef NO_CURSORCOLOR Color_cursor, Color_cursor2, @@ -474,6 +494,7 @@ enum colour_list { Color_border, #ifndef NO_BOLD_UNDERLINE_REVERSE Color_BD, + Color_IT, Color_UL, Color_RV, #endif @@ -491,18 +512,17 @@ enum colour_list { #ifdef KEEP_SCROLLCOLOR Color_topShadow = NRS_COLORS, Color_bottomShadow, - TOTAL_COLORS /* upto 30 */ + TOTAL_COLORS #else - TOTAL_COLORS = NRS_COLORS /* */ + TOTAL_COLORS = NRS_COLORS #endif }; -#define Color_Bits 9 +#define Color_Bits 7 // 0 .. maxTermCOLOR + #define NPIXCLR_SETS ((TOTAL_COLORS + 31) / 32) #define NPIXCLR_BITS 32 -#define DEFAULT_RSTYLE (RS_None | (Color_fg) | (Color_bg<> RS_fontShift) -#define SET_FONT(x,fid) ((x) & ~RS_fontMask) | ((fid) << RS_fontShift) +#define SET_FONT(x,fid) (((x) & ~RS_fontMask) | ((fid) << RS_fontShift)) + +#define GET_STYLE(x) (((x) & RS_styleMask) >> RS_styleShift) +#define SET_STYLE(x,style) (((x) & ~RS_styleMask) | ((style) << RS_styleShift)) #define GET_ATTR(x) (((x) & RS_attrMask)) #define GET_BGATTR(x) \ (((x) & RS_RVid) ? (((x) & (RS_attrMask & ~RS_RVid)) \ | (((x) & RS_fgMask)< /* get the typedef for CARD32 */ @@ -114,12 +113,13 @@ inline void fill_text (text_t *start, text_t value, int len) /* ------------------------------------------------------------------------- * * SCREEN `COMMON' ROUTINES * * ------------------------------------------------------------------------- */ + /* Fill part/all of a line with blanks. */ void rxvt_term::scr_blank_line (text_t *et, rend_t *er, unsigned int width, rend_t efs) { efs &= ~RS_baseattrMask; - efs = SET_FONT (efs, TermWin.ascii_map [' ' - 0x20]); + efs = SET_FONT (efs, FONTSET (efs)->find_font (' ')); while (width--) { @@ -419,7 +419,7 @@ rxvt_term::scr_reset () void rxvt_term::scr_reset_realloc () { - uint16_t total_rows, nrow; + unsigned int total_rows, nrow; nrow = TermWin.nrow; total_rows = nrow + TermWin.saveLines; @@ -446,7 +446,7 @@ rxvt_term::scr_reset_realloc () void rxvt_term::scr_release () { - uint16_t total_rows; + unsigned int total_rows; int i; total_rows = TermWin.nrow + TermWin.saveLines; @@ -513,21 +513,21 @@ rxvt_term::scr_cursor (int mode) switch (mode) { case SAVE: - s->s_cur.row = s->cur.row; - s->s_cur.col = s->cur.col; + s->s_cur.row = screen.cur.row; + s->s_cur.col = screen.cur.col; s->s_rstyle = rstyle; - s->s_charset = s->charset; - s->s_charset_char = charsets[s->charset]; + s->s_charset = screen.charset; + s->s_charset_char = charsets[screen.charset]; break; case RESTORE: want_refresh = 1; - s->cur.row = s->s_cur.row; - s->cur.col = s->s_cur.col; - s->flags &= ~Screen_WrapNext; + screen.cur.row = s->s_cur.row; + screen.cur.col = s->s_cur.col; + screen.flags &= ~Screen_WrapNext; rstyle = s->s_rstyle; - s->charset = s->s_charset; - charsets[s->charset] = s->s_charset_char; + screen.charset = s->s_charset; + charsets[screen.charset] = s->s_charset_char; set_font_style (); break; } @@ -627,7 +627,9 @@ rxvt_term::scr_do_wrap () void rxvt_term::scr_color (unsigned int color, int fgbg) { - color &= RS_fgMask; + if (color > maxTermCOLOR) + color = fgbg; + if (fgbg == Color_fg) rstyle = SET_FGCOLOR (rstyle, color); else @@ -675,7 +677,7 @@ rxvt_term::scr_scroll_text (int row1, int row2, int count, int spec) if (nscrolled > (long)TermWin.saveLines) TermWin.nscrolled = TermWin.saveLines; else - TermWin.nscrolled = (uint16_t)nscrolled; + TermWin.nscrolled = (unsigned int)nscrolled; if ((options & Opt_scrollWithBuffer) && TermWin.view_start != 0 @@ -828,7 +830,7 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) switch (c) { case C0_HT: - scr_tab (1); + scr_tab (1, true); continue; case C0_LF: @@ -889,22 +891,32 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) if (charsets[screen.charset] == '0') // DEC SPECIAL { // vt100 special graphics and line drawing - static uint16_t vt100_0[32] = { // 5f .. 7e - 0x0020, 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, - 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, - 0x23ba, 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, - 0x252c, 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, + // 5f-7e standard vt100 + // 40-5e rxvt extension for extra curses acs chars + static uint16_t vt100_0[63] = { // 5f .. 7e + 0x0000, 0x2191, 0x2193, 0x2192, 0x2190, 0x2588, 0x259a, 0x2603, // 40-47 hi mr. snowman! + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 48-4f + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 50-57 + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, // 58-5f + 0x25c6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, 0x00b1, // 60-67 + 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x23ba, // 68-6f + 0x23bb, 0x2500, 0x23bc, 0x23bd, 0x251c, 0x2524, 0x2534, 0x252c, // 70-77 + 0x2502, 0x2264, 0x2265, 0x03c0, 0x2260, 0x00a3, 0x00b7, // 78-7e }; - if (c >= 0x5f && c <= 0x7e) + if (c >= 0x40 && c <= 0x7e && vt100_0[c - 0x40]) { - c = vt100_0[c - 0x5f]; + c = vt100_0[c - 0x40]; width = 1; } } if (width != 0) { + // some utf-8 decoders decode surrogate characters. + if (0xd800 <= c && c <= 0xdfff) + c = 0xfffd; + #if !UNICODE_3 // trim characters we can't store directly :( if (c >= 0x10000) @@ -914,11 +926,29 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) c = 0xfffd; # endif #endif - bool bold = (options & Opt_realBold) && ((rstyle & RS_Bold) != 0); - rend_t rend = SET_FONT (rstyle, - c > 0x7f || bold || c < 0x20 - ? TermWin.fontset->find_font (c, bold) - : TermWin.ascii_map [c - 0x20]); + + // nuke the character at this position, if required + if (stp[screen.cur.col] == NOCHAR + || (screen.cur.col < TermWin.ncol - 1 + && stp[screen.cur.col + 1] == NOCHAR)) + { + int col = screen.cur.col; + + // find begin + while (col > 0 && stp[col] == NOCHAR) + col--; + + rend_t rend = SET_FONT (srp[col], FONTSET (srp[col])->find_font (' ')); + + // found begin, nuke + do { + stp[col] = ' '; + srp[col] = rend; + col++; + } while (col < TermWin.ncol && stp[col] == NOCHAR); + } + + rend_t rend = SET_FONT (rstyle, FONTSET (rstyle)->find_font (c)); do { @@ -973,7 +1003,12 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) // handle double-width-chars by making them look extremely ugly if (*tp == NOCHAR) - *tp = ' '; // hack //D //TODO //--tp, --rp; + { + // hack //D //TODO //--tp, --rp; + *tp = ' '; + *rp &= ~RS_baseattrMask; + *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); + } // first try to find a precomposed character unicode_t n = rxvt_compose (*tp, c); @@ -981,7 +1016,7 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len) n = rxvt_composite.compose (*tp, c); *tp = n; - *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); + *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); #endif } } @@ -1030,7 +1065,7 @@ rxvt_term::scr_backspace () * XTERM_SEQ: CTRL-I */ void -rxvt_term::scr_tab (int count) +rxvt_term::scr_tab (int count, bool ht) { int i, x; @@ -1041,6 +1076,12 @@ rxvt_term::scr_tab (int count) return; else if (count > 0) { + int row = TermWin.saveLines + screen.cur.row; + text_t *tp = screen.text[row]; + rend_t *rp = screen.rend[row]; + rend_t base_rend = rp[i]; + ht &= tp[i] == ' '; + for (; ++i < TermWin.ncol; ) if (tabs[i]) { @@ -1048,9 +1089,33 @@ rxvt_term::scr_tab (int count) if (!--count) break; } + else + ht &= tp[i] == ' ' + && RS_SAME (rp[i], base_rend); if (count) x = TermWin.ncol - 1; + + // store horizontal tab commands as characters inside the text + // buffer so they can be selected and pasted. + if (ht) + { + base_rend = SET_FONT (base_rend, 0); + + if (screen.tlen[row] != -1) /* XXX: think about this */ + MAX_IT (screen.tlen[row], x); + + i = screen.cur.col; + + tp[i] = '\t'; + rp[i] = base_rend; + + while (++i < x) + { + tp[i] = NOCHAR; + rp[i] = base_rend; + } + } } else /* if (count < 0) */ { @@ -1351,7 +1416,7 @@ rxvt_term::scr_E () num_scr_allow = 0; selection_check (3); - fs = SET_FONT (rstyle, TermWin.fontset->find_font ('E')); + fs = SET_FONT (rstyle, FONTSET (rstyle)->find_font ('E')); for (k = TermWin.saveLines, i = TermWin.nrow; i--; k++) { screen.tlen[k] = TermWin.ncol; /* make the `E's selectable */ @@ -1570,6 +1635,7 @@ rxvt_term::scr_relative_origin (int mode) screen.flags |= Screen_Relative; else screen.flags &= ~Screen_Relative; + scr_gotorc (0, 0, 0); } @@ -1619,10 +1685,10 @@ rxvt_term::scr_rvideo_mode (int mode) { rvideo = mode; SWAP_IT (pix_colors[Color_fg], pix_colors[Color_bg], rxvt_color); -#if defined(XPM_BACKGROUND) +#if XPM_BACKGROUND if (bgPixmap.pixmap == None) #endif -#if defined(TRANSPARENT) +#if TRANSPARENT if (! (options & Opt_transparent) || am_transparent == 0) #endif XSetWindowBackground (display->display, TermWin.vt, @@ -1810,7 +1876,7 @@ int rxvt_term::scr_move_to (int y, int len) { long p = 0; - uint16_t oldviewstart; + unsigned int oldviewstart; oldviewstart = TermWin.view_start; @@ -1821,7 +1887,7 @@ rxvt_term::scr_move_to (int y, int len) p = max (p, 0); } - TermWin.view_start = (uint16_t)min (p, TermWin.nscrolled); + TermWin.view_start = (unsigned int)min (p, TermWin.nscrolled); return scr_changeview (oldviewstart); } @@ -1835,7 +1901,7 @@ int rxvt_term::scr_page (enum page_dirn direction, int nlines) { int n; - uint16_t oldviewstart; + unsigned int oldviewstart; #ifdef DEBUG_STRICT assert ((nlines >= 0) && (nlines <= TermWin.nrow)); @@ -1855,7 +1921,7 @@ rxvt_term::scr_page (enum page_dirn direction, int nlines) } int -rxvt_term::scr_changeview (uint16_t oldviewstart) +rxvt_term::scr_changeview (unsigned int oldviewstart) { if (TermWin.view_start != oldviewstart) { @@ -1962,7 +2028,6 @@ void rxvt_term::scr_refresh (unsigned char refresh_type) { unsigned char must_clear, /* use draw_string not draw_image_string */ - rvid, /* reverse video this position */ showcursor; /* show the cursor */ int16_t col, row, /* column/row we're processing */ ocrow; /* old cursor row */ @@ -1984,10 +2049,10 @@ rxvt_term::scr_refresh (unsigned char refresh_type) row_offset = TermWin.saveLines - TermWin.view_start; -#ifdef XPM_BACKGROUND +#if XPM_BACKGROUND must_clear |= (bgPixmap.pixmap != None); #endif -#ifdef TRANSPARENT +#if TRANSPARENT must_clear |= ((options & Opt_transparent) && am_transparent); #endif ocrow = oldcursor.row; /* is there an old outline cursor on screen? */ @@ -1996,9 +2061,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type) * B: reverse any characters which are selected */ scr_reverse_selection (); -#if ENABLE_OVERLAY - scr_swap_overlay (); -#endif /* * C: set the cursor character (s) @@ -2082,8 +2144,13 @@ rxvt_term::scr_refresh (unsigned char refresh_type) } } +#if ENABLE_OVERLAY + scr_swap_overlay (); +#endif + rend_t *drp, *srp; /* drawn-rend-pointer, screen-rend-pointer */ text_t *dtp, *stp; /* drawn-text-pointer, screen-text-pointer */ + #ifndef NO_SLOW_LINK_SUPPORT /* * D: CopyArea pass - very useful for slower links @@ -2170,7 +2237,7 @@ rxvt_term::scr_refresh (unsigned char refresh_type) { /* compare new text with old - if exactly the same then continue */ if (stp[col] == dtp[col] /* Must match characters to skip. */ - && (srp[col] == drp[col] /* Either rendition the same or */ + && (RS_SAME (srp[col], drp[col]) /* Either rendition the same or */ || (stp[col] == ' ' /* space w/ no background change */ && GET_BGATTR (srp[col]) == GET_BGATTR (drp[col])))) continue; @@ -2190,8 +2257,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type) int xpixel = Col2Pixel (col); - // this loop looks very messy, it can probably be optimized - // and cleaned a bit by you? for (i = 0; ++col < TermWin.ncol; ) { if (stp[col] == NOCHAR) @@ -2204,13 +2269,13 @@ rxvt_term::scr_refresh (unsigned char refresh_type) continue; } - if (rend != srp[col]) + if (!RS_SAME (rend, srp[col])) break; count++; if (stp[col] != dtp[col] - || srp[col] != drp[col]) + || !RS_SAME (srp[col], drp[col])) { if (must_clear && (i++ > count / 2)) break; @@ -2230,62 +2295,84 @@ rxvt_term::scr_refresh (unsigned char refresh_type) while (i && text[count] == NOCHAR) count++, i--; +#if ENABLE_STYLES + // force redraw after "careful" characters to avoid pixel droppings + if (srp[col] & RS_Careful && col < TermWin.ncol - 1 && 0) + drp[col + 1] = ~srp[col + 1]; + + // include previous careful character(s) if possible, looks nicer (best effort...) + while (text > stp + && srp[text - stp - 1] & RS_Careful + && RS_SAME (rend, srp[text - stp - 1])) + text--, count++, xpixel -= TermWin.fwidth; +#endif + /* * Determine the attributes for the string */ - int fid = GET_FONT (rend); int fore = GET_FGCOLOR (rend); // desired foreground int back = GET_BGCOLOR (rend); // desired background - rend = GET_ATTR (rend); - - rvid = !!(rend & RS_RVid); + // only do special processing if ana attributes are set, which is rare + if (rend & (RS_Bold | RS_Italic | RS_Uline | RS_RVid | RS_Blink)) + { + bool invert = rend & RS_RVid; #ifndef NO_BOLD_UNDERLINE_REVERSE - if (rend & RS_Bold && fore == Color_fg && !(options & Opt_realBold)) - { - if (ISSET_PIXCOLOR (Color_BD)) - fore = Color_BD; - else - rvid = !rvid; - } + if (rend & RS_Bold + && fore == Color_fg) + { + if (ISSET_PIXCOLOR (Color_BD)) + fore = Color_BD; +# if !ENABLE_STYLES + else + invert = !invert; +# endif + } + + if (rend & RS_Italic + && fore == Color_fg) + { + if (ISSET_PIXCOLOR (Color_IT)) + fore = Color_IT; +# if !ENABLE_STYLES + else + invert = !invert; +# endif + } - if (rend & RS_Uline) - if (ISSET_PIXCOLOR (Color_UL)) - fore = Color_UL; + if (rend & RS_Uline && ISSET_PIXCOLOR (Color_UL)) + fore = Color_UL; #endif - if (rvid) - { - SWAP_IT (fore, back, int); + if (invert) + { + SWAP_IT (fore, back, int); #ifndef NO_BOLD_UNDERLINE_REVERSE - if (ISSET_PIXCOLOR (Color_RV) -# ifndef NO_CURSORCOLOR - && !ISSET_PIXCOLOR (Color_cursor) -# endif - ) - back = Color_RV; + if (ISSET_PIXCOLOR (Color_RV)) + back = Color_RV; #endif - } + } #ifdef TEXT_BLINK - if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) - { - if (!text_blink_ev.active) + if (rend & RS_Blink && (back == Color_bg || fore == Color_bg)) { - text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); - hidden_text = 0; + if (!text_blink_ev.active) + { + text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); + hidden_text = 0; + } + else if (hidden_text) + fore = back; } - else if (hidden_text) - fore = back; - } #endif + } /* * Actually do the drawing of the string here */ - rxvt_font *font = (*TermWin.fontset)[fid]; + rxvt_font *font = (*TermWin.fontset[GET_STYLE (rend)])[GET_FONT (rend)]; if (back == fore) font->clear_rect (*TermWin.drawable, xpixel, ypixel, @@ -2317,6 +2404,10 @@ rxvt_term::scr_refresh (unsigned char refresh_type) } /* for (col....) */ } /* for (row....) */ +#if ENABLE_OVERLAY + scr_swap_overlay (); +#endif + /* * G: cleanup cursor and display outline cursor if necessary */ @@ -2351,9 +2442,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type) /* * H: cleanup selection */ -#if ENABLE_OVERLAY - scr_swap_overlay (); -#endif scr_reverse_selection (); if (refresh_type & SMOOTH_REFRESH) @@ -2371,7 +2459,7 @@ rxvt_term::scr_remap_chars (text_t *tp, rend_t *rp) return; for (int i = TermWin.ncol; i; i--, rp++, tp++) - *rp = SET_FONT (*rp, TermWin.fontset->find_font (*tp)); + *rp = SET_FONT (*rp, FONTSET (*rp)->find_font (*tp)); } void @@ -2387,6 +2475,36 @@ rxvt_term::scr_remap_chars () } } +void +rxvt_term::scr_recolour () +{ + if (1 +#if TRANSPARENT + && !am_transparent +#endif +#if XPM_BACKGROUND + && !bgPixmap.pixmap +#endif + ) + { + XSetWindowBackground (display->display, TermWin.parent[0], pix_colors[Color_border]); + XClearWindow (display->display, TermWin.parent[0]); + XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); +#if HAVE_SCROLLBARS + if (scrollBar.win) + { + XSetWindowBackground (display->display, scrollBar.win, pix_colors[Color_border]); + scrollBar.setIdle (); + scrollbar_show (0); + } +#endif + } + + scr_clear (); + scr_touch (true); + want_refresh = 1; +} + /* ------------------------------------------------------------------------- */ void rxvt_term::scr_clear (bool really) @@ -2397,12 +2515,12 @@ rxvt_term::scr_clear (bool really) num_scr_allow = 0; want_refresh = 1; -#ifdef TRANSPARENT +#if TRANSPARENT if ((options & Opt_transparent) && (am_pixmap_trans == 0)) { int i; - if (! (options & Opt_transparent_all)) + if (!(options & Opt_transparent_all)) i = 0; else i = (int) (sizeof (TermWin.parent) / sizeof (Window)); @@ -3509,7 +3627,7 @@ rxvt_term::scr_overlay_new (int x, int y, int w, int h) rend_t *rp = ov_rend[y] = new rend_t[w]; text_t t0, t1, t2; - rend_t r = SET_BGCOLOR (SET_FGCOLOR (RS_None, Color_bg), Color_fg); + rend_t r = OVERLAY_RSTYLE; if (y == 0) t0 = 0x2554, t1 = 0x2550, t2 = 0x2557; @@ -3553,7 +3671,7 @@ rxvt_term::scr_overlay_off () void rxvt_term::scr_overlay_set (int x, int y, text_t text, rend_t rend) { - if (!ov_text || x >= ov_w - 2 || y >= ov_h) + if (!ov_text || x >= ov_w - 2 || y >= ov_h - 2) return; x++, y++; @@ -3589,7 +3707,7 @@ rxvt_term::scr_swap_overlay () for (int x = ov_w; x--; ) { text_t t = *t1; *t1++ = *t2; *t2++ = t; - rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, TermWin.fontset->find_font (t, false)); + rend_t r = *r1; *r1++ = *r2; *r2++ = SET_FONT (r, FONTSET (r)->find_font (t)); } } } diff --git a/src/version.h b/src/version.h index 06343a4..80c809f 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,5 @@ -#define VERSION "3.7" -#define VSTRING "30700" -#define DATE "2004-08-17" -#define LSMDATE "17AUG04" -#define LIBVERSION "3:7:0" +#define VERSION "3.8" +#define VSTRING "30800" +#define DATE "2004-08-25" +#define LSMDATE "25AUG04" +#define LIBVERSION "3:8:0" -- 1.9.1