emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108544: Add support for italic text


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108544: Add support for italic text on ttys.
Date: Sun, 10 Jun 2012 00:44:44 +0800
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108544
fixes bug: http://debbugs.gnu.org/9652
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-06-10 00:44:44 +0800
message:
  Add support for italic text on ttys.
  
  * src/dispextern.h: Replace unused TTY_CAP_BLINK with TTY_CAP_ITALIC.
  (struct face): Remove unused fields tty_dim_p, tty_blinking_p, and
  tty_alt_charset_p.  Add tty_italic_p.
  
  * src/term.c: Support italics in capable terminals.
  (no_color_bit): Replace unused NC_BLINK with NC_ITALIC.
  (turn_on_face): Output using TS_enter_italic_mode if available.
  Don't handle unused blinking and alt-charset cases.
  (turn_off_face): Handle italic case; discard unused tty_blinking_p
  and tty_alt_charset_p cases.
  (tty_capable_p, init_tty): Support italics.
  
  * src/termchar.h (struct tty_display_info): Add field for italics.
  Remove unused blink field.
  
  * src/xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
  Handle slant.
modified:
  src/ChangeLog
  src/dispextern.h
  src/term.c
  src/termchar.h
  src/xfaces.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-06-09 11:13:30 +0000
+++ b/src/ChangeLog     2012-06-09 16:44:44 +0000
@@ -1,3 +1,23 @@
+2012-06-09  Chong Yidong  <address@hidden>
+
+       * term.c: Support italics in capable terminals (Bug#9652).
+       (no_color_bit): Replace unused NC_BLINK with NC_ITALIC.
+       (turn_on_face): Output using TS_enter_italic_mode if available.
+       Don't handle unused blinking and alt-charset cases.
+       (turn_off_face): Handle italic case; discard unused tty_blinking_p
+       and tty_alt_charset_p cases.
+       (tty_capable_p, init_tty): Support italics.
+
+       * termchar.h (struct tty_display_info): Add field for italics.
+       Remove unused blink field.
+
+       * xfaces.c (tty_supports_face_attributes_p, realize_tty_face):
+       Handle slant.
+
+       * dispextern.h: Replace unused TTY_CAP_BLINK with TTY_CAP_ITALIC.
+       (struct face): Remove unused fields tty_dim_p, tty_blinking_p, and
+       tty_alt_charset_p.  Add tty_italic_p.
+
 2012-06-09  Michael Albinus  <address@hidden>
 
        * dbusbind.c (XD_BASIC_DBUS_TYPE): Use dbus_type_is_valid and

=== modified file 'src/dispextern.h'
--- a/src/dispextern.h  2012-05-25 18:19:24 +0000
+++ b/src/dispextern.h  2012-06-09 16:44:44 +0000
@@ -1609,15 +1609,12 @@
   unsigned strike_through_color_defaulted_p : 1;
   unsigned box_color_defaulted_p : 1;
 
-  /* TTY appearances.  Blinking is not yet implemented.  Colors are
-     found in `lface' with empty color string meaning the default
-     color of the TTY.  */
+  /* TTY appearances.  Colors are found in `lface' with empty color
+     string meaning the default color of the TTY.  */
   unsigned tty_bold_p : 1;
-  unsigned tty_dim_p : 1;
+  unsigned tty_italic_p : 1;
   unsigned tty_underline_p : 1;
-  unsigned tty_alt_charset_p : 1;
   unsigned tty_reverse_p : 1;
-  unsigned tty_blinking_p : 1;
 
   /* 1 means that colors of this face may not be freed because they
      have been copied bitwise from a base face (see
@@ -2979,8 +2976,7 @@
 #define TTY_CAP_UNDERLINE      0x02
 #define TTY_CAP_BOLD           0x04
 #define TTY_CAP_DIM            0x08
-#define TTY_CAP_BLINK          0x10
-#define TTY_CAP_ALT_CHARSET    0x20
+#define TTY_CAP_ITALIC         0x10
 
 
 /***********************************************************************

=== modified file 'src/term.c'
--- a/src/term.c        2012-05-25 18:19:24 +0000
+++ b/src/term.c        2012-06-09 16:44:44 +0000
@@ -122,12 +122,11 @@
   NC_STANDOUT   = 1 << 0,
   NC_UNDERLINE  = 1 << 1,
   NC_REVERSE    = 1 << 2,
-  NC_BLINK      = 1 << 3,
+  NC_ITALIC     = 1 << 3,
   NC_DIM        = 1 << 4,
   NC_BOLD       = 1 << 5,
   NC_INVIS      = 1 << 6,
-  NC_PROTECT    = 1 << 7,
-  NC_ALT_CHARSET = 1 << 8
+  NC_PROTECT    = 1 << 7
 };
 
 /* internal state */
@@ -2022,17 +2021,16 @@
   if (face->tty_bold_p && MAY_USE_WITH_COLORS_P (tty, NC_BOLD))
     OUTPUT1_IF (tty, tty->TS_enter_bold_mode);
 
-  if (face->tty_dim_p && MAY_USE_WITH_COLORS_P (tty, NC_DIM))
-    OUTPUT1_IF (tty, tty->TS_enter_dim_mode);
-
-  /* Alternate charset and blinking not yet used.  */
-  if (face->tty_alt_charset_p
-      && MAY_USE_WITH_COLORS_P (tty, NC_ALT_CHARSET))
-    OUTPUT1_IF (tty, tty->TS_enter_alt_charset_mode);
-
-  if (face->tty_blinking_p
-      && MAY_USE_WITH_COLORS_P (tty, NC_BLINK))
-    OUTPUT1_IF (tty, tty->TS_enter_blink_mode);
+  if (face->tty_italic_p && MAY_USE_WITH_COLORS_P (tty, NC_ITALIC))
+    {
+      if (tty->TS_enter_italic_mode)
+       OUTPUT1 (tty, tty->TS_enter_italic_mode);
+      else
+       /* Italics mode is unavailable on many terminals.  In that
+          case, map slant to dimmed text; we want italic text to
+          appear different and dimming is not otherwise used.  */
+       OUTPUT1 (tty, tty->TS_enter_dim_mode);
+    }
 
   if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (tty, NC_UNDERLINE))
     OUTPUT1_IF (tty, tty->TS_enter_underline_mode);
