lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev [PATCH]


From: Vlad Harchev
Subject: lynx-dev [PATCH]
Date: Thu, 22 Jun 2000 03:34:54 +0500 (SAMST)

 Here is a patch that allows user to trigger execution of commands declared
via EXTERNAL setting. To allow this, one more field to the syntax of the value
of EXTERNAL setting is added; if that field is TRUE, then activating (using 
arrow-right for example) the link with URL matching the one specified by 
'prefix' field will be equal to pressing '.' on it.
 Personally I use it for invoking 'links' browser for ftp links - it caches
ftp connections so it doesn't reconnect when directory is changed. Here is
a setting I use:
EXTERNAL:ftp://:links %s:TRUE:TRUE

 Seems Eduardo wanted this functionality.

 Best regards,
  -Vlad

diff -ru lynx2.8.4dev3-2/lynx.cfg lynx2.8.4dev3/lynx.cfg
--- lynx2.8.4dev3-2/lynx.cfg    Tue Jun 20 22:43:19 2000
+++ lynx2.8.4dev3/lynx.cfg      Thu Jun 22 03:10:28 2000
@@ -2802,11 +2802,12 @@
 #
 # Restrictions can be imposed using -restrictions=externals at the Lynx
 # command line.  This will disallow all EXTERNAL lines in lynx.cfg that
-# end in FALSE.  TRUE lines will still function.
+# have FALSE in 3rd field (not counting the name of the setting). TRUE lines 
+# will still function.
 #
 # The lynx.cfg line is as follows:
 #
-# EXTERNAL:<url>:<command> %s:<norestriction>
+# EXTERNAL:<url>:<command> %s:<norestriction>:<allow_for_activate>
 #
 # <url> Any given URL.  This can be normal ones like ftp or http or it
 # can be one made up like mymail.
@@ -2820,6 +2821,12 @@
 # for certain externals to be enabled while restricting others.  TRUE means
 # a command will still function while Lynx is restricted.  WB
 #
+# <allow_for_activate> Setting this to TRUE allows the use of this command
+# not only when EXTERN key is pressed, but also when ACTIVATE command is 
invoked
+# (i.e activating the link with the given prefix will be equivalient to 
pressing
+# EXTERN key on it). If this component of the line is absent, then FALSE is
+# assumed.
+# 
 # For invoking the command use the EXTERN key.  By default it is mapped
 # to '.' (if the feature is enabled), see the KEYMAP section above.
 #
diff -ru lynx2.8.4dev3-2/src/LYExtern.c lynx2.8.4dev3/src/LYExtern.c
--- lynx2.8.4dev3-2/src/LYExtern.c      Mon Mar 27 08:14:00 2000
+++ lynx2.8.4dev3/src/LYExtern.c        Thu Jun 22 03:04:11 2000
@@ -170,7 +170,9 @@
     HTEndParam(result, fmt, 1);
 }
 
