Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    rf271129 rca1fb26a  
    9696  OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY,
    9797              "removes a binding in a keymap",
    98               "bindkey <keymap> <keyseq>",
     98              "unbindkey <keymap> <keyseq>",
    9999              "Removes a binding of a key sequence within a keymap.\n"
    100100              "Use 'show keymaps' to see the existing keymaps.\n"
     
    479479
    480480  OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE,
    481               "Set, enable or disable both AIM and zephyr away messages",
     481              "Set, enable or disable all away messages",
    482482              "away [ on | off | toggle ]\n"
    483483              "away <message>",
    484               "Turn on or off the AIM and zephyr away message.  If\n"
     484              "Turn on or off all away messages.  If\n"
    485485              "'message' is specified turn them on with that message,\n"
    486486              "otherwise use the default.\n"
    487               "\n"
    488               "This command really just runs the 'aaway' and 'zaway'\n"
    489               "commands together\n"
    490487              "\n"
    491488              "SEE ALSO: aaway, zaway"),
     
    10331030  OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS,
    10341031                  "starts a command line to search for particular string",
    1035                   "popless:start-search [-r] [inital-value]",
     1032                  "popless:start-search [-r] [initial-value]",
    10361033                  "Initializes the command-line to search for initial-value. If\n"
    10371034                  "-r is used, the search will be performed backwards.\n\n"
     
    11171114void owl_command_version(void)
    11181115{
    1119   owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);
     1116  owl_function_makemsg("BarnOwl version %s", version);
    11201117}
    11211118
     
    15311528char *owl_command_away(int argc, const char *const *argv, const char *buff)
    15321529{
    1533   if ((argc==1) ||
    1534       ((argc==2) && !strcmp(argv[1], "on"))) {
     1530  bool away_off;
     1531  const char *message = NULL;
     1532
     1533  if (argc == 1 ||
     1534      (argc == 2 && !strcmp(argv[1], "on"))) {
     1535    away_off = false;
    15351536    owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g));
    15361537    owl_global_set_zaway_msg(&g, owl_global_get_zaway_msg_default(&g));
     1538  } else if (argc == 2 && !strcmp(argv[1], "off")) {
     1539    away_off = true;
     1540  } else if (argc == 2 && !strcmp(argv[1], "toggle")) {
     1541    away_off = owl_function_is_away();
     1542  } else {
     1543    away_off = false;
     1544    message = skiptokens(buff, 1);
     1545  }
     1546
     1547  if (away_off) {
     1548    owl_function_aaway_off();
     1549    owl_function_zaway_off();
     1550    owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_off", 0, NULL);
     1551    owl_function_makemsg("Away messages off.");
     1552  } else if (message != NULL) {
     1553    owl_global_set_aaway_msg(&g, message);
     1554    owl_global_set_zaway_msg(&g, message);
    15371555    owl_function_aaway_on();
    15381556    owl_function_zaway_on();
     1557    owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 1, &message);
     1558    owl_function_makemsg("Away messages set (%s).", message);
     1559  } else {
     1560    owl_function_aaway_on();
     1561    owl_function_zaway_on();
     1562    owl_perlconfig_perl_call_norv("BarnOwl::Hooks::_away_on", 0, NULL);
    15391563    owl_function_makemsg("Away messages set.");
    1540     return NULL;
    1541   }
    1542 
    1543   if (argc==2 && !strcmp(argv[1], "off")) {
    1544     owl_function_aaway_off();
    1545     owl_function_zaway_off();
    1546     return NULL;
    1547   }
    1548 
    1549   if (argc==2 && !strcmp(argv[1], "toggle")) {
    1550     /* if either one is on, turn it off, otherwise toggle both (turn
    1551      *  them both on)
    1552      */
    1553     if (!owl_global_is_zaway(&g) && !owl_global_is_aaway(&g)) {
    1554       owl_function_aaway_toggle();
    1555       owl_function_zaway_toggle();
    1556       owl_function_makemsg("Away messages set.");
    1557     } else {
    1558       if (owl_global_is_zaway(&g)) owl_function_zaway_toggle();
    1559       if (owl_global_is_aaway(&g)) owl_function_aaway_toggle();
    1560       owl_function_makemsg("Away messages off.");
    1561     }
    1562     return NULL;
    1563   }
    1564 
    1565   buff = skiptokens(buff, 1);
    1566   owl_global_set_aaway_msg(&g, buff);
    1567   owl_global_set_zaway_msg(&g, buff);
    1568   owl_function_aaway_on();
    1569   owl_function_zaway_on();
    1570   owl_function_makemsg("Away messages set.");
     1564  }
     1565
    15711566  return NULL;
    15721567}
     
    16041599  if (v == NULL) {
    16051600    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1606   } else if (requirebool && owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1601  } else if (requirebool && !v->takes_on_off) {
    16071602    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16081603  } else {
     
    16331628  if (v == NULL) {
    16341629    if (!silent) owl_function_error("Unknown variable '%s'", var);
    1635   } else if (owl_variable_get_type(v) != OWL_VARIABLE_BOOL) {
     1630  } else if (!v->takes_on_off) {
    16361631    if (!silent) owl_function_error("Variable '%s' is not a boolean", var);
    16371632  } else {
     
    17781773
    17791774  if (argc < 3) {
    1780     owl_function_makemsg("Usage: bindkey <keymap> <binding>");
     1775    owl_function_makemsg("Usage: unbindkey <keymap> <binding>");
    17811776    return NULL;
    17821777  }
     
    19851980  }
    19861981  /* check for a zwrite -m */
    1987   z = owl_zwrite_new(buff);
     1982  z = owl_zwrite_new(argc, argv);
    19881983  if (!z) {
    19891984    owl_function_error("Error in zwrite arguments");
     
    21902185    if (!strcmp(argv[0], "-f")) {
    21912186      if (argc<2) {
    2192         owl_function_makemsg("Too few argments to the view command");
     2187        owl_function_makemsg("Too few arguments to the view command");
    21932188        return(NULL);
    21942189      }
     
    22022197    } else if (!strcmp(argv[0], "-s")) {
    22032198      if (argc<2) {
    2204         owl_function_makemsg("Too few argments to the view command");
     2199        owl_function_makemsg("Too few arguments to the view command");
    22052200        return(NULL);
    22062201      }
     
    22092204      argv+=2;
    22102205    } else {
    2211       owl_function_makemsg("Too few argments to the view command");
     2206      owl_function_makemsg("Too few arguments to the view command");
    22122207      return(NULL);
    22132208    }
     
    27962791    owl_history_store(hist, owl_editwin_get_text(e), false);
    27972792
     2793  /* Take a reference to the editwin, so that it survives the pop
     2794   * context. TODO: We should perhaps refcount or otherwise protect
     2795   * the context so that, even if a command pops a context, the
     2796   * context itself will last until the command returns. */
     2797  owl_editwin_ref(e);
    27982798  owl_global_pop_context(&g);
     2799
     2800  owl_editwin_do_callback(e, false);
     2801  owl_editwin_unref(e);
    27992802}
    28002803
     
    28562859  owl_global_pop_context(&g);
    28572860
    2858   owl_editwin_do_callback(e);
     2861  owl_editwin_do_callback(e, true);
    28592862  owl_editwin_unref(e);
    28602863}
Note: See TracChangeset for help on using the changeset viewer.