lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV [patch] New version of current URL editing


From: Tomasz J. Cholewo
Subject: LYNX-DEV [patch] New version of current URL editing
Date: Mon, 10 Feb 1997 00:37:06 -0500

David Combs wrote:

> The obvious response: why not simply "..", with "normal" g?

It is not so obvious as normally '..' would be interpreted by starting
DIRED in the directory below current.  It doesn't look likely to be used
too often, though, so I decided to implement it this way.

The following patch (against the Feb 9 prerelease) replaces both my
previous patches and allows current URL editing by pressing arrow down
after 'g' and going to the "parent" document by typing ".." after 'g'.

Thanks for the idea,
  Tom
=========== CUT HERE ==============
diff -dbur lynx2-7/LYMessages_en.h lynx2-7-work/LYMessages_en.h
--- lynx2-7/LYMessages_en.h     Sun Feb  9 04:42:42 1997
+++ lynx2-7-work/LYMessages_en.h        Mon Feb 10 00:21:54 1997
@@ -249,6 +249,7 @@
 #define ALREADY_AT_END "You are already at the end of this document."
 #define ALREADY_AT_BEGIN "You are already at the beginning of this document."
 #define ALREADY_AT_FIRST "You are already at the first document"
+#define ALREADY_AT_ROOT "You are already at the root document"
 #define NO_LINKS_ABOVE "There are no links above this line of the document."
 #define NO_LINKS_BELOW "There are no links below this line of the document."
 #define MAXLEN_REACHED_DEL_OR_MOV \
@@ -285,6 +286,7 @@
 #define GOTO_TN3270_DISALLOWED "You are not allowed to goto \"tn3270:\" URLs"
 #define GOTO_WAIS_DISALLOWED "You are not allowed to goto \"wais:\" URLs"
 #define URL_TO_OPEN "URL to open: "
+#define EDIT_CURRENT_URL "Edit the current document URL: "
 #define EDIT_CURRENT_GOTO "Edit the current Goto URL: "
 #define EDIT_THE_PREV_GOTO "Edit the previous Goto URL: "
 #define EDIT_A_PREV_GOTO "Edit a previous Goto URL: "
diff -dbur lynx2-7/src/LYMainLoop.c lynx2-7-work/src/LYMainLoop.c
--- lynx2-7/src/LYMainLoop.c    Sun Feb  9 16:50:02 1997
+++ lynx2-7-work/src/LYMainLoop.c       Mon Feb 10 00:20:47 1997
@@ -2207,6 +2207,7 @@
            } else {
                collapse_spaces(user_input_buffer);
            }
+
            if (*user_input_buffer == '\0' &&
                !(recall && (ch == UPARROW || ch == DNARROW))) {
                strcpy(user_input_buffer, temp);
@@ -2215,7 +2216,9 @@
                sleep(InfoSecs);
                break;
            }
