lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev change to status line


From: Eduardo Chappa L.
Subject: lynx-dev change to status line
Date: Wed, 14 Jul 1999 11:57:23 -0700 (PDT)

Hello

When in advance mode, lynx cuts the address of the current link if this is
too long to be displayed, not showing the name of the document to be
accessed. This is important sometimes because one would not like to follow
certain links (say tar.gz or jpg in slow connections) or persons with
disabilities would not get valuable information from the status line.

The following patch changes this behavior to display the most possible
"useful information" For example:

http://here-there-is-a-very-very-very-very-very-long-url.com/and/it/links/to
/document.html

is displayed as:

http://here-there-is-a-very-very-very-very-very-long-url.c/.../document.html

the information is hard to find using the list of links and  not necessary
to do so, since it can be given in a better format. The following patch
acomplishes that. Of course more elegant solutions can be done.

The patch is against 2.8.2rel1

*** LYMainLoopreal.c    Wed Jul 14 11:10:31 1999
--- LYMainLoop.c        Wed Jul 14 11:05:19 1999
***************
*** 57,62 ****
--- 57,63 ----
  
  PRIVATE void exit_immediately_with_error_message PARAMS((int state, BOOLEAN 
first_file));
  PRIVATE void print_status_message PARAMS((CONST linkstruct curlink, char 
**cp));
+ PRIVATE char * status_link  PARAMS((char *curlink_name,char *more,char 
*index));
  PRIVATE BOOL confirm_post_resub PARAMS((
      CONST char*               address,
      CONST char*               title,
***************
*** 6151,6156 ****
--- 6152,6160 ----
        /*
         *  Show the URL or, for some internal links, the fragment
         */
+         char *more = "-more-";
+         char *index = "-index-";
+ 
        *cp = NULL;
        if (curlink.type == WWW_INTERN_LINK_TYPE &&
            strncmp(curlink.lname, "LYNXIMGMAP:", 11)) {
***************
*** 6160,6174 ****
            *cp = curlink.lname;
        if (more) {
            if (is_www_index)
!               _user_message("-more- -index- %s",
!                                        *cp);
!           else
!               _user_message("-more- %s",*cp);
        } else {
!           if (is_www_index)
!               _user_message("-index- %s",*cp);
!           else
!               statusline(*cp);
        }
      } else if (is_www_index && more) {
        char buf[128];
--- 6164,6177 ----
            *cp = curlink.lname;
        if (more) {
            if (is_www_index)
!               statusline(status_link(*cp, more, index)); 
!           else 
!               statusline(status_link(*cp, more, NULL)); 
        } else {
!           if (is_www_index) 
!               statusline(status_link(*cp, NULL, index)); 
!           else 
!               statusline(status_link(*cp, NULL, NULL));
        }
      } else if (is_www_index && more) {
        char buf[128];
***************
*** 6247,6250 ****
--- 6250,6325 ----
        exit_immediately(-1);
      }
      /* else: return(-1) in mainloop */
+ }
+ 
+ 
+ PRIVATE char * status_link ARGS3(char *, curlink_name, char *, more, char *, 
index)
+ {
+ #define MINDISPLAY LYcols/2
+           char result[LYcols];
+           char *test;
+           int largo_more = 0;
+           int largo_index = 0;
+           if (more != NULL) {
+               largo_more = strlen(more) + 1;}
+           if (index != NULL) {
+               largo_index = strlen(index) + 1;}
+           if (strlen(curlink_name) + largo_more + largo_index > LYcols - 2) {
+           char buf[1024]; /* 1024 is he length of a very long URL */
+           int count;
+           int total_length;
+           int cut_position;
+           int link_position;
+               if (more == NULL) {
+                       if (index == NULL) {
+                               sprintf(buf,"%s",curlink_name);}
+                       else {
+                               sprintf(buf,"%s %s", index, curlink_name);
+                       }
+               } else {
+                       if (index == NULL) {
+                               sprintf(buf,"%s %s",more,curlink_name);}
+                       else {
+                               sprintf(buf,"%s %s %s",more, index, 
curlink_name);
+                       }
+               }
+               total_length = strlen(curlink_name) + largo_more + largo_index;
+               for (count = total_length; (count > largo_more + largo_index) 
&& buf[count] != '/'; --count);
+               if (count == total_length - 1) {
+               for (count = total_length - 2; (count > largo_more + 
largo_index) &&  buf[count] != '/'; --count);
+               } 
+               cut_position = LYcols - 2 - (total_length - count);
+               if (cut_position < MINDISPLAY){ 
+                       cut_position = MINDISPLAY;
+                       link_position = total_length - MINDISPLAY;      
+               } else {
+                       cut_position = LYcols - 2 - (total_length - count);
+                       link_position = count;
+                       }
+               for (count = 0; count <= cut_position; ++count)
+                  result[count] = buf[count];
+                 result[cut_position - 1] = '.';
+                 result[cut_position - 2] = '.';
+                 result[cut_position - 3] = '.';
+               for (count = cut_position;  (count < LYcols - 2) && 
(link_position + count - cut_position <= total_length); ++count) 
+                       result[count] = buf[link_position + count - 
cut_position];
+               result[count] = '\0';
+       }
+         else {
+               if (more == NULL) {
+                       if (index == NULL) {
+                               sprintf(result,"%s\n",curlink_name);}
+                       else {
+                               sprintf(result,"%s %s\n", index, curlink_name);
+                       }
+               } else {
+                       if (index == NULL) {
+                               sprintf(result,"%s %s\n",more,curlink_name);}
+                       else {
+                               sprintf(result,"%s %s %s\n",more, index, 
curlink_name);
+                       }
+               }
+             }
+             test = result;
+             return test; 
  }

Eduardo}
http://www.math.washington.edu/~chappa/personal.html




reply via email to

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