Changes in commands.c [f271129:ca1fb26a]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
rf271129 rca1fb26a 96 96 OWLCMD_ARGS("unbindkey", owl_command_unbindkey, OWL_CTX_ANY, 97 97 "removes a binding in a keymap", 98 " bindkey <keymap> <keyseq>",98 "unbindkey <keymap> <keyseq>", 99 99 "Removes a binding of a key sequence within a keymap.\n" 100 100 "Use 'show keymaps' to see the existing keymaps.\n" … … 479 479 480 480 OWLCMD_ARGS("away", owl_command_away, OWL_CTX_INTERACTIVE, 481 "Set, enable or disable both AIM and zephyraway messages",481 "Set, enable or disable all away messages", 482 482 "away [ on | off | toggle ]\n" 483 483 "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" 485 485 "'message' is specified turn them on with that message,\n" 486 486 "otherwise use the default.\n" 487 "\n"488 "This command really just runs the 'aaway' and 'zaway'\n"489 "commands together\n"490 487 "\n" 491 488 "SEE ALSO: aaway, zaway"), … … 1033 1030 OWLCMD_ARGS_CTX("popless:start-search", owl_viewwin_command_start_search, OWL_CTX_POPLESS, 1034 1031 "starts a command line to search for particular string", 1035 "popless:start-search [-r] [init al-value]",1032 "popless:start-search [-r] [initial-value]", 1036 1033 "Initializes the command-line to search for initial-value. If\n" 1037 1034 "-r is used, the search will be performed backwards.\n\n" … … 1117 1114 void owl_command_version(void) 1118 1115 { 1119 owl_function_makemsg("BarnOwl version %s", OWL_VERSION_STRING);1116 owl_function_makemsg("BarnOwl version %s", version); 1120 1117 } 1121 1118 … … 1531 1528 char *owl_command_away(int argc, const char *const *argv, const char *buff) 1532 1529 { 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; 1535 1536 owl_global_set_aaway_msg(&g, owl_global_get_aaway_msg_default(&g)); 1536 1537 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); 1537 1555 owl_function_aaway_on(); 1538 1556 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); 1539 1563 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 1571 1566 return NULL; 1572 1567 } … … 1604 1599 if (v == NULL) { 1605 1600 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) { 1607 1602 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1608 1603 } else { … … 1633 1628 if (v == NULL) { 1634 1629 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) { 1636 1631 if (!silent) owl_function_error("Variable '%s' is not a boolean", var); 1637 1632 } else { … … 1778 1773 1779 1774 if (argc < 3) { 1780 owl_function_makemsg("Usage: bindkey <keymap> <binding>");1775 owl_function_makemsg("Usage: unbindkey <keymap> <binding>"); 1781 1776 return NULL; 1782 1777 } … … 1985 1980 } 1986 1981 /* check for a zwrite -m */ 1987 z = owl_zwrite_new( buff);1982 z = owl_zwrite_new(argc, argv); 1988 1983 if (!z) { 1989 1984 owl_function_error("Error in zwrite arguments"); … … 2190 2185 if (!strcmp(argv[0], "-f")) { 2191 2186 if (argc<2) { 2192 owl_function_makemsg("Too few arg ments to the view command");2187 owl_function_makemsg("Too few arguments to the view command"); 2193 2188 return(NULL); 2194 2189 } … … 2202 2197 } else if (!strcmp(argv[0], "-s")) { 2203 2198 if (argc<2) { 2204 owl_function_makemsg("Too few arg ments to the view command");2199 owl_function_makemsg("Too few arguments to the view command"); 2205 2200 return(NULL); 2206 2201 } … … 2209 2204 argv+=2; 2210 2205 } else { 2211 owl_function_makemsg("Too few arg ments to the view command");2206 owl_function_makemsg("Too few arguments to the view command"); 2212 2207 return(NULL); 2213 2208 } … … 2796 2791 owl_history_store(hist, owl_editwin_get_text(e), false); 2797 2792 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); 2798 2798 owl_global_pop_context(&g); 2799 2800 owl_editwin_do_callback(e, false); 2801 owl_editwin_unref(e); 2799 2802 } 2800 2803 … … 2856 2859 owl_global_pop_context(&g); 2857 2860 2858 owl_editwin_do_callback(e );2861 owl_editwin_do_callback(e, true); 2859 2862 owl_editwin_unref(e); 2860 2863 }
Note: See TracChangeset
for help on using the changeset viewer.