Changeset cb6c9e1


Ignore:
Timestamp:
Feb 26, 2011, 12:59:00 AM (10 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.8, release-1.9
Children:
f54b07d
Parents:
237d02c
git-author:
David Benjamin <davidben@mit.edu> (02/25/11 15:34:47)
git-committer:
David Benjamin <davidben@mit.edu> (02/26/11 00:59:00)
Message:
Apply default attributes after processing commands

Otherwise we reset the color after every clump of formatting characters,
whether it includes a color or not. (Though this never happens because
of how we generate fmtext.) Also, actually modify the current attr so
that default_attrs works with search.

(While I'm at it, simplify _owl_fmtext_append_fmtext a bit.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r237d02c rcb6c9e1  
    131131static void _owl_fmtext_append_fmtext(owl_fmtext *f, const owl_fmtext *in, int start, int stop)
    132132{
    133   int a = 0, fg = 0, bg = 0;
    134133  char attr = 0;
    135134  short fgcolor = OWL_COLOR_DEFAULT;
     
    137136
    138137  _owl_fmtext_scan_attributes(in, start, &attr, &fgcolor, &bgcolor);
    139   if (attr != OWL_FMTEXT_ATTR_NONE) a=1;
    140   if (fgcolor != OWL_COLOR_DEFAULT) fg=1;
    141   if (bgcolor != OWL_COLOR_DEFAULT) bg=1;
    142 
    143   if (a)
     138
     139  if (attr != OWL_FMTEXT_ATTR_NONE)
    144140    g_string_append_unichar(f->buff, OWL_FMTEXT_UC_ATTR | attr);
    145   if (fg)
     141  if (fgcolor != OWL_COLOR_DEFAULT)
    146142    g_string_append_unichar(f->buff, OWL_FMTEXT_UC_FGCOLOR | fgcolor);
    147   if (bg)
     143  if (bgcolor != OWL_COLOR_DEFAULT)
    148144    g_string_append_unichar(f->buff, OWL_FMTEXT_UC_BGCOLOR | bgcolor);
    149145
     
    264260      p[0] = tmp;
    265261
    266       /* Deal with new attributes. Initialize to defaults, then
    267          process all consecutive formatting characters. */
    268       attr = default_attrs;
    269       fg = default_fgcolor;
    270       bg = default_bgcolor;
     262      /* Deal with new attributes. Process all consecutive formatting
     263       * characters, and then apply defaults where relevant. */
    271264      while (owl_fmtext_is_format_char(g_utf8_get_char(p))) {
    272265        _owl_fmtext_update_attributes(g_utf8_get_char(p), &attr, &fg, &bg);
    273266        p = g_utf8_next_char(p);
    274267      }
    275       _owl_fmtext_wattrset(w, attr | default_attrs);
     268      attr |= default_attrs;
    276269      if (fg == OWL_COLOR_DEFAULT) fg = default_fgcolor;
    277270      if (bg == OWL_COLOR_DEFAULT) bg = default_bgcolor;
     271      _owl_fmtext_wattrset(w, attr);
    278272      _owl_fmtext_update_colorpair(fg, bg, &pair);
    279273      _owl_fmtext_wcolor_set(w, pair);
Note: See TracChangeset for help on using the changeset viewer.