Changeset 8fa9562 for filter.c


Ignore:
Timestamp:
Jan 20, 2007, 9:49:55 PM (18 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, barnowl_perlaim, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
575877f
Parents:
212764e
Message:
Added background color support to owl.

If we run out of color pairs during a painting of the screen, further
background colors will be silently dropped. I'm hoping this doesn't
happen often. The used pair list is reset with each draw, so only
what's actually on screen matters.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • filter.c

    r446aa2b r8fa9562  
    2121  f->name=owl_strdup(name);
    2222  f->polarity=0;
    23   f->color=OWL_COLOR_DEFAULT;
     23  f->fgcolor=OWL_COLOR_DEFAULT;
     24  f->bgcolor=OWL_COLOR_DEFAULT;
    2425  f->cachedmsgid=-1;
    2526
    2627  /* first take arguments that have to come first */
    2728  /* set the color */
    28   if (argc>=2 && !strcmp(argv[0], "-c")) {
     29  while ( argc>=2 && ( !strcmp(argv[0], "-c") ||
     30                       !strcmp(argv[0], "-b") ) ) {
    2931    if (owl_util_string_to_color(argv[1])==-1) {
    3032      owl_function_error("The color '%s' is not available, using default.", argv[1]);
    3133    } else {
    32       f->color=owl_util_string_to_color(argv[1]);
     34      switch (argv[0][1]) {
     35      case 'c':
     36        f->fgcolor=owl_util_string_to_color(argv[1]);
     37        break;
     38      case 'b':
     39        f->bgcolor=owl_util_string_to_color(argv[1]);
     40        break;
     41      }
    3342    }
    3443    argc-=2;
     
    159168}
    160169
    161 void owl_filter_set_color(owl_filter *f, int color)
    162 {
    163   f->color=color;
    164 }
    165 
    166 int owl_filter_get_color(owl_filter *f)
    167 {
    168   return(f->color);
     170void owl_filter_set_fgcolor(owl_filter *f, int color)
     171{
     172  f->fgcolor=color;
     173}
     174
     175int owl_filter_get_fgcolor(owl_filter *f)
     176{
     177  return(f->fgcolor);
     178}
     179
     180void owl_filter_set_bgcolor(owl_filter *f, int color)
     181{
     182  f->bgcolor=color;
     183}
     184
     185int owl_filter_get_bgcolor(owl_filter *f)
     186{
     187  return(f->bgcolor);
    169188}
    170189
     
    196215  strcat(out, ": ");
    197216
    198   if (f->color!=OWL_COLOR_DEFAULT) {
     217  if (f->fgcolor!=OWL_COLOR_DEFAULT) {
    199218    strcat(out, "-c ");
    200     strcat(out, owl_util_color_to_string(f->color));
     219    strcat(out, owl_util_color_to_string(f->fgcolor));
     220    strcat(out, " ");
     221  }
     222  if (f->bgcolor!=OWL_COLOR_DEFAULT) {
     223    strcat(out, "-b ");
     224    strcat(out, owl_util_color_to_string(f->bgcolor));
    201225    strcat(out, " ");
    202226  }
Note: See TracChangeset for help on using the changeset viewer.