-           if (recall && ch == UPARROW) {
+
+           if (recall && (ch == UPARROW || ch == DNARROW)) {
+                if (ch == UPARROW) {
                if (FirstURLRecall) {
                    /*
                     *  Use last URL in the list. - FM
@@ -2227,61 +2230,42 @@
                     *  Go back to the previous URL in the list. - FM
                     */
                    URLNum++;
-               }
                if (URLNum >= URLTotal)
                    /*
                     *  Roll around to the last URL in the list. - FM
                     */
                    URLNum = 0;
-               if ((cp = (char *)HTList_objectAt(Goto_URLs,
-                                                 URLNum)) != NULL) {
-                   strcpy(user_input_buffer, cp);
-                   if (goto_buffer && *temp &&
-                       !strcmp(temp, user_input_buffer)) {
-                       _statusline(EDIT_CURRENT_GOTO);
-                   } else if ((goto_buffer && URLTotal == 2) ||
-                              (!goto_buffer && URLTotal == 1)) {
-                       _statusline(EDIT_THE_PREV_GOTO);
-                   } else {
-                       _statusline(EDIT_A_PREV_GOTO);
-                   }
-                   if ((ch = LYgetstr(user_input_buffer, VISIBLE,
-                                     sizeof(user_input_buffer),
-                                     recall)) < 0) {
-                       /*
-                        *  User cancelled the Goto via ^G.
-                        *  Restore user_input_buffer and break. - FM
-                        */
-                       strcpy(user_input_buffer, temp);
-                       FREE(temp);
-                       _statusline(CANCELLED);
-                       sleep(InfoSecs);
-                       break;
-                   }
-                   goto check_recall;
                }
-           } else if (recall && ch == DNARROW) {
+                } else if (ch == DNARROW) {
                if (FirstURLRecall) {
                    /*
                     *  Use the first URL in the list. - FM
                     */
                    FirstURLRecall = FALSE;
-                   URLNum = URLTotal - 1;
+                        URLNum = URLTotal;      /* index |URLTotal| represents 
the current URL which is not stored in |Goto_URLs| - tjc */
                } else {
                    /*
                     *  Advance to the next URL in the list. - FM
                     */
                    URLNum--;
-               }
                if (URLNum < 0)
                    /*
-                    *  Roll around to the first URL in the list. - FM
+                            *  Roll around to the current URL in the list. - FM
                     */
-                   URLNum = URLTotal - 1;
-               if ((cp=(char *)HTList_objectAt(Goto_URLs,
-                                                   URLNum)) != NULL) {
+                            URLNum = URLTotal;
+                    }
+                }
+
+                if (URLNum >= URLTotal)      /* current URL - tjc */
+                    cp = curdoc.address;
+                else
+                    cp = (char *)HTList_objectAt(Goto_URLs, URLNum);
+
+                if (cp != NULL) {
                    strcpy(user_input_buffer, cp);
-                   if (goto_buffer && *temp &&
+                    if (URLNum >= URLTotal) {
+                       _statusline(EDIT_CURRENT_URL);
+                   } else if (goto_buffer && *temp &&
                        !strcmp(temp, user_input_buffer)) {
                        _statusline(EDIT_CURRENT_GOTO);
                    } else if ((goto_buffer && URLTotal == 2) ||
@@ -2307,6 +2291,32 @@
                }
            }

+           if (!strcmp (user_input_buffer, "..")) {
+                char *address = HTParse(curdoc.address, "", PARSE_ACCESS |
+                                        PARSE_HOST | PARSE_PUNCTUATION);
+                char *path = HTParse(curdoc.address, "", PARSE_PATH | 
PARSE_PUNCTUATION); /* ignore anchor */
+
+                if (path != NULL) {
+                    if (strlen(path) > 1) {
+                        if (path[strlen(path)-1] == '/')
+                            path[strlen(path)-1] = '\0'; /* remove trailing 
slash */
+                        if ((cp = strrchr(path, '/')) != NULL)
+                            *(cp + 1) = '\0';   /* leave slash */
+                        else
+                            path[0] = '\0';     /* at root */
+                        StrAllocCat(address, path);
+                        FREE(path);
+                    } else {                    /* we are at the root already 
*/
+                        _statusline(ALREADY_AT_ROOT);
+                        sleep(MessageSecs);
+                        FREE(path);
+                        break;
+                    }
+                }
+                sprintf(user_input_buffer, "%.*s",
+                        (sizeof(user_input_buffer) - 1), address);
+                FREE(address);
+            } else {
            /*
             *  If its not a URL then make it one.
             */
@@ -2316,6 +2326,8 @@
            sprintf(user_input_buffer, "%.*s",
                    (sizeof(user_input_buffer) - 1), temp);
            FREE(temp);
+            }
+
            if ((no_file_url || no_goto_file) &&
                !strncmp(user_input_buffer,"file:",5)) {
                 _statusline(GOTO_FILE_DISALLOWED);
;
; To UNSUBSCRIBE:  Send a mail message to address@hidden
;                  with "unsubscribe lynx-dev" (without the
;                  quotation marks) on a line by itself.
;

reply via email to

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