*** empty log message ***
authorroot <root>
Wed, 25 Aug 2004 03:47:20 +0000 (03:47 +0000)
committerroot <root>
Wed, 25 Aug 2004 03:47:20 +0000 (03:47 +0000)
doc/rxvt.7.pod
src/command.C
src/init.C
src/rxvt.h
src/rxvtlib.h.in
src/screen.C
src/version.h

index 266ed67..58bad11 100644 (file)
@@ -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<rxvt-unicode>. First the description of supported command sequences,
+followed by menu and pixmap support and last by a description of all
+features selectable at C<configure> time.
+
 =head1 RXVT TECHNICAL REFERENCE
 
 =head1 Definitions
 =head1 RXVT TECHNICAL REFERENCE
 
 =head1 Definitions
@@ -151,11 +173,11 @@ Invoke the G2 Character Set (LS2)
 
 Invoke the G3 Character Set (LS3)
 
 
 Invoke the G3 Character Set (LS3)
 
-=item B<< C<ESC>(C<C> >>
+=item B<< C<ESC> ( C> >>
 
 Designate G0 Character Set (ISO 2022), see below for values of C<C>.
 
 
 Designate G0 Character Set (ISO 2022), see below for values of C<C>.
 
-=item B<< C<ESC>)C<C> >>
+=item B<< C<ESC> ) C> >>
 
 Designate G1 Character Set (ISO 2022), see below for values of C<C>.
 
 
 Designate G1 Character Set (ISO 2022), see below for values of C<C>.
 
@@ -332,21 +354,22 @@ Tab Clear (TBC)
 
 =end table
 
 
 =end table
 