@@ -2077,27 +2075,19 @@
         half-bright, reverse-video, standout, underline.  It may or
         may not turn off alt-char-mode.  */
       if (face->tty_bold_p
-         || face->tty_dim_p
+         || face->tty_italic_p
          || face->tty_reverse_p
-         || face->tty_alt_charset_p
-         || face->tty_blinking_p
          || face->tty_underline_p)
        {
          OUTPUT1_IF (tty, tty->TS_exit_attribute_mode);
          if (strcmp (tty->TS_exit_attribute_mode, tty->TS_end_standout_mode) 
== 0)
            tty->standout_mode = 0;
        }
-
-      if (face->tty_alt_charset_p)
-       OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode);
     }
   else
     {
       /* If we don't have "me" we can only have those appearances
         that have exit sequences defined.  */
-      if (face->tty_alt_charset_p)
-       OUTPUT_IF (tty, tty->TS_exit_alt_charset_mode);
-
       if (face->tty_underline_p)
        OUTPUT_IF (tty, tty->TS_exit_underline_mode);
     }
@@ -2128,8 +2118,7 @@
   TTY_CAPABLE_P_TRY (tty, TTY_CAP_UNDERLINE,   tty->TS_enter_underline_mode,   
NC_UNDERLINE);
   TTY_CAPABLE_P_TRY (tty, TTY_CAP_BOLD,        tty->TS_enter_bold_mode,        
NC_BOLD);
   TTY_CAPABLE_P_TRY (tty, TTY_CAP_DIM,                 tty->TS_enter_dim_mode, 
        NC_DIM);
-  TTY_CAPABLE_P_TRY (tty, TTY_CAP_BLINK,       tty->TS_enter_blink_mode,       
NC_BLINK);
-  TTY_CAPABLE_P_TRY (tty, TTY_CAP_ALT_CHARSET,         
tty->TS_enter_alt_charset_mode, NC_ALT_CHARSET);
+  TTY_CAPABLE_P_TRY (tty, TTY_CAP_ITALIC,      tty->TS_enter_italic_mode,      
NC_ITALIC);
 
   /* We can do it!  */
   return 1;
@@ -3222,8 +3211,8 @@
   tty->TS_enter_underline_mode = tgetstr ("us", address);
   tty->TS_exit_underline_mode = tgetstr ("ue", address);
   tty->TS_enter_bold_mode = tgetstr ("md", address);
