Changeset 16c6cca


Ignore:
Timestamp:
Jan 9, 2008, 2:32:01 PM (13 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
a827529
Parents:
369479d
Message:
Preserve colors when highlighting search terms.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • fmtext.c

    r6d77f1f r16c6cca  
    245245  if (attrs & OWL_FMTEXT_ATTR_UNDERLINE) wattron(w, A_UNDERLINE);
    246246}
     247
     248void _owl_fmtext_update_colorpair(short fg, short bg, short *pair) /*noproto*/
     249{
     250  if (owl_global_get_hascolors(&g)) {
     251    *pair = owl_fmtext_get_colorpair(fg, bg);
     252  }
     253}
     254
     255void _owl_fmtext_wcolor_set(WINDOW *w, short pair) /*noproto*/
     256{
     257  if (owl_global_get_hascolors(&g)) {
     258      wcolor_set(w,pair,NULL);
     259  }
     260}
     261
    247262/* add the formatted text to the curses window 'w'.  The window 'w'
    248263 * must already be initiatlized with curses
     
    254269  char *s, *p;
    255270  char attr;
    256   short fg, bg;
     271  short fg, bg, pair;
    257272  int search_results, search_len;
    258273 
     
    274289  bg = f->default_bgcolor;
    275290  _owl_fmtext_wattrset(w, attr);
    276   if (owl_global_get_hascolors(&g)) {
    277     short pair;
    278     pair = owl_fmtext_get_colorpair(fg, bg);
    279     if (pair != -1) {
    280       wcolor_set(w,pair,NULL);
    281     }
    282   }
     291  _owl_fmtext_update_colorpair(fg, bg, &pair);
     292  _owl_fmtext_wcolor_set(w, pair);
    283293
    284294  /* Find next possible format character. */
     
    304314
    305315          _owl_fmtext_wattrset(w, attr ^ OWL_FMTEXT_ATTR_REVERSE);
    306 
     316          _owl_fmtext_wcolor_set(w, pair);
     317         
    307318          tmp2 = ss[search_len];
    308319          ss[search_len] = '\0';
     
    310321          ss[search_len] = tmp2;
    311322
    312           _owl_fmtext_wattrset(w,attr);
     323          _owl_fmtext_wattrset(w, attr);
     324          _owl_fmtext_wcolor_set(w, pair);
    313325
    314326          s = ss + search_len;
     
    330342      }
    331343      _owl_fmtext_wattrset(w, attr | f->default_attrs);
    332       if (owl_global_get_hascolors(&g)) {
    333         if (fg == OWL_COLOR_DEFAULT) fg = f->default_fgcolor;
    334         if (bg == OWL_COLOR_DEFAULT) bg = f->default_bgcolor;
    335         short pair;
    336         pair = owl_fmtext_get_colorpair(fg, bg);
    337         if (pair != -1) {
    338           wcolor_set(w,pair,NULL);
    339         }
    340       }
     344      if (fg == OWL_COLOR_DEFAULT) fg = f->default_fgcolor;
     345      if (bg == OWL_COLOR_DEFAULT) bg = f->default_bgcolor;
     346      _owl_fmtext_update_colorpair(fg, bg, &pair);
     347      _owl_fmtext_wcolor_set(w, pair);
     348
    341349      /* Advance to next non-formatting character. */
    342350      s = p;
Note: See TracChangeset for help on using the changeset viewer.