Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/commands.c @ 95:9e6b7897ec37
[/trunk] Changeset 109 by mikael
* Work on compl.* integration. No big change yet...
author | mikael |
---|---|
date | Wed, 20 Apr 2005 19:06:25 +0000 |
parents | 9a4aa2797f02 |
children | 8b2703ccc4be |
comparison
equal
deleted
inserted
replaced
94:9a4aa2797f02 | 95:9e6b7897ec37 |
---|---|
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 * USA | 19 * USA |
20 */ | 20 */ |
21 | 21 |
22 #include <string.h> | |
23 | |
22 #include "commands.h" | 24 #include "commands.h" |
23 #include "jabglue.h" | 25 #include "jabglue.h" |
24 #include "roster.h" | 26 #include "roster.h" |
25 #include "screen.h" | 27 #include "screen.h" |
28 #include "compl.h" | |
26 #include "utf8.h" | 29 #include "utf8.h" |
27 #include "utils.h" | 30 #include "utils.h" |
28 | 31 |
29 | 32 |
30 // Command structure | 33 // Command structure |
31 typedef struct { | 34 typedef struct { |
32 char name[32]; | 35 char name[32]; |
33 char *help; // ? | 36 const char *help; |
34 guint completion_flags; | 37 guint completion_flags[2]; |
35 void *(*func)(); | 38 void *(*func)(); |
36 } cmd; | 39 } cmd; |
37 | 40 |
41 static GSList *Commands; | |
42 | |
43 // cmd_add() | |
44 // Adds a command to the commands list and to the CMD completion list | |
45 void cmd_add(const char *name, const char *help, | |
46 guint flags_row1, guint flags_row2, void *(*f)()) | |
47 { | |
48 cmd *n_cmd = g_new0(cmd, 1); | |
49 strncpy(n_cmd->name, name, 32-1); | |
50 n_cmd->help = help; | |
51 n_cmd->completion_flags[0] = flags_row1; | |
52 n_cmd->completion_flags[1] = flags_row2; | |
53 n_cmd->func = f; | |
54 g_slist_append(Commands, n_cmd); | |
55 // Add to completion CMD category | |
56 compl_add_category_word(COMPL_CMD, name); | |
57 } | |
58 | |
59 // cmd_init() | |
60 // ... | |
61 void cmd_init(void) | |
62 { | |
63 guint cflags[4]; | |
64 | |
65 //cmd_add("add"); | |
66 //cmd_add("clear"); | |
67 //cmd_add("del"); | |
68 //cmd_add("group"); | |
69 //cmd_add("info"); | |
70 //cmd_add("move"); | |
71 //cmd_add("nick"); | |
72 cmd_add("quit", "Exit the software", 0, 0, NULL); | |
73 //cmd_add("rename"); | |
74 //cmd_add("request_auth"); | |
75 cmd_add("say", "Say something to the selected buddy", 0, 0, NULL); | |
76 //cmd_add("search"); | |
77 //cmd_add("send_auth"); | |
78 cmd_add("status", "Show or set your status", COMPL_STATUS, 0, NULL); | |
79 | |
80 // Status category | |
81 compl_add_category_word(COMPL_STATUS, "online"); | |
82 compl_add_category_word(COMPL_STATUS, "avail"); | |
83 compl_add_category_word(COMPL_STATUS, "invisible"); | |
84 compl_add_category_word(COMPL_STATUS, "free"); | |
85 compl_add_category_word(COMPL_STATUS, "dnd"); | |
86 compl_add_category_word(COMPL_STATUS, "busy"); | |
87 compl_add_category_word(COMPL_STATUS, "notavail"); | |
88 compl_add_category_word(COMPL_STATUS, "away"); | |
89 } | |
38 | 90 |
39 // send_message(msg) | 91 // send_message(msg) |
40 // Write the message in the buddy's window and send the message on | 92 // Write the message in the buddy's window and send the message on |
41 // the network. | 93 // the network. |
42 void send_message(char *msg) | 94 void send_message(char *msg) |