comparison mcabber/src/commands.c @ 1173:960f34ec22a2

Add init_bindings() for default key bindings (Lego12239)
author Mikael Berthe <mikael@lilotux.net>
date Tue, 03 Apr 2007 20:30:34 +0200
parents 334ae9f498f1
children 10733d7de004
comparison
equal deleted inserted replaced
1172:334ae9f498f1 1173:960f34ec22a2
39 #define IMSTATUS_FREE4CHAT "free" 39 #define IMSTATUS_FREE4CHAT "free"
40 #define IMSTATUS_INVISIBLE "invisible" 40 #define IMSTATUS_INVISIBLE "invisible"
41 #define IMSTATUS_AVAILABLE "avail" 41 #define IMSTATUS_AVAILABLE "avail"
42 #define IMSTATUS_NOTAVAILABLE "notavail" 42 #define IMSTATUS_NOTAVAILABLE "notavail"
43 #define IMSTATUS_DONOTDISTURB "dnd" 43 #define IMSTATUS_DONOTDISTURB "dnd"
44
45 // Return value container for the following functions
46 static int retval_for_cmds;
44 47
45 // Commands callbacks 48 // Commands callbacks
46 static void do_roster(char *arg); 49 static void do_roster(char *arg);
47 static void do_status(char *arg); 50 static void do_status(char *arg);
48 static void do_status_to(char *arg); 51 static void do_status_to(char *arg);
94 compl_add_category_word(COMPL_CMD, name); 97 compl_add_category_word(COMPL_CMD, name);
95 } 98 }
96 99
97 // cmd_init() 100 // cmd_init()
98 // Commands table initialization 101 // Commands table initialization
102 // !!!
103 // After changing commands names and it arguments names here, you must change
104 // ones in init_bindings()!
105 //
99 void cmd_init(void) 106 void cmd_init(void)
100 { 107 {
101 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add); 108 cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add);
102 cmd_add("alias", "Add an alias", 0, 0, &do_alias); 109 cmd_add("alias", "Add an alias", 0, 0, &do_alias);
103 cmd_add("authorization", "Manage subscription authorizations", 110 cmd_add("authorization", "Manage subscription authorizations",
411 ; 418 ;
412 // Skip spaces 419 // Skip spaces
413 while (*p && (*p == ' ')) 420 while (*p && (*p == ' '))
414 p++; 421 p++;
415 // Call command-specific function 422 // Call command-specific function
423 retval_for_cmds = 0;
416 (*curcmd->func)(p); 424 (*curcmd->func)(p);
417 g_free(xpline); 425 g_free(xpline);
418 return 0; 426 return retval_for_cmds;
419 } 427 }
420 428
421 // process_line(line) 429 // process_line(line)
422 // Process a command/message line. 430 // Process a command/message line.
423 // If this isn't a command, this is a message and it is sent to the 431 // If this isn't a command, this is a message and it is sent to the
2719 } 2727 }
2720 2728
2721 free_arg_lst(paramlst); 2729 free_arg_lst(paramlst);
2722 } 2730 }
2723 2731
2732 /* !!!
2733 After changing the /iline arguments names here, you must change ones
2734 in init_bindings().
2735 */
2724 static void do_iline(char *arg) 2736 static void do_iline(char *arg)
2725 { 2737 {
2726 if (!strcasecmp(arg, "fword")) { 2738 if (!strcasecmp(arg, "fword")) {
2727 readline_forward_word(); 2739 readline_forward_word();
2728 } else if (!strcasecmp(arg, "bword")) { 2740 } else if (!strcasecmp(arg, "bword")) {
2760 } else if (!strcasecmp(arg, "iline_bdel")) { 2772 } else if (!strcasecmp(arg, "iline_bdel")) {
2761 readline_backward_kill_iline(); 2773 readline_backward_kill_iline();
2762 } else if (!strcasecmp(arg, "send_multiline")) { 2774 } else if (!strcasecmp(arg, "send_multiline")) {
2763 readline_send_multiline(); 2775 readline_send_multiline();
2764 } else if (!strcasecmp(arg, "iline_accept")) { 2776 } else if (!strcasecmp(arg, "iline_accept")) {
2765 readline_accept_line(); 2777 retval_for_cmds = readline_accept_line();
2766 } else if (!strcasecmp(arg, "iline_accept_down_hist")) { // May be too long 2778 } else if (!strcasecmp(arg, "iline_accept_down_hist")) { // May be too long
2767 readline_accept_line_down_hist(); 2779 retval_for_cmds = readline_accept_line_down_hist();
2768 } else if (!strcasecmp(arg, "compl_cancel")) { 2780 } else if (!strcasecmp(arg, "compl_cancel")) {
2769 readline_cancel_completion(); 2781 readline_cancel_completion();
2770 } else if (!strcasecmp(arg, "compl_do")) { 2782 } else if (!strcasecmp(arg, "compl_do")) {
2771 readline_do_completion(); 2783 readline_do_completion();
2772 } 2784 }