Changeset 8fa9562 for functions.c


Ignore:
Timestamp:
Jan 20, 2007, 9:49:55 PM (14 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:
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
  • functions.c

    r8203afd r8fa9562  
    24542454      return;
    24552455    }
    2456     owl_filter_set_color(f, owl_util_string_to_color(argv[3]));
     2456    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
     2457    owl_global_set_needrefresh(&g);
     2458    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2459    return;
     2460  }
     2461  if (argc==4 && !strcmp(argv[2], "-b")) {
     2462    f=owl_global_get_filter(&g, argv[1]);
     2463    if (!f) {
     2464      owl_function_error("The filter '%s' does not exist.", argv[1]);
     2465      return;
     2466    }
     2467    if (owl_util_string_to_color(argv[3])==-1) {
     2468      owl_function_error("The color '%s' is not available.", argv[3]);
     2469      return;
     2470    }
     2471    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    24572472    owl_global_set_needrefresh(&g);
    24582473    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    25452560    owl_fmtext_append_normal(&fm, "   ");
    25462561    if (owl_global_get_hascolors(&g)) {
    2547       owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_color(f));
     2562      owl_fmtext_append_normal_color(&fm, owl_filter_get_name(f), owl_filter_get_fgcolor(f), owl_filter_get_bgcolor(f));
    25482563    } else {
    25492564      owl_fmtext_append_normal(&fm, owl_filter_get_name(f));
     
    29242939 * be 'color'
    29252940 */
    2926 void owl_function_color_current_filter(char *color)
     2941void owl_function_color_current_filter(char *fgcolor, char *bgcolor)
    29272942{
    29282943  char *name;
    29292944
    29302945  name=owl_view_get_filtname(owl_global_get_current_view(&g));
    2931   owl_function_color_filter(name, color);
     2946  owl_function_color_filter(name, fgcolor, bgcolor);
    29322947}
    29332948
     
    29362951 * the "all" filter, return -2.  Return 0 on success
    29372952 */
    2938 int owl_function_color_filter(char *filtname, char *color)
     2953int owl_function_color_filter(char *filtname, char *fgcolor, char *bgcolor)
    29392954{
    29402955  owl_filter *f;
     
    29522967  }
    29532968
    2954   if (owl_util_string_to_color(color)==-1) {
    2955     owl_function_error("No color named '%s' avilable.");
     2969  if (owl_util_string_to_color(fgcolor)==-1) {
     2970    owl_function_error("No color named '%s' avilable.", fgcolor);
    29562971    return(-1);
    29572972  }
    2958   owl_filter_set_color(f, owl_util_string_to_color(color));
     2973
     2974
     2975  if (bgcolor != NULL) {
     2976    if (owl_util_string_to_color(bgcolor)==-1) {
     2977      owl_function_error("No color named '%s' avilable.", bgcolor);
     2978      return(-1);
     2979    }
     2980    owl_filter_set_bgcolor(f, owl_util_string_to_color(bgcolor));
     2981  }
     2982  owl_filter_set_fgcolor(f, owl_util_string_to_color(fgcolor));
     2983 
    29592984  owl_global_set_needrefresh(&g);
    29602985  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     
    29682993  owl_fmtext_init_null(&fm);
    29692994  owl_fmtext_append_normal(&fm, "default: ");
    2970   owl_fmtext_append_normal_color(&fm, "default\n", OWL_COLOR_DEFAULT);
     2995  owl_fmtext_append_normal_color(&fm, "default\n", OWL_COLOR_DEFAULT, OWL_COLOR_DEFAULT);
    29712996
    29722997  owl_fmtext_append_normal(&fm,"red:      ");
    2973   owl_fmtext_append_normal_color(&fm, "red\n", OWL_COLOR_RED);
     2998  owl_fmtext_append_normal_color(&fm, "red\n", OWL_COLOR_RED, OWL_COLOR_DEFAULT);
    29742999
    29753000  owl_fmtext_append_normal(&fm,"green:    ");
    2976   owl_fmtext_append_normal_color(&fm, "green\n", OWL_COLOR_GREEN);
     3001  owl_fmtext_append_normal_color(&fm, "green\n", OWL_COLOR_GREEN, OWL_COLOR_DEFAULT);
    29773002
    29783003  owl_fmtext_append_normal(&fm,"yellow:   ");
    2979   owl_fmtext_append_normal_color(&fm, "yellow\n", OWL_COLOR_YELLOW);
     3004  owl_fmtext_append_normal_color(&fm, "yellow\n", OWL_COLOR_YELLOW, OWL_COLOR_DEFAULT);
    29803005
    29813006  owl_fmtext_append_normal(&fm,"blue:     ");
    2982   owl_fmtext_append_normal_color(&fm, "blue\n", OWL_COLOR_BLUE);
     3007  owl_fmtext_append_normal_color(&fm, "blue\n", OWL_COLOR_BLUE, OWL_COLOR_DEFAULT);
    29833008
    29843009  owl_fmtext_append_normal(&fm,"magenta:  ");
    2985   owl_fmtext_append_normal_color(&fm, "magenta\n", OWL_COLOR_MAGENTA);
     3010  owl_fmtext_append_normal_color(&fm, "magenta\n", OWL_COLOR_MAGENTA, OWL_COLOR_DEFAULT);
    29863011
    29873012  owl_fmtext_append_normal(&fm,"cyan:     ");
    2988   owl_fmtext_append_normal_color(&fm, "cyan\n", OWL_COLOR_CYAN);
     3013  owl_fmtext_append_normal_color(&fm, "cyan\n", OWL_COLOR_CYAN, OWL_COLOR_DEFAULT);
    29893014
    29903015  owl_fmtext_append_normal(&fm,"white:    ");
    2991   owl_fmtext_append_normal_color(&fm, "white\n", OWL_COLOR_WHITE);
     3016  owl_fmtext_append_normal_color(&fm, "white\n", OWL_COLOR_WHITE, OWL_COLOR_DEFAULT);
    29923017
    29933018  owl_function_popless_fmtext(&fm);
Note: See TracChangeset for help on using the changeset viewer.