-void run_external ARGS1(char *, c)
+BOOL run_external ARGS2(
+    char *,    c,
+    BOOL,      only_overriders)
 {
 #ifdef WIN_EX
     HANDLE handle;
@@ -182,9 +184,10 @@
 #endif
     char *cmdbuf = NULL;
     lynx_html_item_type *externals2 = 0;
+    int found = 0;
 
     if (externals == NULL)
-       return;
+       return 0;
 
 #ifdef WIN_EX                  /* 1998/01/26 (Mon) 09:16:13 */
     if (c == NULL) {
@@ -201,12 +204,14 @@
        CTRACE((tfp, "EXTERNAL: '%s' <==> '%s'\n", externals2->name, c));
 #endif
        if (externals2->command != 0
-         && !strncasecomp(externals2->name, c, strlen(externals2->name)))
+         && !strncasecomp(externals2->name, c, strlen(externals2->name)) &&
+         (only_overriders ? externals2->override_primary_action : 1))
        {
-           if (no_externals && !externals2->always_enabled) {
+           if (no_externals && !externals2->always_enabled && 
!only_overriders) {
                HTUserMsg(EXTERNALS_DISABLED);
                break;
            }
+           ++found;
            /*  Too dangerous to leave any URL that may come along unquoted.
             *  They often contain '&', ';', and '?' chars, and who knows
             *  what else may occur.
@@ -371,6 +376,6 @@
     } /* end-for */
 
     FREE(cmdbuf);
-    return;
+    return found;
 }
 #endif /* USE_EXTERNALS */
diff -ru lynx2.8.4dev3-2/src/LYExtern.h lynx2.8.4dev3/src/LYExtern.h
--- lynx2.8.4dev3-2/src/LYExtern.h      Tue Feb 15 08:07:39 2000
+++ lynx2.8.4dev3/src/LYExtern.h        Thu Jun 22 02:47:14 2000
@@ -5,7 +5,8 @@
 #include <LYStructs.h>
 #endif /* LYSTRUCTS_H */
 
-void run_external PARAMS((char * c));
+/*returns TRUE if something matching was executed*/
+BOOL run_external PARAMS((char * c,BOOL only_overriders));
 char *string_short PARAMS((char * str, int cut_pos));
 
 #ifdef WIN_EX
diff -ru lynx2.8.4dev3-2/src/LYMainLoop.c lynx2.8.4dev3/src/LYMainLoop.c
--- lynx2.8.4dev3-2/src/LYMainLoop.c    Mon Jun 12 15:26:41 2000
+++ lynx2.8.4dev3/src/LYMainLoop.c      Thu Jun 22 02:55:33 2000
@@ -1300,6 +1300,10 @@
                    reloading = FALSE;
                    return 0;
                }
+               
+           if (run_external(links[curdoc.link].lname,TRUE))            
+               return 0;
+               
            /*
             *  Follow a normal link or anchor.
             */
@@ -2647,7 +2651,7 @@
 {
     if ((nlinks > 0) && (links[curdoc.link].lname != NULL))
     {
-       run_external(links[curdoc.link].lname);
+       run_external(links[curdoc.link].lname,FALSE);
        *refresh_screen = TRUE;
     }
 }
diff -ru lynx2.8.4dev3-2/src/LYReadCFG.c lynx2.8.4dev3/src/LYReadCFG.c
--- lynx2.8.4dev3-2/src/LYReadCFG.c     Tue Jun 20 22:11:58 2000
+++ lynx2.8.4dev3/src/LYReadCFG.c       Thu Jun 22 02:44:49 2000
@@ -165,6 +165,7 @@
     cur_item->name = NULL;
     cur_item->command = NULL;
     cur_item->always_enabled = FALSE;
+    cur_item->override_primary_action = FALSE;
 
     /*
      * Find first unescaped colon and process fields
@@ -196,7 +197,13 @@
            remove_backslashes(cur_item->command);
        }
        if (*next_colon++) {
-           cur_item->always_enabled = is_true(next_colon);
+           colon = next_colon;
+           if (next_colon = strchr(colon,':'))
+               *next_colon++ = '\0';           
+           cur_item->always_enabled = is_true(colon);
+           if (next_colon) {
+               cur_item->override_primary_action = is_true(next_colon);
+           };
        }
     }
 }
diff -ru lynx2.8.4dev3-2/src/LYStructs.h lynx2.8.4dev3/src/LYStructs.h
--- lynx2.8.4dev3-2/src/LYStructs.h     Wed Dec  1 07:33:02 1999
+++ lynx2.8.4dev3/src/LYStructs.h       Thu Jun 22 02:38:18 2000
@@ -88,6 +88,13 @@
                                        * not to disable the printer
                                        * when the no_print option is on
                                        */
+    BOOL override_primary_action;      /* whether primary action will be
+                                       * overriden by this - e.g. this allows
+                                       * invoking user's MUA when mailto: link
+                                       * is activated using normal "activate"
+                                       * command. This field is only examined
+                                       * by code that handles EXTERNAL command.
+                                       */
 } lynx_html_item_type;
 
 /* for printer commands */


; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]