mcabber/src/commands.c
changeset 260 33e1a05864a6
parent 244 5f8b529412bd
child 262 ab6f83a82811
equal deleted inserted replaced
259:594e73bc9610 260:33e1a05864a6
   122 
   122 
   123   // Multi-line (msay) category
   123   // Multi-line (msay) category
   124   compl_add_category_word(COMPL_MULTILINE, "abort");
   124   compl_add_category_word(COMPL_MULTILINE, "abort");
   125   compl_add_category_word(COMPL_MULTILINE, "begin");
   125   compl_add_category_word(COMPL_MULTILINE, "begin");
   126   compl_add_category_word(COMPL_MULTILINE, "send");
   126   compl_add_category_word(COMPL_MULTILINE, "send");
       
   127   compl_add_category_word(COMPL_MULTILINE, "verbatim");
   127 }
   128 }
   128 
   129 
   129 //  cmd_get
   130 //  cmd_get
   130 // Finds command in the command list structure.
   131 // Finds command in the command list structure.
   131 // Returns a pointer to the cmd entry, or NULL if command not found.
   132 // Returns a pointer to the cmd entry, or NULL if command not found.
   201     }
   202     }
   202     return 0;
   203     return 0;
   203   }
   204   }
   204 
   205 
   205   if (*line != '/') {
   206   if (*line != '/') {
       
   207     // This isn't a command
   206     if (scr_get_multimode())
   208     if (scr_get_multimode())
   207       scr_append_multiline(line);
   209       scr_append_multiline(line);
   208     else
   210     else
   209       do_say(line);
   211       do_say(line);
   210     return 0;
   212     return 0;
   216     ;
   218     ;
   217   for (p-- ; p>line && (*p == ' ') ; p--)
   219   for (p-- ; p>line && (*p == ' ') ; p--)
   218     *p = 0;
   220     *p = 0;
   219 
   221 
   220   // Command "quit"?
   222   // Command "quit"?
   221   if (!strncasecmp(line, "/quit", 5))
   223   if ((!strncasecmp(line, "/quit", 5)) && (scr_get_multimode() != 2) )
   222     if (!line[5] || line[5] == ' ')
   224     if (!line[5] || line[5] == ' ')
   223       return 255;
   225       return 255;
       
   226 
       
   227   // If verbatim multi-line mode, we check if another /msay command is typed
       
   228   if ((scr_get_multimode() == 2) && (strncasecmp(line, "/msay ", 6))) {
       
   229     // It isn't an /msay command
       
   230     scr_append_multiline(line);
       
   231     return 0;
       
   232   }
   224 
   233 
   225   // Commands handling
   234   // Commands handling
   226   curcmd = cmd_get(line);
   235   curcmd = cmd_get(line);
   227 
   236 
   228   if (!curcmd) {
   237   if (!curcmd) {
   399   send_message(arg);
   408   send_message(arg);
   400 }
   409 }
   401 
   410 
   402 void do_msay(char *arg)
   411 void do_msay(char *arg)
   403 {
   412 {
   404   /* begin abort send */
   413   /* Parameters: begin verbatim abort send */
   405   gpointer bud;
   414   gpointer bud;
   406 
   415 
   407   if (!strcasecmp(arg, "abort")) {
   416   if (!strcasecmp(arg, "abort")) {
   408     scr_set_multimode(FALSE);
   417     scr_set_multimode(FALSE);
   409     return;
   418     return;
   410   } else if (!strcasecmp(arg, "begin")) {
   419   } else if ((!strcasecmp(arg, "begin")) || (!strcasecmp(arg, "verbatim"))) {
   411     scr_set_multimode(TRUE);
   420     if (!strcasecmp(arg, "verbatim"))
       
   421       scr_set_multimode(2);
       
   422     else
       
   423       scr_set_multimode(1);
       
   424 
   412     scr_LogPrint("Entered multi-line message mode.");
   425     scr_LogPrint("Entered multi-line message mode.");
   413     scr_LogPrint("Select a buddy and use \"/msay send\" "
   426     scr_LogPrint("Select a buddy and use \"/msay send\" "
   414                  "when your message is ready.");
   427                  "when your message is ready.");
   415     return;
   428     return;
   416   } else if (*arg == 0) {
   429   } else if (*arg == 0) {