* Applied "multi editor" patch supplied by georbit
authorArt Cancro <ajc@citadel.org>
Thu, 13 Feb 2003 20:13:51 +0000 (20:13 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 13 Feb 2003 20:13:51 +0000 (20:13 +0000)
citadel/ChangeLog
citadel/citadel.c
citadel/citadel.h
citadel/citadel.rc
citadel/citadel_decls.h
citadel/commands.c
citadel/docs/citadel.html
citadel/messages.c
citadel/rooms.c
citadel/routines2.c

index 53b689c4d0e1db996ab3ad515889b9f4cb13f934..796c53d3e236cff6636e6f721283cf5f1426b522 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 601.130  2003/02/13 20:13:51  ajc
+ * Applied "multi editor" patch supplied by georbit
+
  Revision 601.129  2003/02/12 04:51:44  ajc
  * More docs update
 
@@ -4459,4 +4462,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 2e28ef9d9894a567f17163278c568ea0de14c1ff..40e8e3d38b764a0d8166960b891146aa31e2e99c 100644 (file)
@@ -65,7 +65,7 @@ struct march *march = NULL;
 char temp[PATH_MAX];           /* Name of general temp file */
 char temp2[PATH_MAX];          /* Name of general temp file */
 char tempdir[PATH_MAX];                /* Name of general temp dir */
-char editor_path[SIZ];         /* path to external editor */
+char editor_paths[MAX_EDITORS][SIZ];   /* paths to external editors */
 char printcmd[SIZ];            /* print command */
 int editor_pid = (-1);
 char fullname[USERNAME_SIZE];
@@ -1699,6 +1699,17 @@ NEWUSR:  if (strlen(rc_password) == 0) {
                                page_user(ipc);
                                break;
 
+                       default: /* allow some math on the command */
+                               /* commands 100... to 100+MAX_EDITORS-1 will
+                                  call the appropriate editor... in other
+                                  words, command numbers 100+ will match
+                                  the citadel.rc keys editor0, editor1, etc.*/
+                               if (mcmd >= 100 && mcmd < (100+MAX_EDITORS))
+                               {
+                                       /* entmsg mode >=2 select editor */
+                                       entmsg(ipc, 0, mcmd - 100 + 2);
+                                       break;
+                               }
                        }       /* end switch */
        } while (termn8 == 0);
 
