lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev short_url option (was Re: lynx2.8.3dev.5)


From: nsh
Subject: Re: lynx-dev short_url option (was Re: lynx2.8.3dev.5)
Date: Wed, 04 Aug 1999 23:18:59 +0900

Hi,

Short_url became more useful!  Furthermore...

In message <address@hidden>
        Subject: Re: lynx-dev short_url option (was Re: lynx2.8.3dev.5)
        "Eduardo Chappa L." <address@hidden> writes:

:) I think (now) that the character should be ".", and also, if at possible,
:) that it showuld be displayed with both preceding and following separators
:) displayed.  I.e. "/.../" should appear if possible in the place where a
:) part has been removed.  IMO this would make things most obvious, and
:) a real occurrence of "/.../" in a URL is very unlikely.  A space character
:) wouldn't be good - sometimes they can appear in URLs (especially in
:) the #fragment part), whether that's strictly valid or not.  

>   Ok, so here is the patch that makes lynx to separate beginning and end
> by '/.../'. If you would like '//.../' to be displayed like '/..../'
> instead, let me know.

This cuts off directories at the middle of it, and replaces
to "/.../", like this:
        http://www.foo.com/bar/very_long_string/index.html
        http://www.foo.com/bar/very/.../index.html
Since "/" is the true path separator, this is still confusing
with real "/very/", though real "/.../" is very unlikely.  In
the case above, it is little better to remove a whole of
"very_long_string".

How about another patch?  This is made for the original
lynx2.8.3dev.5.  I know the problem here, this strips off
more information from URLs.  Any comment?

diff -ru lynx2-8-3.orig/src/LYMainLoop.c lynx2-8-3/src/LYMainLoop.c
--- lynx2-8-3.orig/src/LYMainLoop.c     Sat Jul 31 00:39:54 1999
+++ lynx2-8-3/src/LYMainLoop.c  Wed Aug  4 20:22:36 1999
@@ -6883,7 +6883,7 @@
        BOOLEAN,        show_indx)
 {
 #define MAX_STATUS (LYcols - 2)
-#define MIN_STATUS MAX_STATUS / 2
+#define MIN_STATUS 0
     char format[MAX_LINE];
     int prefix;
     int length;
@@ -6903,41 +6903,38 @@
 
        if ((length + prefix > MAX_STATUS) && long_url_ok) {
            char *buf = NULL;
-           int j;
-           int k;
-           int cut_position;
-           int link_position;
+           int cut_from_pos;
+           int cut_to_pos;
+           int n;
 
            StrAllocCopy(buf, curlink_name);
-
-           /* Scan to find the final leaf of the url, put it in 'k'.
-            * Ignore trailing '/'.
+           /*
+            *  Scan to find the final leaf of the URL.
+            *  Ignore trailing '/'.
             */
-           for (j = length; (j > 0) && buf[j] != '/'; --j)
-               ;
-           if (j >= (length - 3)) {
-               for (k = j - 1; (k > 0) && buf[k] != '/'; --k)
-                   ;
-           } else {
-               k = j;
-           }
-
-           /* We assume that one can recognize the link from at least
-            * MIN_STATUS characters.
+           for (cut_to_pos = length - 2;
+                (cut_to_pos > 0) && (buf[cut_to_pos] != '/');
+                cut_to_pos--);
+           /*
+            *  Jump back to the next leaf to remove.
+            */
+           for (cut_from_pos = cut_to_pos - 4;
+                (cut_from_pos > 0) && ((buf[cut_from_pos] != '/')
+                || (prefix + cut_from_pos + 4 + (length - cut_to_pos) >= 
MAX_STATUS));
+                cut_from_pos--);
+           /*
+            *  Replace some leaves to '...', if possible, and put the
+            *  final leaf at the end. We assume that one can recognize
+            *  the link from at least MIN_STATUS characters.
             */
-           cut_position = MAX_STATUS - prefix - (length - k);
-           if (cut_position < MIN_STATUS){
-               cut_position = MIN_STATUS;
-               link_position = length - MIN_STATUS + 3;
-           } else {
-               link_position = k;
+           if (cut_from_pos > MIN_STATUS) {
+               for (n = 1; n <= 3; n++)
+                   buf[cut_from_pos + n] = '.';
+               for (n = 0; cut_to_pos + n <= length; n++)
+                   buf[cut_from_pos + 4 + n] = buf[cut_to_pos + n];
            }
-           for (j = 0; j < 3; j++)
-               buf[cut_position++] = '_';
-           if (cut_position < link_position)
-               while ((buf[cut_position++] = buf[link_position++]) != 0)
-                   ;
            _user_message(format, buf);
+       CTRACE(tfp,"lastline = %s",buf); /* don't forget to erase me */
            FREE(buf);
        } else {        /* show (possibly truncated) url */
            _user_message(format, curlink_name);


Anyhow, the idea of displaying the relevant parts of URLs is
very convenient for me.

Thank you.
---
address@hidden

reply via email to

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