lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV [patch] New feature: the current document URL editing


From: Tomasz J. Cholewo
Subject: LYNX-DEV [patch] New feature: the current document URL editing
Date: Sun, 9 Feb 1997 14:39:51 -0500

Bela Lubkin wrote:

> I've been thinking for a while that I'd like to be able to hit "g",
> then hit some special key which causes it to enter the current
> document URL into the line editor buffer.

I agree that this is a more general concept, though I probably will use
it for making URL's shorter anyway.

The following patch (against the Feb 8 prerelease) causes that after 'g'
the arrow down key rotates first through the current document URL and
then through history entries.  As a result after pressing the arrow down
for the first time the user can edit the current URL.  Behavior of arrow
up key is not changed.

The same memory leak as in the previous version of this patch is also
corrected.

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        Sun Feb  9 13:59:37 1997
@@ -285,6 +285,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    Thu Feb  6 16:34:00 1997
+++ lynx2-7-work/src/LYMainLoop.c       Sun Feb  9 13:59:37 1997
@@ -2196,7 +2196,7 @@
            if (!strncasecomp(user_input_buffer, "lynxexec:", 9) ||
                !strncasecomp(user_input_buffer, "lynxprog:", 9)) {
                /*
-                *  The original implementions of these schemes expected
+                *  The original implementations of these schemes expected
                 *  white space without hex escaping, and did not check
                 *  for hex escaping, so we'll continue to support that,
                 *  until that code is redone in conformance with SGML
@@ -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) ||
@@ -2795,8 +2779,9 @@
                             *  Wasn't a ~user URL so guess address@hidden - FM
                             */
                            StrAllocCopy(address, "mailto:WebMaster@";);
-                       StrAllocCat(address,
-                                   HTParse(curdoc.address, "", PARSE_HOST));
+                        cp = HTParse(curdoc.address, "", PARSE_HOST);
+                       StrAllocCat(address, cp);
+                        FREE(cp);
                        _user_message(NO_OWNER_USE, address);
                        c = LYgetch();
                        if (TOUPPER(c) == 'Y') {
;
; 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]