Example #1
0
void owl_variable_dict_add_variable(owl_vardict * vardict,
                                    owl_variable * var) {
  char *oldvalue = NULL;
  owl_variable *oldvar = owl_variable_get_var(vardict, var->name);
  /* Save the old value as a string. */
  if (oldvar) {
    oldvalue = owl_variable_get_tostring(oldvar);
  }
  owl_dict_insert_element(vardict, var->name, var, (void (*)(void *))owl_variable_delete);
  /* Restore the old value. */
  if (oldvalue) {
    owl_variable_set_fromstring(var, oldvalue, 0);
    g_free(oldvalue);
  }
}
Example #2
0
void owl_variable_dict_newvar_string(owl_vardict * vd, char *name, char *summ, char * desc, char * initval) {
  owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_STRING);
  if(old) {
    owl_variable_update(old, summ, desc);
    if(old->pval_default) owl_free(old->pval_default);
    old->pval_default = owl_strdup(initval);
  } else {
    owl_variable * var = owl_variable_newvar(name, summ, desc);
    var->type = OWL_VARIABLE_STRING;
    var->pval_default = owl_strdup(initval);
    var->set_fn = owl_variable_string_set_default;
    var->set_fromstring_fn = owl_variable_string_set_fromstring_default;
    var->get_fn = owl_variable_get_default;
    var->get_tostring_fn = owl_variable_string_get_tostring_default;
    var->free_fn = owl_variable_free_default;
    var->set_fn(var, initval);
    owl_variable_dict_add_variable(vd, var);
  }
}
Example #3
0
void owl_variable_dict_newvar_bool(owl_vardict * vd, char *name, char *summ, char * desc, int initval) {
  owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_BOOL);
  if(old) {
    owl_variable_update(old, summ, desc);
    old->ival_default = initval;
  } else {
    owl_variable * var = owl_variable_newvar(name, summ, desc);
    var->type = OWL_VARIABLE_BOOL;
    var->ival_default = initval;
    var->validate_fn = owl_variable_bool_validate_default;
    var->set_fn = owl_variable_bool_set_default;
    var->set_fromstring_fn = owl_variable_bool_set_fromstring_default;
    var->get_fn = owl_variable_get_default;
    var->get_tostring_fn = owl_variable_bool_get_tostring_default;
    var->free_fn = owl_variable_free_default;
    var->val = owl_malloc(sizeof(int));
    var->set_fn(var, &initval);
    owl_variable_dict_add_variable(vd, var);
  }
}
Example #4
0
void owl_variable_dict_newvar_int(owl_vardict * vd, const char *name, const char *summ, const char * desc, int initval) {
  owl_variable *old = owl_variable_get_var(vd, name, OWL_VARIABLE_INT);
  if(old) {
    owl_variable_update(old, summ, desc);
    old->ival_default = initval;
  } else {
    owl_variable * var = owl_variable_newvar(name, summ, desc);
    var->type = OWL_VARIABLE_INT;
    var->ival_default = initval;
    var->validate_fn = owl_variable_int_validate_default;
    var->set_fn = owl_variable_int_set_default;
    var->set_fromstring_fn = owl_variable_int_set_fromstring_default;
    var->get_fn = owl_variable_get_default;
    var->get_tostring_fn = owl_variable_int_get_tostring_default;
    var->delete_fn = owl_variable_delete_default;
    var->val = g_new(int, 1);
    var->set_fn(var, &initval);
    owl_variable_dict_add_variable(vd, var);
  }
}
Example #5
0
void owl_help(void)
{
  const owl_variable *v;
  owl_fmtext fm;
  const char *varname;
  GPtrArray *varnames;
  int i;

  owl_fmtext_init_null(&fm);
  owl_fmtext_append_bold
    (&fm, 
     "OWL HELP\n\n");

  owl_fmtext_append_normal
    (&fm, 
     "  If you're new to BarnOwl, the first thing you should type is\n\n"
     "    :show quickstart\n\n"
     "  For help on a specific command use 'help <command>'\n"
     "  For information on advanced keys, use 'show keymaps'.\n"
     "  For information on advanced commands, use 'show commands'.\n"
     "  For information on variables, use 'show variables'.\n\n");

  owl_fmtext_append_bold
    (&fm, 
     "  Basic Keys:\n"
     );
  owl_fmtext_append_normal
    (&fm, 
     "    n             Move to next non-deleted message\n"
     "    p             Move to previous non-deleted message\n"
     "    C-n , down    Move to next message\n"
     "    C-p , up      Move to previous message\n"
     "    < , >         Move to first, last message\n"
     "    right , left  Scroll screen left or right\n"
     "    C-v           Page down\n"
     "    M-v           Page up\n"
     "    i             Print more information about a message\n"
     "    P             Move to the next personal message\n"
     "    M-P           Move to the previous personal message\n"
     "    C-space       Move the mark (asterisk) to the current message\n"
     "    C-x C-x       Move the mark to the current message while moving to previous mark\n"
     "\n"
     "    d             Mark message for deletion\n"
     "    u             Undelete a message marked for deletion\n"
     "    x             Expunge deleted messages\n"
     "    X             Expunge deleted messages and switch to home view\n"
     "    T             Mark all 'trash' messages for deletion\n"
     "    M-D           Mark all messages in current view for deletion\n"
     "    M-u           Unmark all messages in the current view for deletion\n"
     "\n"
     "    z             Start a zwrite command\n"
     "    a             Start an aimwrite command\n"
     "    r             Reply to the current message\n"
     "    R             Reply to sender\n"
     "    C-r           Reply but allow editing of reply line\n"
     "\n"
     "    M-n           View zephyrs in selected conversation\n"
     "    M-N           View zephyrs in selected conversation of instance\n"
     "    M-p           View only personal zephyrs\n"
     "    V             Change to back to home view ('all' by default)\n"
     "    v             Start a view command\n"
     "    !             Invert the current view\n"
     "\n"
     "    l             Print a zephyr/AIM buddy listing\n"
     "    A             Toggle away\n"
     "    o             Toggle one-line display mode\n"
     "    w             Open a URL in the current message\n"
     "    C-l           Refresh the screen\n"
     "    C-z           Suspend BarnOwl\n"
     "    h             Print this help message\n"
     "    : , M-x       Enter command mode\n"
     "\n"
     "    /             Forward search\n"
     "    ?             Reverse search\n"
     "\n\n"
     );
  owl_fmtext_append_bold
    (&fm, 
     "  Basic Commands:\n"
     );
  owl_fmtext_append_normal
    (&fm, 
     "    quit, exit    Exit BarnOwl\n"
     "    help          Get help about commands\n"
     "    show          Show information about BarnOwl (see detailed help)\n"
     "\n"
     "    zwrite        Send a zephyr\n"
     "    aimlogin      Login to AIM\n"
     "    aimwrite      Send an AIM message\n"
     "\n"
     "    addbuddy      Add a zephyr or AIM buddy\n"
     "    zaway         Turn zaway on or off, or set the message\n"
     "    zlocate       Locate a user\n"
     "    subscribe     Subscribe to a zephyr class or instance\n"
     "    unsubscribe   Unsubscribe to a zephyr class or instance\n"
     "    blist         Print a list of zephyr and AIM buddies logged in\n"
     "    search        Search for a text string\n"
     "\n"
     "    set           Set a variable (see list below)\n"
     "    print         Print a variable's value (variables listed below)\n"
     "    startup       Set a command to be run at every BarnOwl startup\n"
     "    unstartup     Remove a command to be run at every BarnOwl startup\n"
     "\n"
     "    getsubs       Print a list of current subscriptions\n"
     "    unsuball      Unsubscribe from all zephyr classes\n"
     "    load-subs     Load zephyr subscriptions from a file\n"
     "    zpunt         Suppress messages from a zephyr triplet\n"
     "    zlog          Send a login or logout notification\n"
     "    zlist         Print a list of zephyr buddies logged in\n"
     "    alist         Print a list of AIM buddies logged in\n"
     "    info          Print detailed information about the current message\n"
     "    filter        Create a message filter\n"
     "    view          View messages matching a filter\n"
     "    viewuser      View messages to or from a particular user\n"
     "    viewclass     View messages to a particular class\n"
     "    expunge       Expunge messages marked for deletion\n"
     "    bindkey       Create a new key binding\n"
     "    alias         Create a command alias\n"
     "    dump          Dump messagelist as text to a file\n"
     "\n"
     "    about         Print information about BarnOwl\n"
     "    status        Print status information about the running BarnOwl\n"
     "    version       Print the version number of BarnOwl\n"
     "\n");
  
  /* help for variables */
  owl_fmtext_append_bold(&fm, 
			 "Variables:\n");
  varnames = owl_variable_dict_get_names(owl_global_get_vardict(&g));
  for (i = 0; i < varnames->len; i++) {
    varname = varnames->pdata[i];
    if (varname && varname[0]!='_') {
      v = owl_variable_get_var(owl_global_get_vardict(&g), varname);
      owl_variable_describe(v, &fm);
    }
  }
  owl_ptr_array_free(varnames, g_free);

  owl_fmtext_append_normal(&fm, "\n");

  owl_function_popless_fmtext(&fm);

  owl_fmtext_cleanup(&fm);
}
Example #6
0
/* returns a reference */
void *owl_variable_get(owl_vardict *d, char *name, int require_type) {
  owl_variable *v = owl_variable_get_var(d, name, require_type);
  if(v == NULL) return NULL;
  return v->get_fn(v);
}