lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev change to status line


From: Eduardo Chappa L.
Subject: Re: lynx-dev change to status line
Date: Thu, 15 Jul 1999 13:20:16 -0700 (PDT)

Oops, my apologies, my last e-mail went through a filter, which made it
look really bad. I'll take care this one won't go through it. The message
goes again...

---------------

Hello

Here is a new patch, explanation follows:

 * New starting option "-short_url", that shortens urls to see their
   beginning and end when in advance mode. The default is the normal
   behavior in Lynx.

  Some explanation about what it does, was given before. In essence it
shows relevant information about what the link is, to where and what kind
of file is being accessed. There was/is a bug with "javascript" urls. The
solution was to assume that the ending of a link can not contain less than
3 characters, so it should always show at least 4 characters and less than
half of LYcols in the end of the link. The separation between beginning
and end is done by the "___" string. Other suggestions welcome :) (BTW,
there is a snip.com page :P)

  The patch is against lynx2.8.2rel1

diff -rc lynx2-8-2.real/src/LYMain.c lynx2-8-2/src/LYMain.c
*** lynx2-8-2.real/src/LYMain.c Tue Jun  1 06:22:18 1999
--- lynx2-8-2/src/LYMain.c      Thu Jul 15 12:44:34 1999
***************
*** 195,200 ****
--- 195,201 ----
  PUBLIC BOOLEAN news_ok = TRUE;
  #endif
  PUBLIC BOOLEAN rlogin_ok = TRUE;
+ PUBLIC BOOLEAN long_url_ok = TRUE;
  PUBLIC BOOLEAN ftp_ok = TRUE;
  PUBLIC BOOLEAN system_editor = FALSE;
  #ifdef USE_EXTERNALS
***************
*** 2963,2968 ****
--- 2964,2973 ----
     PARSE_FUN(
        "selective",    FUNCTION_ARG,           selective_fun,
        "require .www_browsable files to browse directories"
+    ),
+    PARSE_SET(
+       "short_url",            UNSET_ARG,              &long_url_ok,
+       "enables examination of beginnig and end of long URL in status line"
     ),
     PARSE_SET(
        "show_cursor",  TOGGLE_ARG,             &LYUseDefShoCur,

diff -rc lynx2-8-2.real/src/LYMainLoop.c lynx2-8-2/src/LYMainLoop.c
*** lynx2-8-2.real/src/LYMainLoop.c     Fri May 28 07:04:01 1999
--- lynx2-8-2/src/LYMainLoop.c  Thu Jul 15 12:56:47 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,6161 ----
        /*
         *  Show the URL or, for some internal links, the fragment
         */
+         char *more = "-more-";
+         char *index = "-index-";
+         extern BOOLEAN long_url_ok;
+ 
        *cp = NULL;
        if (curlink.type == WWW_INTERN_LINK_TYPE &&
            strncmp(curlink.lname, "LYNXIMGMAP:", 11)) {
***************
*** 6159,6174 ****
        if (!(*cp))
            *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,6190 ----
        if (!(*cp))
            *cp = curlink.lname;
        if (more) {
!           if (is_www_index) {
!               if (long_url_ok) {
!                     _user_message("-more- -index- %s", *cp); }
!               else {
!                   statusline(status_link(*cp, more, index)); } }
!           else  {
!               if (long_url_ok) {
!                     _user_message("-more- %s",*cp); }
!               else {
!                   statusline(status_link(*cp, more, NULL)); } }
        } else {
!           if (is_www_index) {
!               if (long_url_ok) {
!                     _user_message("-index- %s",*cp);}
!               else {
!                   statusline(status_link(*cp, NULL, index)); } }
!           else {
!               if (long_url_ok) {
!                     statusline(*cp);}
!               else {
!                   statusline(status_link(*cp, NULL, NULL));} }
        }
      } else if (is_www_index && more) {
        char buf[128];
***************
*** 6247,6250 ****
--- 6263,6348 ----
        exit_immediately(-1);
      }
      /* else: return(-1) in mainloop */
+ }
+ 
+ 
+ PRIVATE char * status_link ARGS3(char *, curlink_name, char *, more, char *, 
index)
+ {
+ #define MINDISPLAY (LYcols-2)/2
+           char result[LYcols];
+           char *test;
+           int length_more = 0;
+           int length_index = 0;
+           if (more != NULL) {
+               length_more = strlen(more) + 1;}
+           if (index != NULL) {
+               length_index = strlen(index) + 1;}
+           if (strlen(curlink_name) + length_more + length_index > LYcols - 2) 
{
+           char buf[1024]; /* 1024 is he length of a very long URL */
+           int count;
+           int newcount;
+           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) + length_more + 
length_index;
+               for (count = total_length; (count > length_more + length_index) 
&& buf[count] != '/'; --count);
+               newcount = count;
+ 
+                /* Now we deal with links that are not URLs or that end with 
+                   a '/' character */
+ 
+               if (count >= (total_length - 3)) {
+               for (newcount = count - 1; (newcount > length_more + 
length_index) &&  buf[newcount] != '/'; --newcount);
+               } 
+ 
+               /* We make the assumption that one can recognize the kind of
+                  link from at least MINDISPLAY characters */
+ 
+               cut_position = LYcols - 2 - (total_length - newcount);
+               if (cut_position < MINDISPLAY){ 
+                       cut_position = MINDISPLAY;
+                       link_position = total_length - MINDISPLAY;      
+               } else {
+                       link_position = newcount;
+                       }
+               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]