+=item B<< C<ESC [ Pm h> >>
+
+Set Mode (SM). See B<< C<ESC [ Pm l> >> sequence for description of C<Pm>.
+
 =item B<< C<ESC [ Ps i> >>
 
 =item B<< C<ESC [ Ps i> >>
 
-Printing
+Printing. See also the C<print-pipe> resource.
 
 =begin table
 
 
 =begin table
 
+       B<< C<Ps = 0> >>        print screen (MC0)
        B<< C<Ps = 4> >>        disable transparent print mode (MC4)
        B<< C<Ps = 4> >>        disable transparent print mode (MC4)
-       B<< C<Ps = 5> >>        enable transparent print mode (MC5) I<unimplemented>
+       B<< C<Ps = 5> >>        enable transparent print mode (MC5)
 
 =end table
 
 
 =end table
 
-=item B<< C<ESC [ Pm h> >>
-
-Set Mode (SM). See next sequence for description of C<Pm>.
-
 =item B<< C<ESC [ Pm l> >>
 
 Reset Mode (RM)
 =item B<< C<ESC [ Pm l> >>
 
 Reset Mode (RM)
@@ -381,12 +404,12 @@ Character Attributes (SGR)
 
        B<< C<Ps = 0> >>        Normal (default)
        B<< C<Ps = 1 / 21> >>   On / Off Bold (bright fg)
 
        B<< C<Ps = 0> >>        Normal (default)
        B<< C<Ps = 1 / 21> >>   On / Off Bold (bright fg)
-       B<< C<Ps = 3 / 23> >>   On / Off Italic (NYI)
+       B<< C<Ps = 3 / 23> >>   On / Off Italic
        B<< C<Ps = 4 / 24> >>   On / Off Underline
        B<< C<Ps = 5 / 25> >>   On / Off Slow Blink (bright bg)
        B<< C<Ps = 6 / 26> >>   On / Off Rapid Blink (bright bg)
        B<< C<Ps = 4 / 24> >>   On / Off Underline
        B<< C<Ps = 5 / 25> >>   On / Off Slow Blink (bright bg)
        B<< C<Ps = 6 / 26> >>   On / Off Rapid Blink (bright bg)
-       B<< C<Ps = 7 / 27> >>   On / Off Invisible (NYI)
-       B<< C<Ps = 8 / 27> >>   On / Off Inverse
+       B<< C<Ps = 7 / 27> >>   On / Off Inverse
+       B<< C<Ps = 8 / 27> >>   On / Off Invisible (NYI)
        B<< C<Ps = 30 / 40> >>  fg/bg Black
        B<< C<Ps = 31 / 41> >>  fg/bg Red
        B<< C<Ps = 32 / 42> >>  fg/bg Green
        B<< C<Ps = 30 / 40> >>  fg/bg Black
        B<< C<Ps = 31 / 41> >>  fg/bg Red
        B<< C<Ps = 32 / 42> >>  fg/bg Green
@@ -394,6 +417,7 @@ Character Attributes (SGR)
        B<< C<Ps = 34 / 44> >>  fg/bg Blue
        B<< C<Ps = 35 / 45> >>  fg/bg Magenta
        B<< C<Ps = 36 / 46> >>  fg/bg Cyan
        B<< C<Ps = 34 / 44> >>  fg/bg Blue
        B<< C<Ps = 35 / 45> >>  fg/bg Magenta
        B<< C<Ps = 36 / 46> >>  fg/bg Cyan
+       B<< C<Ps = 38;5 / 48;5> >>      set fg/bg to color #m (ISO 8613-6)
        B<< C<Ps = 37 / 47> >>  fg/bg White
        B<< C<Ps = 39 / 49> >>  fg/bg Default
        B<< C<Ps = 90 / 100> >> fg/bg Bright Black
        B<< C<Ps = 37 / 47> >>  fg/bg White
        B<< C<Ps = 39 / 49> >>  fg/bg Default
        B<< C<Ps = 90 / 100> >> fg/bg Bright Black
@@ -747,8 +771,13 @@ B<octet> can be escaped by prefixing it with SYN (0x16, ^V).
        B<< C<Ps = 50> >>       Set fontset to B<< C<Pt> >>, with the following special values of B<< C<Pt> >> (B<rxvt>) B<< C<#+n> >> change up B<< C<n> >> B<< C<#-n> >> change down B<< C<n> >> if B<< C<n> >> is missing of 0, a value of 1 is used I<empty> change to font0 B<< C<n> >> change to font B<< C<n> >>
        B<< C<Ps = 55> >>       Log all scrollback buffer and all of screen to B<< C<Pt> >>
        B<< C<Ps = 701> >>      Change current locale to B<< C<Pt> >>, or, if B<< C<Pt> >> is B<< C<?> >>, return the current locale (@@RXVT_NAME@@ extension)
        B<< C<Ps = 50> >>       Set fontset to B<< C<Pt> >>, with the following special values of B<< C<Pt> >> (B<rxvt>) B<< C<#+n> >> change up B<< C<n> >> B<< C<#-n> >> change down B<< C<n> >> if B<< C<n> >> is missing of 0, a value of 1 is used I<empty> change to font0 B<< C<n> >> change to font B<< C<n> >>
        B<< C<Ps = 55> >>       Log all scrollback buffer and all of screen to B<< C<Pt> >>
        B<< C<Ps = 701> >>      Change current locale to B<< C<Pt> >>, or, if B<< C<Pt> >> is B<< C<?> >>, return the current locale (@@RXVT_NAME@@ extension)
-       B<< C<Ps = 702> >>      find font for character, used for debugging (@@RXVT_NAME@@ extension)
-       B<< C<Ps = 703> >>      menubar command B<< C<Pt> >> I<rxvt compile-time option> (@@RXVT_NAME@@ extension)
+       B<< C<Ps = 703> >>      Menubar command B<< C<Pt> >> I<rxvt compile-time option> (rxvt-unicode extension)
+       B<< C<Ps = 704> >>      Change colour of italic characters to B<< C<Pt> >>
+       B<< C<Ps = 705> >>      Change background pixmap tint colour to B<< C<Pt> >>
+       B<< C<Ps = 710> >>      Set normal fontset to B<< C<Pt> >>. Same as C<Ps = 50>.
+       B<< C<Ps = 711> >>      Set bold fontset to B<< C<Pt> >>. Similar to C<Ps = 50>.
+       B<< C<Ps = 712> >>      Set italic fontset to B<< C<Pt> >>. Similar to C<Ps = 50>.
+       B<< C<Ps = 713> >>      Set bold-italic fontset to B<< C<Pt> >>. Similar to C<Ps = 50>.
 
 =end table
 
 
 =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.
 
 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<bold>, I<italic> and B<< I<bold italic> >> font
+styles. The fonts can be set manually or automatically.
+
 =item --with-codesets=NAME,...
 
 =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
 
 
 =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.
 
 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.
 =item --enable-cursor-blink
 
 Add support for a blinking cursor.
index 3cd5077..338e812 100644 (file)
@@ -135,7 +135,8 @@ rxvt_term::iso14755_54 (int x, int y)
 
       if (t != NOCHAR || !x)
         {
 
       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;
         }
           iso14755buf = ISO_14755_54;
           break;
         }
@@ -148,9 +149,11 @@ rxvt_term::iso14755_54 (int x, int y)
 
 #if ENABLE_OVERLAY
 void
 
 #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
   int len;
 
 #if ENABLE_COMBINING
@@ -163,12 +166,18 @@ rxvt_term::iso14755_51 (wchar_t ch)
   else
 #endif
     {
   else
 #endif
     {
+      ch2 = ch;
+
       alloc = 0;
       alloc = 0;
-      chr = &ch;
+      chr = &ch2;
       len = 1;
     }
 
       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++)
     {
 
   for (int y = 0; y < len; y++)
     {
@@ -183,10 +192,12 @@ rxvt_term::iso14755_51 (wchar_t ch)
       if (ch >= 0x10000)
         ch = 0xfffd;
 #endif
       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;
 #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 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);
   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);
           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));
   tt_printf ("\033[M%c%c%c",
             (32 + button_number + key_state),
             (32 + x + 1),
             (32 + y + 1));
-#endif
 }
 
 #ifdef USING_W11LIB
 }
 
 #ifdef USING_W11LIB
@@ -1229,7 +1239,7 @@ rxvt_term::x_cb (XEvent &ev)
 
       case KeyRelease:
         {
 
       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 :/
           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;
             if (rs[Rs_fade])
               {
                 pix_colors = pix_colors_focused;
-                set_colorfgbg ();
-                scr_clear ();
-                scr_touch (true);
+                scr_recolour ();
               }
 #endif
 
               }
 #endif
 
@@ -1404,6 +1412,13 @@ rxvt_term::x_cb (XEvent &ev)
           {
             TermWin.focus = 0;
             want_refresh = 1;
           {
             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);
 #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;
             if (rs[Rs_fade])
               {
                 pix_colors = pix_colors_unfocused;
-                set_colorfgbg ();
-                scr_clear ();
-                scr_touch (true);
+                scr_recolour ();
               }
 #endif
               }
 #endif
-
           }
         break;
 
           }
         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)
             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)
 
 #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;
     }
 
         TermWin.parent[i] = None;
     }
 