index 74fb0bf9779fca9ec81349e0e6112cab965db9bb..5abb38919e1d74ccd5613300602c7327c3858c60 100644 (file)
@@ -68,6 +68,8 @@ extern "C" {
                                         */
                                         
 #define USERNAME_SIZE  64              /* The size of a username string */
+#define MAX_EDITORS    5               /* # of external editors supported */
+                                       /* MUST be at least 1 */
 
 /*
  * Message expiration policy stuff
index ef3704b1cccb9e3bba83c6900d91ada6196a146f..d5f1e8d54a9e23ca33ff200202051f8052f8619d 100644 (file)
@@ -27,7 +27,14 @@ fullscreen=no
 # messages.  If you want the external editor to be used by default, be sure
 # to reflect this in the command set below.
 #
-editor=pico
+# editor=pico
+
+# Or, you could have multiple editors available, like this:
+# ("editor" and "editor0" are the same internally)
+# You can go up to MAX_EDITORS number of editors (5 by default)
+# editor0=pico
+# editor1=vi
+# editor2=nano
 
 # If you define PRINTCMD, it will be a pipe through which messages are
 # printed when the user hits the <P>rint key after a message.
@@ -308,8 +315,15 @@ cmd=44,0,&.,&Enter,file using &Zmodem
 #
 cmd=41,0,&.,&Enter,re&Gistration
 cmd=4,0,&.,&Enter,&Message
+
+# If you have an external editor defined, it will appear on command 46.
 cmd=46,0,&.,&Enter,message with &Editor
-#
+
+# If you have multiple editors defined, they will appear on
+# commands 46, 101, 102, 103... up to MAX_EDITORS (5 by default)
+#cmd=101,0,&.,&Enter,message with &VI
+#cmd=102,0,&.,&Enter,message with &Nano
+
 cmd=59,0,&;,&Configure floor mode
 cmd=60,0,&;,&Goto floor:
 cmd=61,0,&;,&Skip to floor:
index edae28ae265cd9ea7f03a14efc655f0c455cba30..32bbf3a5e36b13a37c4a467ca66671beff6c0186 100644 (file)
@@ -7,7 +7,7 @@ extern char axlevel;
 extern char is_room_aide;
 extern unsigned userflags;
 extern char sigcaught;
-extern char editor_path[SIZ];
+extern char editor_paths[MAX_EDITORS][SIZ];
 extern char printcmd[SIZ];
 extern char have_xterm;
 extern char rc_username[USERNAME_SIZE];
index bb9d20cb90a13d0cd52654651cff7cd882a1e579..0232dec392a7a3570cc76295d588c8c16e78ef46 100644 (file)
@@ -719,15 +719,18 @@ void load_command_set(void)
 {
        FILE *ccfile;
        char buf[1024];
+       char editor_key[100];
        struct citcmd *cptr;
        struct citcmd *lastcmd = NULL;
        int a, d;
        int b = 0;
+       int i;
 
 
        /* first, set up some defaults for non-required variables */
 
-       strcpy(editor_path, "");
+       for (i = 0; i < MAX_EDITORS; i++)
+               strcpy(editor_paths[i], "");
        strcpy(printcmd, "");
        strcpy(rc_username, "");
        strcpy(rc_password, "");
@@ -804,7 +807,14 @@ void load_command_set(void)
 #endif
 
                if (!strncasecmp(buf, "editor=", 7))
-                       strcpy(editor_path, &buf[7]);
+                       strcpy(editor_paths[0], &buf[7]);
+
+               for (i = 0; i < MAX_EDITORS; i++)
+               {
+                       sprintf(editor_key, "editor%d=", i);
+                       if (!strncasecmp(buf, editor_key, strlen(editor_key)))
+                               strcpy(editor_paths[i], &buf[strlen(editor_key)]);
+               }
 
                if (!strncasecmp(buf, "printcmd=", 9))
                        strcpy(printcmd, &buf[9]);
index d73a617b03752707b617b86aef0c478dd2006a78..23c1c1b389a06f8ed2d6d0dbda124087a3047190 100644 (file)
@@ -44,6 +44,12 @@ access,     and   others<br>
                     <td valign="top"><i>cosmetics, additional commands<br>
                     </i></td>
                   </tr>
+                  <tr>
+                    <td valign="top">Nick Georbit<br>
+                    </td>
+                    <td valign="top"><i>additional client features<br>
+                    </i></td>
+                  </tr>
                   <tr>
                     <td valign="top">Michael Hampton<br>
                     </td>
index e222b00120bf71ccaf727b0b27e3537d83ff024f..4b0c777f50ab862a282bc79321c339aebade4e93 100644 (file)
@@ -81,7 +81,6 @@ extern char fullname[];
 extern char axlevel;
 extern unsigned userflags;
 extern char sigcaught;
-extern char editor_path[];
 extern char printcmd[];
 extern int rc_allow_attachments;
 extern int rc_display_message_numbers;
@@ -733,14 +732,21 @@ int client_make_message(CtdlIPC *ipc,
        long beg;
        char datestr[SIZ];
        char header[SIZ];
+       char *editor_path = NULL;
        int cksum = 0;
 
-       if (mode == 2)
-               if (strlen(editor_path) == 0) {
+       if (mode >= 2)
+       {
+               if((mode-2) < MAX_EDITORS && strlen(editor_paths[mode-2]) > 0) {
+                       editor_path = editor_paths[mode-2];
+               } else if (strlen(editor_paths[0]) > 0) {
+                       editor_path = editor_paths[0];
+               } else {
                        err_printf
                            ("*** No editor available, using built-in editor\n");
                        mode = 0;
                }
+       }
 
        fmt_date(datestr, sizeof datestr, time(NULL), 0);
        header[0] = 0;
@@ -825,6 +831,7 @@ ME1:        switch (mode) {
                break;
 
        case 2:
+       default:        /* allow 2+ modes */
                e_ex_code = 1;  /* start with a failed exit code */
                editor_pid = fork();
                cksum = file_checksum(filename);
@@ -850,7 +857,7 @@ ME1:        switch (mode) {
                break;
        }
 
-MECR:  if (mode == 2) {
+MECR:  if (mode >= 2) {
                if (file_checksum(filename) == cksum) {
                        err_printf("*** Aborted message.\n");
                        e_ex_code = 1;
index e612b7dd0d44bcb4dc9bdabf1043d167d609286b..d107eceb447f316d38d9b5dc5676eb0dbcca85ae 100644 (file)
@@ -47,7 +47,6 @@ extern char room_name[];
 extern char temp[];
 extern char tempdir[];
 extern int editor_pid;
-extern char editor_path[];
 extern int screenwidth;
 extern int screenheight;
 extern char fullname[];
@@ -1037,7 +1036,7 @@ void do_edit(CtdlIPC *ipc,
        char cmd[SIZ];
        int b, cksum, editor_exit;
 
-       if (strlen(editor_path) == 0) {
+       if (strlen(editor_paths[0]) == 0) {
                scr_printf("Do you wish to re-enter %s? ", desc);
                if (yesno() == 0)
                        return;
@@ -1053,7 +1052,7 @@ void do_edit(CtdlIPC *ipc,
                return;
        }
 
-       if (strlen(editor_path) > 0) {
+       if (strlen(editor_paths[0]) > 0) {
                CtdlIPC_putline(ipc, read_cmd);
                CtdlIPC_getline(ipc, cmd);
                if (cmd[0] == '1') {
@@ -1067,7 +1066,7 @@ void do_edit(CtdlIPC *ipc,
 
        cksum = file_checksum(temp);
 
-       if (strlen(editor_path) > 0) {
+       if (strlen(editor_paths[0]) > 0) {
                char tmp[SIZ];
 
                snprintf(tmp, sizeof tmp, "WINDOW_TITLE=%s", desc);
@@ -1077,7 +1076,7 @@ void do_edit(CtdlIPC *ipc,
                editor_pid = fork();
                if (editor_pid == 0) {
                        chmod(temp, 0600);
-                       execlp(editor_path, editor_path, temp, NULL);
+                       execlp(editor_paths[0], editor_paths[0], temp, NULL);
                        exit(1);
                }
                if (editor_pid > 0)
@@ -1086,7 +1085,7 @@ void do_edit(CtdlIPC *ipc,
                                b = ka_wait(&editor_exit);
                        } while ((b != editor_pid) && (b >= 0));
                editor_pid = (-1);
-               scr_printf("Executed %s\n", editor_path);
+               scr_printf("Executed %s\n", editor_paths[0]);
                sttybbs(0);
                screen_set();
        } else {
index 30aaa37955e778344f0dc39f0f568982ed72dd16..10f852340f411e088b31ad8dedf4f9eef26981b1 100644 (file)
@@ -917,7 +917,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
        FILE *tempfp;
        FILE *changefp;
 
-       if (strlen(editor_path) == 0) {
+       if (strlen(editor_paths[0]) == 0) {
                scr_printf("You must have an external editor configured in"
                        " order to use this function.\n");
                return;
@@ -958,7 +958,7 @@ void network_config_management(CtdlIPC *ipc, char *entrytype, char *comment)
        if (editor_pid == 0) {
                chmod(filename, 0600);
                putenv("WINDOW_TITLE=Network configuration");
-               execlp(editor_path, editor_path, filename, NULL);
+               execlp(editor_paths[0], editor_paths[0], filename, NULL);
                exit(1);
        }
        if (editor_pid > 0) {