+  tty->TS_enter_italic_mode = tgetstr ("ZH", address);
   tty->TS_enter_dim_mode = tgetstr ("mh", address);
-  tty->TS_enter_blink_mode = tgetstr ("mb", address);
   tty->TS_enter_reverse_mode = tgetstr ("mr", address);
   tty->TS_enter_alt_charset_mode = tgetstr ("as", address);
   tty->TS_exit_alt_charset_mode = tgetstr ("ae", address);

=== modified file 'src/termchar.h'
--- a/src/termchar.h    2012-01-19 07:21:25 +0000
+++ b/src/termchar.h    2012-06-09 16:44:44 +0000
@@ -124,8 +124,8 @@
                                    each as vpos and hpos) */
 
   const char *TS_enter_bold_mode; /* "md" -- turn on bold (extra bright mode). 
 */
+  const char *TS_enter_italic_mode; /* "ZH" -- turn on italics mode.  */
   const char *TS_enter_dim_mode; /* "mh" -- turn on half-bright mode.  */
-  const char *TS_enter_blink_mode; /* "mb" -- enter blinking mode.  */
   const char *TS_enter_reverse_mode; /* "mr" -- enter reverse video mode.  */
   const char *TS_exit_underline_mode; /* "us" -- start underlining.  */
   const char *TS_enter_underline_mode; /* "ue" -- end underlining.  */

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2012-06-09 09:37:47 +0000
+++ b/src/xfaces.c      2012-06-09 16:44:44 +0000
@@ -4884,14 +4884,13 @@
 tty_supports_face_attributes_p (struct frame *f, Lisp_Object *attrs,
                                struct face *def_face)
 {
-  int weight;
+  int weight, slant;
   Lisp_Object val, fg, bg;
   XColor fg_tty_color, fg_std_color;
   XColor bg_tty_color, bg_std_color;
   unsigned test_caps = 0;
   Lisp_Object *def_attrs = def_face->lface;
 
-
   /* First check some easy-to-check stuff; ttys support none of the
      following attributes, so we can just return false if any are requested
      (even if `nominal' values are specified, we should still return false,
@@ -4907,11 +4906,9 @@
       || !UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
       || !UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
       || !UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
-      || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
-      || !UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]))
+      || !UNSPECIFIEDP (attrs[LFACE_BOX_INDEX]))
     return 0;
 
-
   /* Test for terminal `capabilities' (non-color character attributes).  */
 
   /* font weight (bold/dim) */
@@ -4937,6 +4934,18 @@
        return 0;               /* same as default */
     }
 
+  /* font slant */
+  val = attrs[LFACE_SLANT_INDEX];
+  if (!UNSPECIFIEDP (val)
+      && (slant = FONT_SLANT_NAME_NUMERIC (val), slant >= 0))
+    {
+      int def_slant = FONT_SLANT_NAME_NUMERIC (def_attrs[LFACE_SLANT_INDEX]);
+      if (slant == 100 || slant == def_slant)
+       return 0; /* same as default */
+      else
+       test_caps |= TTY_CAP_ITALIC;
+    }
+
   /* underlining */
   val = attrs[LFACE_UNDERLINE_INDEX];
   if (!UNSPECIFIEDP (val))
@@ -5857,15 +5866,13 @@
   face->font_name = FRAME_MSDOS_P (cache->f) ? "ms-dos" : "tty";
 #endif
 
-  /* Map face attributes to TTY appearances.  We map slant to
-     dimmed text because we want italic text to appear differently
-     and because dimmed text is probably used infrequently.  */
+  /* Map face attributes to TTY appearances.  */
   weight = FONT_WEIGHT_NAME_NUMERIC (attrs[LFACE_WEIGHT_INDEX]);
   slant = FONT_SLANT_NAME_NUMERIC (attrs[LFACE_SLANT_INDEX]);
   if (weight > 100)
     face->tty_bold_p = 1;
-  if (weight < 100 || slant != 100)
-    face->tty_dim_p = 1;
+  if (slant != 100)
+    face->tty_italic_p = 1;
   if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
     face->tty_underline_p = 1;
   if (!NILP (attrs[LFACE_INVERSE_INDEX]))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]