-  // this is experimental
   if (scrollBar.win)
     {
       XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
   if (scrollBar.win)
     {
       XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
-      XClearWindow (display->display, scrollBar.win);
       scrollBar.setIdle ();
       scrollbar_show (0);
     }
       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.
               // 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 */
             }
 
           /* 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)
 {
 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)
     {
   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;
         }
         {
           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 */
 
       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)
       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
       else
-        string[n++] = prev = ch;
+        string[n++] = ch;
     }
 
   string[n++] = '\0';
     }
 
   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 color;
   char *buf, *name;
   bool query = str[0] == '?' && !str[1];
+  int saveop = op;
 
   assert (str != NULL);
   switch (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_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;
       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
         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 != ';')
 
       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:
         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)
         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
                      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
         break;
 
 #if ENABLE_FRILLS
@@ -3790,16 +3836,6 @@ rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp)
 # endif
           }
         break;
 # 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
 #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 */
       switch (arg[i])
         {
           case 1048:           /* alternative cursor save */
+          case 1049:
             if (options & Opt_secondaryScreen)
               if (mode == 0)
                 scr_cursor (RESTORE);
             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 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;
           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 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;
             rendset = 0, rendstyle = RS_Bold;
             break;
-          case 22:
+          case 22: // normal intensity
             rendset = 0, rendstyle = RS_Bold;
             break;
             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 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:
             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;
           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;
             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;
           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;
           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;
             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 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 */
 #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:
           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 */
             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:
           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
 
             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)
 {
 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)
     {
 
   if (len)
     {
@@ -4268,7 +4305,7 @@ rxvt_term::tt_write (const unsigned char *data, unsigned int len)
 
   for (;;)
     {
 
   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)
         {
 
       if (written > 0)
         {
index d3ea2af..42e4033 100644 (file)
@@ -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) */
     "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: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,
 #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_border                   */
 #ifndef NO_BOLD_UNDERLINE_REVERSE
     NULL,                       /* Color_BD                       */
+    NULL,                       /* Color_IT                       */
     NULL,                       /* Color_UL                       */
     NULL,                       /* Color_RV                       */
 #endif                          /* ! NO_BOLD_UNDERLINE_REVERSE */
     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;
 
   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;
   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
     }
 
 #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
 #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 */
 
   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;
 }
 
   return cmd_argv;
 }
 
@@ -987,7 +819,6 @@ rxvt_term::color_aliases (int idx)
           rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i];
           return;
 #endif
           rs[Rs_color + idx] = rs[Rs_color + minBrightCOLOR + i];
           return;
 #endif
-
         }
 
       if (i >= 0 && i <= 7)   /* normal colors */
         }
 
       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 ();
 
   /* 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;
 
   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
   /* 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,
   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,
                                            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);
 #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
 
   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
                 | KeyReleaseMask
 #endif
                 | FocusChangeMask | VisibilityChangeMask
@@ -1182,8 +1009,8 @@ rxvt_term::create_windows (int argc, const char *const *argv)
 #if ENABLE_FRILLS
   if (mwmhints.flags)
     {
 #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
 
     }
 #endif
 
@@ -1215,8 +1042,8 @@ rxvt_term::create_windows (int argc, const char *const *argv)
                                    TermWin_TotalWidth (),
                                    TermWin_TotalHeight (),
                                    0,
                                    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
 #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,
                                          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");
 
 #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);
         }
           p++;
           scale_pixmap (p);
         }
+
       set_bgPixmap (rs[Rs_backgroundPixmap]);
       set_bgPixmap (rs[Rs_backgroundPixmap]);
-      scr_touch (True);
+      scr_touch (true);
     }
 #endif
 
     }
 #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
   if (rs[Rs_fade])
     pix_colors = pix_colors_unfocused;
 #endif
+
+  scr_recolour ();
 }
 
 /* ------------------------------------------------------------------------- *
 }
 
 /* ------------------------------------------------------------------------- *
index 6a7ff91..ef52f34 100644 (file)
@@ -125,7 +125,7 @@ struct grwin_t;
 /* If we're using either the rxvt scrollbar or menu bars, keep the
  * scrollColor resource.
  */
 /* 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
 # define KEEP_SCROLLCOLOR 1
 #else
 # undef KEEP_SCROLLCOLOR
@@ -185,7 +185,7 @@ typedef struct _mwmhints {
 # define COLORTERMENVFULL COLORTERMENV
 #endif
 #ifndef TERMENV
 # define COLORTERMENVFULL COLORTERMENV
 #endif
 #ifndef TERMENV
-# define TERMENV        "rxvt"
+# define TERMENV        "rxvt-unicode"
 #endif
 
 #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR)
 #endif
 
 #if defined (NO_MOUSE_REPORT) && !defined (NO_MOUSE_REPORT_SCROLLBAR)
@@ -352,20 +352,36 @@ enum {
 
 #define RS_None                 0               /* Normal */
 
 
 #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 */
 
 #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_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_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 */
 };
 
 /* Words starting with `Color_' are colours.  Others are counts */
