Mercurial > hg
comparison mcabber/src/commands.c @ 1187:16abe7ec3056
Fix a conflict between verbatim multiline mode and the key binding system
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 20 Apr 2007 17:14:38 +0200 |
parents | 807815928754 |
children | be06bbe7e449 |
comparison
equal
deleted
inserted
replaced
1186:0158bd8ca9d6 | 1187:16abe7ec3056 |
---|---|
353 hk_message_out(bjid, NULL, 0, hmsg, crypted); | 353 hk_message_out(bjid, NULL, 0, hmsg, crypted); |
354 if (hmsg != msg) g_free(hmsg); | 354 if (hmsg != msg) g_free(hmsg); |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 // process_command(line) | 358 // process_command(line, iscmd) |
359 // Process a command line. | 359 // Process a command line. |
360 // If iscmd is TRUE, process the command even if verbatim mmode is set; | |
361 // it is intended to be used for key bindings. | |
360 // Return 255 if this is the /quit command, and 0 for the other commands. | 362 // Return 255 if this is the /quit command, and 0 for the other commands. |
361 int process_command(char *line) | 363 int process_command(char *line, guint iscmd) |
362 { | 364 { |
363 char *p; | 365 char *p; |
364 char *xpline; | 366 char *xpline; |
365 cmd *curcmd; | 367 cmd *curcmd; |
366 | 368 |
367 // We do alias expansion here | 369 // We do alias expansion here |
368 if (scr_get_multimode() != 2) | 370 if (iscmd || scr_get_multimode() != 2) |
369 xpline = expandalias(line); | 371 xpline = expandalias(line); |
370 else | 372 else |
371 xpline = line; // No expansion in verbatim multi-line mode | 373 xpline = line; // No expansion in verbatim multi-line mode |
372 | 374 |
373 // We want to have a copy | 375 // We want to have a copy |
379 ; | 381 ; |
380 for (p-- ; p>xpline && (*p == ' ') ; p--) | 382 for (p-- ; p>xpline && (*p == ' ') ; p--) |
381 *p = 0; | 383 *p = 0; |
382 | 384 |
383 // Command "quit"? | 385 // Command "quit"? |
384 if ((scr_get_multimode() != 2) | 386 if ((iscmd || scr_get_multimode() != 2) |
385 && (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) { | 387 && (!strncasecmp(xpline, mkcmdstr("quit"), strlen(mkcmdstr("quit"))))) { |
386 if (!xpline[5] || xpline[5] == ' ') { | 388 if (!xpline[5] || xpline[5] == ' ') { |
387 g_free(xpline); | 389 g_free(xpline); |
388 return 255; | 390 return 255; |
389 } | 391 } |
390 } | 392 } |
391 | 393 |
392 // If verbatim multi-line mode, we check if another /msay command is typed | 394 // If verbatim multi-line mode, we check if another /msay command is typed |
393 if ((scr_get_multimode() == 2) | 395 if (!iscmd && scr_get_multimode() == 2 |
394 && (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { | 396 && (strncasecmp(xpline, mkcmdstr("msay "), strlen(mkcmdstr("msay "))))) { |
395 // It isn't an /msay command | 397 // It isn't an /msay command |
396 scr_append_multiline(xpline); | 398 scr_append_multiline(xpline); |
397 g_free(xpline); | 399 g_free(xpline); |
398 return 0; | 400 return 0; |
453 else | 455 else |
454 do_say(line); | 456 do_say(line); |
455 return 0; | 457 return 0; |
456 } | 458 } |
457 | 459 |
458 /* It is (probably) a command -- except for verbatim multi-line mode */ | 460 /* It is _probably_ a command -- except for verbatim multi-line mode */ |
459 return process_command(line); | 461 return process_command(line, FALSE); |
460 } | 462 } |
461 | 463 |
462 // Helper routine for buffer item_{lock,unlock} | 464 // Helper routine for buffer item_{lock,unlock} |
463 static void roster_buddylock(char *bjid, bool lock) | 465 static void roster_buddylock(char *bjid, bool lock) |
464 { | 466 { |