Changeset 287c634


Ignore:
Timestamp:
Jul 23, 2011, 9:23:57 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.9
Children:
cbc8657
Parents:
e5baf0a
git-author:
David Benjamin <davidben@mit.edu> (07/23/11 18:54:46)
git-committer:
David Benjamin <davidben@mit.edu> (07/23/11 21:23:57)
Message:
Don't attempt to switch filters in :view -d if invalid

Add return value to owl_function_create_filter and check before
switching.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    refeec7f r287c634  
    21652165      myargv[i]=argv[i];
    21662166    }
    2167     owl_function_create_filter(argc, myargv);
    2168     owl_function_change_currentview_filter("owl-dynamic");
     2167    if (owl_function_create_filter(argc, myargv)) {
     2168      owl_function_change_currentview_filter("owl-dynamic");
     2169    }
    21692170    g_free(myargv);
    21702171    return NULL;
  • functions.c

    r4ebbfbc r287c634  
    21322132
    21332133/* Create a new filter, or replace an existing one
    2134  * with a new definition.
     2134 * with a new definition. Returns true on success.
    21352135 */
    2136 void owl_function_create_filter(int argc, const char *const *argv)
     2136bool owl_function_create_filter(int argc, const char *const *argv)
    21372137{
    21382138  owl_filter *f;
     
    21422142  if (argc < 2) {
    21432143    owl_function_error("Wrong number of arguments to filter command");
    2144     return;
     2144    return false;
    21452145  }
    21462146
     
    21522152  if (!strcmp(argv[1], "all")) {
    21532153    owl_function_error("You may not change the 'all' filter.");
    2154     return;
     2154    return false;
    21552155  }
    21562156
     
    21602160    if (!f) {
    21612161      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2162       return;
     2162      return false;
    21632163    }
    21642164    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21652165      owl_function_error("The color '%s' is not available.", argv[3]);
    2166       return;
     2166      return false;
    21672167    }
    21682168    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21692169    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2170     return;
     2170    return false;
    21712171  }
    21722172  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21742174    if (!f) {
    21752175      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2176       return;
     2176      return false;
    21772177    }
    21782178    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21792179      owl_function_error("The color '%s' is not available.", argv[3]);
    2180       return;
     2180      return false;
    21812181    }
    21822182    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21832183    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2184     return;
     2184    return true;
    21852185  }
    21862186
     
    21892189  if (f == NULL) {
    21902190    owl_function_error("Invalid filter");
    2191     return;
     2191    return false;
    21922192  }
    21932193
     
    22102210  }
    22112211  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2212  return true;
    22122213}
    22132214
Note: See TracChangeset for help on using the changeset viewer.