@@ -461,10 +483,8 @@ enum colour_list {
 #else
   Color_White = maxCOLOR,
 #endif
 #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,
 #ifndef NO_CURSORCOLOR
   Color_cursor,
   Color_cursor2,
@@ -474,6 +494,7 @@ enum colour_list {
   Color_border,
 #ifndef NO_BOLD_UNDERLINE_REVERSE
   Color_BD,
   Color_border,
 #ifndef NO_BOLD_UNDERLINE_REVERSE
   Color_BD,
+  Color_IT,
   Color_UL,
   Color_RV,
 #endif
   Color_UL,
   Color_RV,
 #endif
@@ -491,18 +512,17 @@ enum colour_list {
 #ifdef KEEP_SCROLLCOLOR
   Color_topShadow = NRS_COLORS,
   Color_bottomShadow,
 #ifdef KEEP_SCROLLCOLOR
   Color_topShadow = NRS_COLORS,
   Color_bottomShadow,
-  TOTAL_COLORS                /* upto 30 */
+  TOTAL_COLORS
 #else
 #else
-  TOTAL_COLORS = NRS_COLORS   /* */
+  TOTAL_COLORS = NRS_COLORS
 #endif
 };
 
 #endif
 };
 
-#define Color_Bits      9
+#define Color_Bits      7 // 0 .. maxTermCOLOR
+
 #define NPIXCLR_SETS    ((TOTAL_COLORS + 31) / 32)
 #define NPIXCLR_BITS    32
 
 #define NPIXCLR_SETS    ((TOTAL_COLORS + 31) / 32)
 #define NPIXCLR_BITS    32
 
-#define DEFAULT_RSTYLE  (RS_None | (Color_fg) | (Color_bg<<Color_Bits))
-
 /*
  * Resource list
  */
 /*
  * Resource list
  */
@@ -515,6 +535,11 @@ enum {
   Rs_color,
   _Rs_color = Rs_color + NRS_COLORS - 1,
   Rs_font,
   Rs_color,
   _Rs_color = Rs_color + NRS_COLORS - 1,
   Rs_font,
+#if ENABLE_STYLES
+  Rs_boldFont,
+  Rs_italicFont,
+  Rs_boldItalicFont,
+#endif
   Rs_name,
   Rs_title,
 #if defined (XPM_BACKGROUND) || (MENUBAR_MAX)
   Rs_name,
   Rs_title,
 #if defined (XPM_BACKGROUND) || (MENUBAR_MAX)
@@ -590,9 +615,6 @@ enum {
   Rs_secondaryScreen,
   Rs_secondaryScroll,
 #endif
   Rs_secondaryScreen,
   Rs_secondaryScroll,
 #endif
-#ifndef NO_BOLD_UNDERLINE_REVERSE
-  Rs_realBold,
-#endif
 #ifdef OFF_FOCUS_FADING
   Rs_fade,
 #endif
 #ifdef OFF_FOCUS_FADING
   Rs_fade,
 #endif
@@ -756,20 +778,31 @@ enum {
 #endif
 
 #define GET_FONT(x)             (((x) & RS_fontMask) >> RS_fontShift)
 #endif
 
 #define GET_FONT(x)             (((x) & RS_fontMask) >> 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)<<Color_Bits))              \
                      : ((x) & (RS_attrMask | RS_bgMask)))
 
 #define GET_ATTR(x)             (((x) & RS_attrMask))
 #define GET_BGATTR(x)                                                   \
     (((x) & RS_RVid) ? (((x) & (RS_attrMask & ~RS_RVid))                \
                         | (((x) & RS_fgMask)<<Color_Bits))              \
                      : ((x) & (RS_attrMask | RS_bgMask)))
-#define SET_FGCOLOR(x,fg)       (((x) & ~RS_fgMask)  | (fg))
-#define SET_BGCOLOR(x,bg)       (((x) & ~RS_bgMask)  | ((bg)<<Color_Bits))
-#define SET_ATTR(x,a)           (((x) & ~RS_attrMask)| (a))
+#define SET_FGCOLOR(x,fg)       (((x) & ~RS_fgMask)   | (fg))
+#define SET_BGCOLOR(x,bg)       (((x) & ~RS_bgMask)   | ((bg)<<Color_Bits))
+#define SET_ATTR(x,a)           (((x) & ~RS_attrMask) | (a))
+
+#define RS_SAME(a,b)           (!(((a) ^ (b)) & ~RS_Careful))
 
 #define SET_PIXCOLOR(x)         (pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS)))
 #define ISSET_PIXCOLOR(x)       (pixcolor_set[(x) / NPIXCLR_BITS] &  (1 << ((x) % NPIXCLR_BITS)))
 
 
 #define SET_PIXCOLOR(x)         (pixcolor_set[(x) / NPIXCLR_BITS] |= (1 << ((x) % NPIXCLR_BITS)))
 #define ISSET_PIXCOLOR(x)       (pixcolor_set[(x) / NPIXCLR_BITS] &  (1 << ((x) % NPIXCLR_BITS)))
 
+#if ENABLE_STYLES
+# define FONTSET(style) TermWin.fontset[GET_STYLE (style)]
+#else
+# define FONTSET(style) TermWin.fontset[0]
+#endif
+
 #ifdef HAVE_SCROLLBARS
 # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2)
 #else
 #ifdef HAVE_SCROLLBARS
 # define scrollbar_TotalWidth() (scrollBar.width + sb_shadow * 2)
 #else
@@ -944,7 +977,7 @@ extern class rxvt_composite_vec rxvt_composite;
 #endif
 
 
 #endif
 
 
-struct rxvt_term : rxvt_vars {
+struct rxvt_term : zero_initialized, rxvt_vars {
   log_callback *log_hook;               // log error messages through this hook, if != 0
 
   struct mbstate  mbstate;              // current input multibyte state
   log_callback *log_hook;               // log error messages through this hook, if != 0
 
   struct mbstate  mbstate;              // current input multibyte state
@@ -972,6 +1005,7 @@ struct rxvt_term : rxvt_vars {
 #endif
 //                  enc_utf8:1,                /* wether terminal reads/writes utf-8 */
                   seen_input:1,         /* wether we have seen some program output yet */
 #endif
 //                  enc_utf8:1,                /* wether terminal reads/writes utf-8 */
                   seen_input:1,         /* wether we have seen some program output yet */
+                  seen_resize:1,       /* wether we had a resize event */
                   parsed_geometry:1;
 
   unsigned char   refresh_type,
                   parsed_geometry:1;
 
   unsigned char   refresh_type,
@@ -1027,9 +1061,6 @@ struct rxvt_term : rxvt_vars {
 /* ---------- */
   unsigned int    ModMetaMask,
                   ModNumLockMask,
 /* ---------- */
   unsigned int    ModMetaMask,
                   ModNumLockMask,
-#ifndef NO_BRIGHTCOLOR
-                  colorfgbg,
-#endif
                   old_width,  /* last used width in screen resize          */
                   old_height; /* last used height in screen resize         */
   unsigned long   priv_modes,
                   old_width,  /* last used width in screen resize          */
                   old_height; /* last used height in screen resize         */
   unsigned long   priv_modes,
@@ -1130,7 +1161,7 @@ struct rxvt_term : rxvt_vars {
   void scr_overlay_off ();
   void scr_overlay_set (int x, int y,
                         text_t text,
   void scr_overlay_off ();
   void scr_overlay_set (int x, int y,
                         text_t text,
-                        rend_t rend = SET_BGCOLOR (SET_FGCOLOR (RS_None, Color_bg), Color_fg));
+                        rend_t rend = OVERLAY_RSTYLE);
   void scr_overlay_set (int x, int y, const char *s);
 #endif
 
   void scr_overlay_set (int x, int y, const char *s);
 #endif
 
@@ -1167,7 +1198,7 @@ struct rxvt_term : rxvt_vars {
   void commit_iso14755 ();
   int hex_keyval (XKeyEvent &ev);
 # if ISO_14755
   void commit_iso14755 ();
   int hex_keyval (XKeyEvent &ev);
 # if ISO_14755
-  void iso14755_51 (wchar_t ch);
+  void iso14755_51 (unicode_t ch, rend_t r = DEFAULT_RSTYLE);
   void iso14755_54 (int x, int y);
 # endif
 #endif
   void iso14755_54 (int x, int y);
 # endif
 #endif
@@ -1236,9 +1267,6 @@ struct rxvt_term : rxvt_vars {
 
   bool pty_fill ();
 
 
   bool pty_fill ();
 
-  void *operator new (size_t s);
-  void operator delete (void *p, size_t s);
-
   void init_secondary ();
   const char **init_resources (int argc, const char *const *argv);
   void init_env ();
   void init_secondary ();
   const char **init_resources (int argc, const char *const *argv);
   void init_env ();
@@ -1320,8 +1348,7 @@ struct rxvt_term : rxvt_vars {
   void cleanutent ();
   // main.C
   void privileged_utmp (rxvt_privaction action);
   void cleanutent ();
   // main.C
   void privileged_utmp (rxvt_privaction action);
-  bool change_font (const char *fontname);
-  bool font_up_down (int n, int direction);
+  bool set_fonts ();
   void set_title (const char *str);
   void set_icon_name (const char *str);
   void set_window_color (int idx, const char *color);
   void set_title (const char *str);
   void set_icon_name (const char *str);
   void set_window_color (int idx, const char *color);
@@ -1375,6 +1402,8 @@ struct rxvt_term : rxvt_vars {
   void scr_erase_screen (int mode);
   void scr_touch (bool refresh);
   void scr_expose (int x, int y, int width, int height, bool refresh);
   void scr_erase_screen (int mode);
   void scr_touch (bool refresh);
   void scr_expose (int x, int y, int width, int height, bool refresh);
+  rxvt_fontset *scr_find_fontset (rend_t r = DEFAULT_RSTYLE);
+  void scr_recolour ();
   void scr_remap_chars ();
   void scr_remap_chars (text_t *tp, rend_t *rp);
 
   void scr_remap_chars ();
   void scr_remap_chars (text_t *tp, rend_t *rp);
 
@@ -1386,7 +1415,7 @@ struct rxvt_term : rxvt_vars {
   void scr_rendition (int set, int style);
   void scr_add_lines (const unicode_t *str, int nlines, int len);
   void scr_backspace ();
   void scr_rendition (int set, int style);
   void scr_add_lines (const unicode_t *str, int nlines, int len);
   void scr_backspace ();
-  void scr_tab (int count);
+  void scr_tab (int count, bool ht = false);
   void scr_backindex ();
   void scr_forwardindex ();
   void scr_gotorc (int row, int col, int relative);
   void scr_backindex ();
   void scr_forwardindex ();
   void scr_gotorc (int row, int col, int relative);
@@ -1408,7 +1437,7 @@ struct rxvt_term : rxvt_vars {
   void scr_charset_set (int set, unsigned int ch);
   int scr_move_to (int y, int len);
   int scr_page (enum page_dirn direction, int nlines);
   void scr_charset_set (int set, unsigned int ch);
   int scr_move_to (int y, int len);
   int scr_page (enum page_dirn direction, int nlines);
-  int scr_changeview (uint16_t oldviewstart);
+  int scr_changeview (unsigned int oldviewstart);
   void scr_bell ();
   void scr_printscreen (int fullhist);
   void scr_reverse_selection ();
   void scr_bell ();
   void scr_printscreen (int fullhist);
   void scr_reverse_selection ();
index 43320c3..f96f396 100644 (file)
@@ -86,29 +86,28 @@ typedef uint32_t rend_t;
  */
 
 typedef struct {
  */
 
 typedef struct {
-  uint16_t       width;         /* window width                    [pixels] */
-  uint16_t       height;        /* window height                   [pixels] */
-  uint16_t       fwidth;        /* font width                      [pixels] */
-  uint16_t       fheight;       /* font height                     [pixels] */
-  uint16_t       fbase;         /* font ascent (baseline)          [pixels] */
-  uint16_t       propfont;      /* font proportional flags                  */
-  uint16_t       ncol;          /* window columns              [characters] */
-  uint16_t       nrow;          /* window rows                 [characters] */
-  uint16_t       focus;         /* window has focus                         */
-  uint16_t       mapped;        /* window state mapped?                     */
-  uint16_t       int_bwidth;    /* internal border width                    */
-  uint16_t       ext_bwidth;    /* external border width                    */
-  uint16_t       lineSpace;     /* number of extra pixels between rows      */
-  uint16_t       saveLines;     /* number of lines that fit in scrollback   */
-  uint16_t       nscrolled;     /* number of line actually scrolled         */
-  uint16_t       view_start;    /* scrollback view starts here              */
+  unsigned int   width;         /* window width                    [pixels] */
+  unsigned int   height;        /* window height                   [pixels] */
+  unsigned int   fwidth;        /* font width                      [pixels] */
+  unsigned int   fheight;       /* font height                     [pixels] */
+  unsigned int   fweight, fslant;
+  unsigned int   fbase;         /* font ascent (baseline)          [pixels] */
+  unsigned int   ncol;          /* window columns              [characters] */
+  unsigned int   nrow;          /* window rows                 [characters] */
+  unsigned int   focus;         /* window has focus                         */
+  unsigned int   mapped;        /* window state mapped?                     */
+  unsigned int   int_bwidth;    /* internal border width                    */
+  unsigned int   ext_bwidth;    /* external border width                    */
+  unsigned int   lineSpace;     /* number of extra pixels between rows      */
+  unsigned int   saveLines;     /* number of lines that fit in scrollback   */
+  unsigned int   nscrolled;     /* number of line actually scrolled         */
+  unsigned int   view_start;    /* scrollback view starts here              */
   Window         parent[6];     /* parent identifiers - we're parent[0]     */
   Window         vt;            /* vt100 window                             */
   GC             gc;            /* GC for drawing                           */
   Pixmap         pixmap;
   Window         parent[6];     /* parent identifiers - we're parent[0]     */
   Window         vt;            /* vt100 window                             */
   GC             gc;            /* GC for drawing                           */
   Pixmap         pixmap;
-  rxvt_fontset  *fontset;
   rxvt_drawable *drawable;
   rxvt_drawable *drawable;
-  uint16_t       ascii_map[0x7f - 0x20]; // map ascii chars to fonts for speed
+  rxvt_fontset  *fontset[4];
 } TermWin_t;
 
 /*
 } TermWin_t;
 
 /*
@@ -145,12 +144,12 @@ typedef struct {
   text_t        **text; /* _all_ the text                            */
   rend_t        **rend; /* rendition, uses RS_ flags                 */
   row_col_t       cur;  /* cursor position on the screen             */
   text_t        **text; /* _all_ the text                            */
   rend_t        **rend; /* rendition, uses RS_ flags                 */
   row_col_t       cur;  /* cursor position on the screen             */
-  uint16_t        tscroll;      /* top of settable scroll region             */
-  uint16_t        bscroll;      /* bottom of settable scroll region          */
-  uint16_t        charset;      /* character set number [0..3]               */
+  unsigned int    tscroll;      /* top of settable scroll region             */
+  unsigned int    bscroll;      /* bottom of settable scroll region          */
+  unsigned int    charset;      /* character set number [0..3]               */
   unsigned int    flags;        /* see below                                 */
   row_col_t       s_cur;        /* saved cursor position                     */
   unsigned int    flags;        /* see below                                 */
   row_col_t       s_cur;        /* saved cursor position                     */
-  uint16_t        s_charset;    /* saved character set number [0..3]         */
+  unsigned int    s_charset;    /* saved character set number [0..3]         */
   char            s_charset_char;
   rend_t          s_rstyle;     /* saved rendition style                     */
 } screen_t;
   char            s_charset_char;
   rend_t          s_rstyle;     /* saved rendition style                     */
 } screen_t;
@@ -165,9 +164,9 @@ enum selection_op_t {
 
 typedef struct {
   wchar_t        *text;       /* selected text                             */
 
 typedef struct {
   wchar_t        *text;       /* selected text                             */
-  uint32_t        len;        /* length of selected text                   */
-  short           screen;     /* screen being used                         */
-  short           clicks;     /* number of clicks                          */
+  unsigned int    len;        /* length of selected text                   */
+  unsigned int    screen;     /* screen being used                         */
+  unsigned int    clicks;     /* number of clicks                          */
   selection_op_t  op;         /* current operation                         */
   row_col_t       beg;        /* beginning of selection   <= mark          */
   row_col_t       mark;       /* point of initial click   <= end           */
   selection_op_t  op;         /* current operation                         */
   row_col_t       beg;        /* beginning of selection   <= mark          */
   row_col_t       mark;       /* point of initial click   <= end           */
@@ -200,18 +199,17 @@ typedef struct {
 #define Opt_scrollTtyKeypress   (1UL<<12)
 #define Opt_transparent         (1UL<<13)
 #define Opt_transparent_all     (1UL<<14)
 #define Opt_scrollTtyKeypress   (1UL<<12)
 #define Opt_transparent         (1UL<<13)
 #define Opt_transparent_all     (1UL<<14)
-#define Opt_realBold            (1UL<<15)
-#define Opt_tripleclickwords    (1UL<<16)
-#define Opt_scrollWithBuffer    (1UL<<17)
-#define Opt_jumpScroll          (1UL<<18)
-#define Opt_mouseWheelScrollPage (1UL<<19)
-#define Opt_pointerBlank        (1UL<<20)
-#define Opt_cursorBlink         (1UL<<21)
-#define Opt_secondaryScreen    (1UL<<22)
-#define Opt_secondaryScroll    (1UL<<23)
+#define Opt_tripleclickwords    (1UL<<15)
+#define Opt_scrollWithBuffer    (1UL<<16)
+#define Opt_jumpScroll          (1UL<<17)
+#define Opt_mouseWheelScrollPage (1UL<<18)
+#define Opt_pointerBlank        (1UL<<19)
+#define Opt_cursorBlink         (1UL<<20)
+#define Opt_secondaryScreen    (1UL<<21)
+#define Opt_secondaryScroll    (1UL<<22)
 #if ENABLE_FRILLS
 #if ENABLE_FRILLS
-# define Opt_insecure          (1UL<<24) // insecure esc sequences
-# define Opt_borderLess                (1UL<<25) // mem borderless hints
+# define Opt_insecure          (1UL<<23) // insecure esc sequences
+# define Opt_borderLess                (1UL<<24) // mem borderless hints
 #else
 # define Opt_insecure          0
 # define Opt_borderLess                0
 #else
 # define Opt_insecure          0
 # define Opt_borderLess                0
@@ -234,12 +232,12 @@ typedef struct {
 typedef struct {
   char            state;        /* scrollbar state                          */
   char            init;         /* scrollbar has been initialised           */
 typedef struct {
   char            state;        /* scrollbar state                          */
   char            init;         /* scrollbar has been initialised           */
-  short           beg;          /* slider sub-window begin height           */
-  short           end;          /* slider sub-window end height             */
-  short           top;          /* slider top position                      */
-  short           bot;          /* slider bottom position                   */
-  short           style;        /* style: rxvt, xterm, next                 */
-  short           width;        /* scrollbar width                          */
+  unsigned int    beg;          /* slider sub-window begin height           */
+  unsigned int    end;          /* slider sub-window end height             */
+  unsigned int    top;          /* slider top position                      */
+  unsigned int    bot;          /* slider bottom position                   */
+  unsigned int    style;        /* style: rxvt, xterm, next                 */
+  unsigned int    width;        /* scrollbar width                          */
   Window          win;
   int             (rxvt_term::*update)(int, int, int, int);
 
   Window          win;
   int             (rxvt_term::*update)(int, int, int, int);
 
index db93054..0d944a5 100644 (file)
@@ -25,7 +25,6 @@
  */
 
 #include "../config.h"          /* NECESSARY */
  */
 
 #include "../config.h"          /* NECESSARY */
-#define INTERN_SCREEN
 #include "rxvt.h"               /* NECESSARY */
 
 #include <X11/Xmd.h>            /* get the typedef for CARD32 */
 #include "rxvt.h"               /* NECESSARY */
 
 #include <X11/Xmd.h>            /* get the typedef for CARD32 */
@@ -114,12 +113,13 @@ inline void fill_text (text_t *start, text_t value, int len)
 /* ------------------------------------------------------------------------- *
  *                        SCREEN `COMMON' ROUTINES                           *
  * ------------------------------------------------------------------------- */
 /* ------------------------------------------------------------------------- *
  *                        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;
 /* 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--)
     {
 
   while (width--)
     {
@@ -419,7 +419,7 @@ rxvt_term::scr_reset ()
 void
 rxvt_term::scr_reset_realloc ()
 {
 void
 rxvt_term::scr_reset_realloc ()
 {
-  uint16_t total_rows, nrow;
+  unsigned int total_rows, nrow;
 
   nrow = TermWin.nrow;
   total_rows = nrow + TermWin.saveLines;
 
   nrow = TermWin.nrow;
   total_rows = nrow + TermWin.saveLines;
@@ -446,7 +446,7 @@ rxvt_term::scr_reset_realloc ()
 void
 rxvt_term::scr_release ()
 {
 void
 rxvt_term::scr_release ()
 {
-  uint16_t total_rows;
+  unsigned int total_rows;
   int i;
 
   total_rows = TermWin.nrow + TermWin.saveLines;
   int i;
 
   total_rows = TermWin.nrow + TermWin.saveLines;
@@ -513,21 +513,21 @@ rxvt_term::scr_cursor (int mode)
   switch (mode)
     {
       case SAVE:
   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_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;
         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;
         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;
     }
         set_font_style ();
         break;
     }
@@ -627,7 +627,9 @@ rxvt_term::scr_do_wrap ()
 void
 rxvt_term::scr_color (unsigned int color, int fgbg)
 {
 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
   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
       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
 
       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:
         switch (c)
           {
             case C0_HT:
-              scr_tab (1);
+              scr_tab (1, true);
               continue;
 
             case C0_LF:
               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
       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)
         {
               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)
 #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
             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
             {
 
           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)
 
           // 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);
 
           // 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;
             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
         }
     }
 #endif
         }
     }
@@ -1030,7 +1065,7 @@ rxvt_term::scr_backspace ()
  * XTERM_SEQ: CTRL-I
  */
 void
  * XTERM_SEQ: CTRL-I
  */
 void
-rxvt_term::scr_tab (int count)
+rxvt_term::scr_tab (int count, bool ht)
 {
   int i, x;
 
 {
   int i, x;
 
@@ -1041,6 +1076,12 @@ rxvt_term::scr_tab (int count)
     return;
   else if (count > 0)
     {
     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])
           {
       for (; ++i < TermWin.ncol; )
         if (tabs[i])
           {
@@ -1048,9 +1089,33 @@ rxvt_term::scr_tab (int count)
             if (!--count)
               break;
           }
             if (!--count)
               break;
           }
+        else 
+          ht &= tp[i] == ' '
+                && RS_SAME (rp[i], base_rend);
 
       if (count)
         x = TermWin.ncol - 1;
 
       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) */
     {
     }
   else /* if (count < 0) */
     {
@@ -1351,7 +1416,7 @@ rxvt_term::scr_E ()
   num_scr_allow = 0;
   selection_check (3);
 
   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 */
   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;
     screen.flags |= Screen_Relative;
   else
     screen.flags &= ~Screen_Relative;
+
   scr_gotorc (0, 0, 0);
 }
 
   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);
     {
       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 (bgPixmap.pixmap == None)
 #endif
-#if defined(TRANSPARENT)
+#if TRANSPARENT
         if (! (options & Opt_transparent) || am_transparent == 0)
 #endif
           XSetWindowBackground (display->display, TermWin.vt,
         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;
 rxvt_term::scr_move_to (int y, int len)
 {
   long p = 0;
-  uint16_t oldviewstart;
+  unsigned int oldviewstart;
 
   oldviewstart = TermWin.view_start;
 
 
   oldviewstart = TermWin.view_start;
 
@@ -1821,7 +1887,7 @@ rxvt_term::scr_move_to (int y, int len)
       p = max (p, 0);
     }
 
       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);
 }
 
   return scr_changeview (oldviewstart);
 }
@@ -1835,7 +1901,7 @@ int
 rxvt_term::scr_page (enum page_dirn direction, int nlines)
 {
   int n;
 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));
 
 #ifdef DEBUG_STRICT
   assert ((nlines >= 0) && (nlines <= TermWin.nrow));
@@ -1855,7 +1921,7 @@ rxvt_term::scr_page (enum page_dirn direction, int nlines)
 }
 
 int
 }
 
 int
-rxvt_term::scr_changeview (uint16_t oldviewstart)
+rxvt_term::scr_changeview (unsigned int oldviewstart)
 {
   if (TermWin.view_start != 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     */
 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                            */
                 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;
 
 
   row_offset = TermWin.saveLines - TermWin.view_start;
 
-#ifdef XPM_BACKGROUND
+#if XPM_BACKGROUND
   must_clear |= (bgPixmap.pixmap != None);
 #endif
   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? */
   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 ();
    * B: reverse any characters which are selected
    */
   scr_reverse_selection ();
-#if ENABLE_OVERLAY
-  scr_swap_overlay ();
-#endif
 
   /*
    * C: set the cursor character (s)
 
   /*
    * 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   */
   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
 #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. */
         {
           /* 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;
                   || (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);
 
 
           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)
           for (i = 0; ++col < TermWin.ncol; )
             {
               if (stp[col] == NOCHAR)
@@ -2204,13 +2269,13 @@ rxvt_term::scr_refresh (unsigned char refresh_type)
                   continue;
                 }
 
                   continue;
                 }
 
-              if (rend != srp[col])
+              if (!RS_SAME (rend, srp[col]))
                 break;
 
               count++;
 
               if (stp[col] != dtp[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;
                 {
                   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--;
 
           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
            */
           /*
            * 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
 
           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
 
 #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
 
 #endif
 
-          if (rvid)
-            {
-              SWAP_IT (fore, back, int);
+              if (invert)
+                {
+                  SWAP_IT (fore, back, int);
 
 #ifndef NO_BOLD_UNDERLINE_REVERSE
 
 #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
 #endif
-            }
+                }
 
 #ifdef TEXT_BLINK
 
 #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
 #endif
+            }
 
           /*
            * Actually do the drawing of the string here
            */
 
           /*
            * 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,
 
           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....) */
 
         }                     /* for (col....) */
     }                         /* for (row....) */
 
+#if ENABLE_OVERLAY
+  scr_swap_overlay ();
+#endif
+
   /*
    * G: cleanup cursor and display outline cursor if necessary
    */
   /*
    * G: cleanup cursor and display outline cursor if necessary
    */
@@ -2351,9 +2442,6 @@ rxvt_term::scr_refresh (unsigned char refresh_type)
   /*
    * H: cleanup selection
    */
   /*
    * H: cleanup selection
    */
-#if ENABLE_OVERLAY
-  scr_swap_overlay ();
-#endif
   scr_reverse_selection ();
 
   if (refresh_type & SMOOTH_REFRESH)
   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++)
     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
 }
 
 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)
 /* ------------------------------------------------------------------------- */
 void
 rxvt_term::scr_clear (bool really)
@@ -2397,12 +2515,12 @@ rxvt_term::scr_clear (bool really)
   num_scr_allow = 0;
   want_refresh = 1;
 
   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) && (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));
         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 *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;
 
       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)
 {
 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++;
     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;
       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));
         }
     }
 }
         }
     }
 }
index 06343a4..80c809f 100644 (file)
@@ -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"