Changeset 486688f for commands.c


Ignore:
Timestamp:
Sep 28, 2002, 1:14:45 PM (22 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
88736cb
Parents:
55a4578
Message:
Will attempt to keep the current message as close as possible
	     to the previous current message after an expunge.
"set <variable>" and "unset <variable>" now work for boolean variables.
	   (although I'm not totally happy with how I implemented it.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rbde7714 r486688f  
    114114  OWLCMD_ARGS("set", owl_command_set, OWL_CTX_ANY,
    115115              "set a variable value",
    116               "set [-q] <variable> <value>\n"
     116              "set [-q] <variable> [<value>]\n"
    117117              "set",
    118118              "Set the named variable to the specified value.  If no\n"
    119119              "arguments are used print the value of all variables.\n"
     120              "If value is unspecified and the variable is a boolean, will set it to 'on'.\n"
     121              "If -q is specified, is silent and doesn't print a message.\n"),
     122
     123  OWLCMD_ARGS("unset", owl_command_unset, OWL_CTX_ANY,
     124              "unset a boolean variable value",
     125              "set [-q] <variable>\n"
     126              "set",
     127              "Set the named boolean variable to off.\n"
    120128              "If -q is specified, is silent and doesn't print a message.\n"),
    121129
     
    946954  char *var, *val;
    947955  int  silent=0;
     956  int requirebool=0;
    948957
    949958  if (argc == 1) {
    950959    owl_function_printallvars();
    951960    return NULL;
    952   } else if (argc == 4 && !strcmp("-q",argv[1])) {
     961  }
     962
     963  if (argc > 1 && !strcmp("-q",argv[1])) {
    953964    silent = 1;
    954     var=argv[2];
    955     val=argv[3];
     965    argc--; argv++;
     966  }
     967
     968  if (argc == 2) {
     969    var=argv[1];
     970    val="on";
     971    requirebool=1;
    956972  } else if (argc == 3) {
    957973    var=argv[1];
     
    961977    return NULL;
    962978  }
    963 
    964   owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent);
     979  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool);
     980  return NULL;
     981}
     982
     983char *owl_command_unset(int argc, char **argv, char *buff) {
     984  char *var, *val;
     985  int  silent=0;
     986
     987  if (argc > 1 && !strcmp("-q",argv[1])) {
     988    silent = 1;
     989    argc--; argv++;
     990  }
     991  if (argc == 2) {
     992    var=argv[1];
     993    val="off";
     994  } else {
     995    owl_function_makemsg("Wrong number of arguments for unset command");
     996    return NULL;
     997  }
     998  owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1);
    965999  return NULL;
    9661000}
Note: See TracChangeset for help on using the changeset viewer.