Mercurial > hg
comparison mcabber/src/commands.c @ 238:8e30b2bb380e
[/trunk] Changeset 251 by mikael
* Add /msay command (multi-line messages)
author | mikael |
---|---|
date | Sat, 11 Jun 2005 19:12:25 +0000 |
parents | 72fd1273f2b7 |
children | 723433a677f0 |
comparison
equal
deleted
inserted
replaced
237:c8df64f43625 | 238:8e30b2bb380e |
---|---|
36 void do_status(char *arg); | 36 void do_status(char *arg); |
37 void do_add(char *arg); | 37 void do_add(char *arg); |
38 void do_del(char *arg); | 38 void do_del(char *arg); |
39 void do_group(char *arg); | 39 void do_group(char *arg); |
40 void do_say(char *arg); | 40 void do_say(char *arg); |
41 void do_msay(char *arg); | |
41 void do_buffer(char *arg); | 42 void do_buffer(char *arg); |
42 void do_clear(char *arg); | 43 void do_clear(char *arg); |
43 void do_info(char *arg); | 44 void do_info(char *arg); |
44 void do_rename(char *arg); | 45 void do_rename(char *arg); |
45 void do_move(char *arg); | 46 void do_move(char *arg); |
76 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); | 77 cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group); |
77 cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); | 78 cmd_add("help", "Display some help", COMPL_CMD, 0, NULL); |
78 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); | 79 cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info); |
79 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, | 80 cmd_add("move", "Move the current buddy to another group", COMPL_GROUPNAME, |
80 0, &do_move); | 81 0, &do_move); |
82 cmd_add("msay", "Send a multi-lines message to the selected buddy", | |
83 COMPL_MULTILINE, 0, &do_msay); | |
81 //cmd_add("nick"); | 84 //cmd_add("nick"); |
82 cmd_add("quit", "Exit the software", 0, 0, NULL); | 85 cmd_add("quit", "Exit the software", 0, 0, NULL); |
83 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); | 86 cmd_add("rename", "Rename the current buddy", 0, 0, &do_rename); |
84 //cmd_add("request_auth"); | 87 //cmd_add("request_auth"); |
85 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, | 88 cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, |
114 | 117 |
115 // Group category | 118 // Group category |
116 compl_add_category_word(COMPL_GROUP, "expand"); | 119 compl_add_category_word(COMPL_GROUP, "expand"); |
117 compl_add_category_word(COMPL_GROUP, "shrink"); | 120 compl_add_category_word(COMPL_GROUP, "shrink"); |
118 compl_add_category_word(COMPL_GROUP, "toggle"); | 121 compl_add_category_word(COMPL_GROUP, "toggle"); |
122 | |
123 // Multi-line (msay) category | |
124 compl_add_category_word(COMPL_MULTILINE, "abort"); | |
125 compl_add_category_word(COMPL_MULTILINE, "begin"); | |
126 compl_add_category_word(COMPL_MULTILINE, "send"); | |
119 } | 127 } |
120 | 128 |
121 // cmd_get | 129 // cmd_get |
122 // Finds command in the command list structure. | 130 // Finds command in the command list structure. |
123 // Returns a pointer to the cmd entry, or NULL if command not found. | 131 // Returns a pointer to the cmd entry, or NULL if command not found. |
124 cmd *cmd_get(char *command) | 132 cmd *cmd_get(const char *command) |
125 { | 133 { |
126 char *p1, *p2; | 134 const char *p1, *p2; |
127 char *com; | 135 char *com; |
128 GSList *sl_com; | 136 GSList *sl_com; |
129 // Ignore leading '/' | 137 // Ignore leading '/' |
130 for (p1 = command ; *p1 == '/' ; p1++) | 138 for (p1 = command ; *p1 == '/' ; p1++) |
131 ; | 139 ; |
148 } | 156 } |
149 | 157 |
150 // send_message(msg) | 158 // send_message(msg) |
151 // Write the message in the buddy's window and send the message on | 159 // Write the message in the buddy's window and send the message on |
152 // the network. | 160 // the network. |
153 void send_message(char *msg) | 161 void send_message(const char *msg) |
154 { | 162 { |
155 const char *jid; | 163 const char *jid; |
156 | 164 |
157 if (!current_buddy) { | 165 if (!current_buddy) { |
158 scr_LogPrint("No buddy currently selected."); | 166 scr_LogPrint("No buddy currently selected."); |
180 { | 188 { |
181 char *p; | 189 char *p; |
182 cmd *curcmd; | 190 cmd *curcmd; |
183 | 191 |
184 if (!*line) { // User only pressed enter | 192 if (!*line) { // User only pressed enter |
193 if (scr_get_multimode()) { | |
194 scr_append_multiline(""); | |
195 return 0; | |
196 } | |
185 if (current_buddy) { | 197 if (current_buddy) { |
186 scr_set_chatmode(TRUE); | 198 scr_set_chatmode(TRUE); |
187 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); | 199 buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE); |
188 scr_ShowBuddyWindow(); | 200 scr_ShowBuddyWindow(); |
189 } | 201 } |
190 return 0; | 202 return 0; |
191 } | 203 } |
192 | 204 |
193 if (*line != '/') { | 205 if (*line != '/') { |
194 do_say(line); | 206 if (scr_get_multimode()) |
207 scr_append_multiline(line); | |
208 else | |
209 do_say(line); | |
195 return 0; | 210 return 0; |
196 } | 211 } |
197 | 212 |
198 /* It is a command */ | 213 /* It is a command */ |
199 // Remove trailing spaces: | 214 // Remove trailing spaces: |
372 | 387 |
373 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | 388 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); |
374 send_message(arg); | 389 send_message(arg); |
375 } | 390 } |
376 | 391 |
392 void do_msay(char *arg) | |
393 { | |
394 /* begin abort send */ | |
395 gpointer bud; | |
396 | |
397 if (!strcasecmp(arg, "abort")) { | |
398 scr_set_multimode(FALSE); | |
399 return; | |
400 } else if (!strcasecmp(arg, "begin")) { | |
401 scr_set_multimode(TRUE); | |
402 scr_LogPrint("Entered multi-line message mode."); | |
403 scr_LogPrint("Select a buddy and use \"/msay send\" " | |
404 "when your message is ready."); | |
405 return; | |
406 } else if (*arg == 0) { | |
407 scr_LogPrint("Please read the manual before using the /msay command."); | |
408 scr_LogPrint("(Use /msay begin to enter multi-line mode...)"); | |
409 return; | |
410 } else if (strcasecmp(arg, "send")) { | |
411 scr_LogPrint("Unrecognized parameter!"); | |
412 return; | |
413 } | |
414 | |
415 // send command | |
416 | |
417 if (!scr_get_multimode()) { | |
418 scr_LogPrint("No message to send. Use \"/msay begin\" first."); | |
419 return; | |
420 } | |
421 | |
422 scr_set_chatmode(TRUE); | |
423 | |
424 if (!current_buddy) { | |
425 scr_LogPrint("Who are you talking to??"); | |
426 return; | |
427 } | |
428 | |
429 bud = BUDDATA(current_buddy); | |
430 if (!(buddy_gettype(bud) & ROSTER_TYPE_USER)) { | |
431 scr_LogPrint("This is not a user"); | |
432 return; | |
433 } | |
434 | |
435 buddy_setflags(bud, ROSTER_FLAG_LOCK, TRUE); | |
436 send_message(scr_get_multiline()); | |
437 scr_set_multimode(FALSE); | |
438 } | |
439 | |
377 void do_buffer(char *arg) | 440 void do_buffer(char *arg) |
378 { | 441 { |
379 if (!strcasecmp(arg, "top")) { | 442 if (!strcasecmp(arg, "top")) { |
380 scr_BufferTop(); | 443 scr_BufferTop(); |
381 } else if (!strcasecmp(arg, "bottom")) { | 444 } else if (!strcasecmp(arg, "bottom")) { |