lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV ac-0.24: even more patches


From: John E. Davis
Subject: LYNX-DEV ac-0.24: even more patches
Date: Sat, 17 May 1997 17:49:58 -0400

Here are some more patches.  These include my previous patches and
diffs are with respect to a clean ac-0.24 tree.   The new patches
essentually isolate the code that performs the highlighting such as:

    if (bold_H1 || bold_headers)
        start_bold();

and replaced it with

    lynx_start_h1_color ();

Not only is this cleaner, but it is ultimately much more useful.  It
is a first step to giving the user more control over the look of the
program.  To this end, I have created several new functions and put
them at the end of LYCurses.c:

    lynx_start_underline_color
    lynx_stop_underline_color
    lynx_start_bold_color
    lynx_stop_bold_color
    lynx_start_title_color
    lynx_stop_title_color
    lynx_start_link_color
    lynx_stop_link_color
    lynx_stop_target_color
    lynx_start_target_color
    lynx_start_status_color
    lynx_stop_status_color
    lynx_start_h1_color
    lynx_stop_h1_color
    lynx_start_prompt_color
    lynx_stop_prompt_color
    lynx_start_radio_color
    lynx_stop_radio_color
    lynx_stop_all_colors


Here are the patches:

diff -ur lynx2.7.1ac-0.24/aclocal.m4 lynx2-7-1/aclocal.m4
--- lynx2.7.1ac-0.24/aclocal.m4 Tue Apr 29 11:16:15 1997
+++ lynx2-7-1/aclocal.m4        Sat May 17 04:31:42 1997
@@ -692,7 +692,7 @@
                [LIBS="-lslang $LIBS"],
                [AC_CHECK_LIB(slang,SLtt_get_screen_size,
                        [LIBS="-lslang -lm $LIBS"],
-                       AC_ERROR(cannot link -lslang),"-lm")])])
+                       AC_ERROR(cannot link -lslang),"-lm")],"-lm")])
 ])dnl
 dnl ---------------------------------------------------------------------------
 dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
diff -ur lynx2.7.1ac-0.24/src/GridText.c lynx2-7-1/src/GridText.c
--- lynx2.7.1ac-0.24/src/GridText.c     Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/GridText.c    Sat May 17 17:22:46 1997
@@ -538,36 +538,33 @@
     i++;
     while ((i < LYcols) && ((buffer[0] = *data) != '\0')) {
        data++;
-       i++;
 
        switch (buffer[0]) {
 
            case LY_UNDERLINE_START_CHAR:
-               if (!(dump_output_immediately && use_underscore)) {
-                   start_underline();
-                   i--;
-               } else {
-                   addch('_');
-               }
-               break;
+                  if (dump_output_immediately && use_underscore)
+                    {
+                       addch ('-');
+                       i++;
+                    }
+               else lynx_start_underline_color ();
+               break;
 
            case LY_UNDERLINE_END_CHAR:
-               if (!(dump_output_immediately && use_underscore)) {
-                   stop_underline();
-                   i--;
-               } else {
-                   addch('_');
-               }
-               break;
+               if (dump_output_immediately && use_underscore)
+                 {
+                    addch ('-');
+                    i++;
+                 }
+               else lynx_stop_underline_color ();
+               break;
 
            case LY_BOLD_START_CHAR:
-               start_bold();
-               i--;
+               lynx_start_bold_color ();
                break;
 
            case LY_BOLD_END_CHAR:
-               stop_bold ();
-               i--;
+               lynx_stop_bold_color ();
                break;
 
            case LY_SOFT_HYPHEN:
@@ -576,16 +573,17 @@
                     *  Ignore the soft hyphen if it is not
                     *  the last character in the line. - FM
                     */
-                   i--;
                    break;
                } else {
                    /*
                     *  Make it a hard hyphen and fall through. - FM
                     */
                    buffer[0] = '-';
+                  i++;
                }
 
            default:
+               i++;
 #ifdef EXP_CHARTRANS
                    if (text->T.output_utf8 && !isascii(buffer[0])) {
                        if ((*buffer & 0xe0) == 0xc0) {
@@ -629,8 +627,8 @@
     /* add the return */
     addch('\n');
 
-    stop_underline();
-    stop_bold();
+    lynx_stop_underline_color ();
+    lynx_stop_bold_color ();
     return(0);
 }
 
@@ -652,6 +650,8 @@
     if (!text)
         return;
 
+   lynx_start_title_color ();
+
     /*
      *  Load the title field. - FM
      */
@@ -750,6 +750,9 @@
     addstr(cp);
     FREE(cp);
     FREE(title);
+   
+   lynx_stop_title_color ();
+
     return;
 }
 
@@ -893,9 +896,7 @@
 
            text->page_has_target = YES;
 
-           start_bold();
-           start_reverse();
-           start_underline();
+           lynx_start_target_color ();
                /* underline string */
            for (; written < len && (tmp[0] = line->data[itmp]) != '\0';
                   itmp++)  {
@@ -989,10 +990,8 @@
                    }
                }
            }
-
-           stop_underline();
-           stop_reverse();
-           stop_bold();
+          
+           lynx_stop_target_color ();
            move(i+2, 0);
        }
 
diff -ur lynx2.7.1ac-0.24/src/LYBookmark.c lynx2-7-1/src/LYBookmark.c
--- lynx2.7.1ac-0.24/src/LYBookmark.c   Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYBookmark.c  Sat May 17 17:04:56 1997
@@ -758,8 +758,7 @@
      */
     clear();
     move(1, 5);
-    if (bold_H1 || bold_headers)
-       start_bold();
+    lynx_start_h1_color ();
     if (MBM_screens > 1) {
         sprintf(shead_buffer,
                MULTIBOOKMARKS_SHEAD_MASK, MBM_current, MBM_screens);
@@ -767,8 +766,8 @@
     } else {
         addstr(MULTIBOOKMARKS_SHEAD);
     }
-    if (bold_H1 || bold_headers)
-       stop_bold();
+   
+   lynx_stop_h1_color ();
 
     MBM_tmp_count = 0;
     for (c = MBM_from; c <= MBM_to; c++) {
diff -ur lynx2.7.1ac-0.24/src/LYClean.c lynx2-7-1/src/LYClean.c
--- lynx2.7.1ac-0.24/src/LYClean.c      Tue May 13 17:40:02 1997
+++ lynx2-7-1/src/LYClean.c     Sat May 17 17:04:56 1997
@@ -162,9 +162,7 @@
         move(LYlines-1, 0);
         clrtoeol();
 
-        stop_bold();
-        stop_underline();
-        stop_reverse();
+        lynx_stop_all_colors ();
         refresh();
 
         stop_curses();
diff -ur lynx2.7.1ac-0.24/src/LYCurses.c lynx2-7-1/src/LYCurses.c
--- lynx2.7.1ac-0.24/src/LYCurses.c     Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYCurses.c    Sat May 17 17:23:19 1997
@@ -64,8 +64,6 @@
 
 PUBLIC void LY_SLclear NOARGS
 {
-    int r, c;
-
     SLsmg_gotorc (0, 0);
     SLsmg_erase_eos ();
 }
@@ -119,13 +117,16 @@
     SLtt_set_mono(7, NULL, SLTT_ULINE_MASK | SLTT_BOLD_MASK | SLTT_REV_MASK);
 }
 
+
+
 PRIVATE void sl_suspend ARGS1(
        int,            sig)
 {
-#ifndef VMS
 #ifdef SIGSTOP
+#ifndef VMS
     int r, c;
-
+   
+    lynx_enable_mouse (0);
     if (sig == SIGTSTP)
         SLsmg_suspend_smg();
     SLang_reset_tty();
@@ -150,13 +151,43 @@
     if ((r != SLtt_Screen_Rows) || (c != SLtt_Screen_Cols)) {
        recent_sizechange = TRUE;
     }
-#endif /* SIGSTOP */
+   lynx_enable_mouse (1);
 #endif /* !VMS */
+#endif /* SIGSTOP */
    return;
 }
 #endif /* USE_SLANG */
 
 
+PUBLIC void lynx_enable_mouse ARGS1(int,state)
+{
+   if (LYUseMouse == 0) 
+     return;
+
+#ifdef USE_SLANG_MOUSE
+   SLtt_set_mouse_mode (state, 0);
+   SLtt_flush_output ();
+#else
+#ifdef NCURSES_MOUSE_VERSION
+     /* Inform ncurses that we're interested in knowing when mouse
+      button 1 is clicked */
+#ifndef _WINDOWS
+   if (state)
+     mousemask(BUTTON1_CLICKED, NULL);
+   else
+     mousemask(0, NULL);
+#else
+   if (state) mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED);
+#endif /* _WINDOWS */
+#endif /* NCURSES_MOUSE_VERSION */
+
+#if defined(DJGPP) && !defined(SLANG)
+     if (state)
+       mouse_set(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED);
+#endif
+#endif                                /* NOT USE_SLANG_MOUSE */
+}
+
 #ifdef COLOR_CURSES
 /*
  * This block of code is designed to produce the same color effects using SVr4
@@ -381,7 +412,7 @@
     buttons are clicked.  Maybe someday pdcurses will support it.
  */
         if (LYUseMouse)
-             mouse_set(BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED);
+             lynx_enable_mouse (1);
 
         } else sock_init();
 
@@ -440,6 +471,8 @@
     signal(SIGINT, cleanup_sig);
 #endif /* !VMS */
 
+   lynx_enable_mouse (1);
+
 #else /* Using curses: */
 
 #ifdef VMS
@@ -498,16 +531,7 @@
     keypad(stdscr,TRUE);
 #endif /* HAVE_KEYPAD */
 
-#ifdef NCURSES_MOUSE_VERSION
- /* Inform ncurses that we're interested in knowing when mouse
-    button 1 is clicked */
-    if (LYUseMouse)
-#ifndef _WINDOWS
-      mousemask(BUTTON1_CLICKED, NULL);
-#else
-      mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED);
-#endif /* _WINDOWS */
-#endif /* NCURSES_MOUSE_VERSION */
+   lynx_enable_mouse (1);
 
     fflush(stdin);
     fflush(stdout);
@@ -542,10 +566,8 @@
      * 05-28-94 Lynx 2-3-1 Garrett Arch Blythe
      */
     if(LYCursesON == TRUE)     {
-#ifdef NCURSES_MOUSE_VERSION
-        mousemask(0, NULL);
-#endif
-       endwin();       /* stop curses */
+         lynx_enable_mouse (0);
+         endwin();     /* stop curses */
     }
 
     fflush(stdout);
@@ -1226,3 +1248,138 @@
 }
 #endif /* !USE_SLANG */
 #endif /* VMS */
+
+
+
+PUBLIC void lynx_start_underline_color NOARGS
+{
+   start_underline ();
+}
+
+PUBLIC void lynx_stop_underline_color NOARGS
+{
+   stop_underline ();
+}
+
+PUBLIC void lynx_start_bold_color NOARGS
+{
+   start_bold ();
+}
+
+PUBLIC void lynx_stop_bold_color NOARGS
+{
+   stop_bold ();
+}
+
+PUBLIC void lynx_start_title_color NOARGS
+{
+}
+
+PUBLIC void lynx_stop_title_color NOARGS
+{
+}
+
+PUBLIC void lynx_start_link_color ARGS1(int, flag)
+{
+   if (flag)
+     {
+       /* makes some terminals work wrong because
+        * they can't handle two attributes at the 
+        * same time
+        */
+       /* start_bold();  */
+       start_reverse();
+#if defined(USE_SLANG) || defined(FANCY_CURSES)
+       start_underline ();
+#endif /* USE_SLANG */
+     } else {
+       start_bold();
+     }
+}
+
+PUBLIC void lynx_stop_link_color ARGS1(int, flag)
+{
+   if (flag) 
+     {
+       stop_reverse();
+#if defined(USE_SLANG) || defined(FANCY_CURSES)
+       stop_underline ();
+#endif /* USE_SLANG */
+     }
+   else stop_bold();
+}
+
+
+PUBLIC void lynx_stop_target_color NOARGS
+{
+   stop_underline();
+   stop_reverse();
+   stop_bold();
+}
+
+PUBLIC void lynx_start_target_color NOARGS
+{
+   start_bold();
+   start_reverse();
+   start_underline();
+}
+
+
+PUBLIC void lynx_start_status_color NOARGS
+{
+#ifdef COLOR_CURSES
+   lynx_set_color (2);
+#else
+   start_reverse ();
+#endif
+}
+
+PUBLIC void lynx_stop_status_color NOARGS
+{
+#ifdef COLOR_CURSES
+   lynx_set_color (0);
+#else
+   stop_reverse ();
+#endif
+}
+
+PUBLIC void lynx_start_h1_color NOARGS
+{
+   if (bold_H1 || bold_headers)
+     start_bold();
+}
+
+PUBLIC void lynx_stop_h1_color NOARGS
+{
+   if (bold_H1 || bold_headers)
+     stop_bold();
+}
+
+PUBLIC void lynx_start_prompt_color NOARGS
+{
+   start_reverse ();
+}
+
+PUBLIC void lynx_stop_prompt_color NOARGS
+{
+   stop_reverse ();
+}
+
+PUBLIC void lynx_start_radio_color NOARGS
+{
+   start_bold ();
+}
+
+PUBLIC void lynx_stop_radio_color NOARGS
+{
+   stop_bold ();
+}
+
+PUBLIC void lynx_stop_all_colors NOARGS
+{
+   stop_underline ();
+   stop_reverse ();
+   stop_bold ();
+}
+   
+       
diff -ur lynx2.7.1ac-0.24/src/LYCurses.h lynx2-7-1/src/LYCurses.h
--- lynx2.7.1ac-0.24/src/LYCurses.h     Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYCurses.h    Sat May 17 17:20:16 1997
@@ -116,6 +116,10 @@
 #endif
 
 #ifdef USE_SLANG
+#if !defined(VMS) && !defined(DJGPP)
+#define USE_SLANG_MOUSE                1
+#endif
+
 #define SL_LYNX_USE_COLOR      1
 #define SL_LYNX_USE_BLINK      2
 #define start_bold()      lynx_add_attr(1)
@@ -247,5 +251,27 @@
 
 #endif /* FANCY_CURSES */
 #endif /* USE_SLANG */
+
+extern void lynx_enable_mouse PARAMS((int));
+extern void lynx_start_underline_color NOPARAMS;
+extern void lynx_stop_underline_color NOPARAMS;
+extern void lynx_start_bold_color NOPARAMS;
+extern void lynx_stop_bold_color NOPARAMS;
+extern void lynx_start_title_color NOPARAMS;
+extern void lynx_stop_title_color NOPARAMS;
+extern void lynx_start_link_color PARAMS((int));
+extern void lynx_stop_link_color PARAMS((int));
+extern void lynx_stop_target_color NOPARAMS;
+extern void lynx_start_target_color NOPARAMS;
+extern void lynx_start_status_color NOPARAMS;
+extern void lynx_stop_status_color NOPARAMS;
+extern void lynx_start_h1_color NOPARAMS;
+extern void lynx_stop_h1_color NOPARAMS;
+extern void lynx_start_prompt_color NOPARAMS;
+extern void lynx_stop_prompt_color NOPARAMS;
+extern void lynx_start_radio_color NOPARAMS;
+extern void lynx_stop_radio_color NOPARAMS;
+extern void lynx_stop_all_colors NOPARAMS;
+
 
 #endif /* LYCURSES_H */
diff -ur lynx2.7.1ac-0.24/src/LYForms.c lynx2-7-1/src/LYForms.c
--- lynx2.7.1ac-0.24/src/LYForms.c      Sat May  3 20:51:45 1997
+++ lynx2-7-1/src/LYForms.c     Sat May 17 17:19:48 1997
@@ -109,7 +109,7 @@
                /* run though list of the links on the screen and
                 * unselect any that are selected. :) 
                 */
-               start_bold();
+               lynx_start_radio_color ();
                for (i = 0; i < nlinks; i++)
                   if (links[i].type == WWW_FORM_LINK_TYPE &&
                       links[i].form->type == F_RADIO_TYPE &&
@@ -122,7 +122,7 @@
                        addstr(unchecked_radio);
                        links[i].hightext = unchecked_radio;
                     }
-               stop_bold();
+               lynx_stop_radio_color ();
                /* will unselect other button and select this one */
                HText_activateRadioButton(form);
                /* now highlight this one */
diff -ur lynx2.7.1ac-0.24/src/LYMain.c lynx2-7-1/src/LYMain.c
--- lynx2.7.1ac-0.24/src/LYMain.c       Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYMain.c      Sat May 17 17:04:56 1997
@@ -449,6 +449,33 @@
     return;
 }
 
+PRIVATE char *make_homedir_lynxrc_filename ARGS1(char *, name)
+{
+   char *home = NULL;
+
+   if (name == NULL)
+     {
+#if defined(UNIX) && !defined(DJGPP)
+       name = "/.lynxrc";
+#else
+       name = "/lynx.rc";
+#endif
+     }
+
+#ifdef DOSPATH
+   StrAllocCopy(home, HTDOS_wwwName((char *)Home_Dir()));
+#else
+#ifdef VMS
+   StrAllocCopy(home, HTVMS_wwwName((char *)Home_Dir()));
+#else
+   StrAllocCopy(home, Home_Dir());
+#endif /* VMS */
+#endif /* DOSPATH */
+   
+   StrAllocCat(home, name);
+   return home;
+}
+
 /*
  * Wow!  Someone wants to start up Lynx.
  */
@@ -837,6 +864,21 @@
            StrAllocCopy(lynx_cfg_file, cp);
     }
 
+   /* If we still have no config file, check one in home directory */
+   if (NULL == lynx_cfg_file)
+     {
+       temp = make_homedir_lynxrc_filename (NULL);
+       if (temp != NULL)
+         {
+            if (NULL != (fp = fopen (temp, "r")))
+              {
+                 fclose (fp);
+                 StrAllocCopy (lynx_cfg_file, temp);
+              }
+            FREE(temp);
+         }
+     }
+
     /*
      *  If we still don't have a configuration file,
      *  use the userdefs.h definition.
@@ -848,25 +890,15 @@
      *  Convert a '~' in the configuration file path to $HOME.
      */
 #ifndef _WINDOWS /* avoid the whole ~ thing for now */
-    if ((cp = strchr(lynx_cfg_file, '~'))) {
-       *(cp++) = '\0';
-       StrAllocCopy(temp, lynx_cfg_file);
-       if (((len = strlen(temp)) > 0) && temp[len-1] == '/')
-           temp[len-1] = '\0';
-#ifdef DOSPATH
-       StrAllocCat(temp, HTDOS_wwwName((char *)Home_Dir()));
-#else
-#ifdef VMS
-       StrAllocCat(temp, HTVMS_wwwName((char *)Home_Dir()));
-#else
-       StrAllocCat(temp, Home_Dir());
-#endif /* VMS */
-#endif /* DOSPATH */
-       StrAllocCat(temp, cp);
-       StrAllocCopy(lynx_cfg_file, temp);
-       FREE(temp);
-    }
-#endif /* _WINDOWS */
+   /* I think this should only be performed if lynx_cfg_file starts with ~/ */
+   if ((lynx_cfg_file[0] == '~') && (lynx_cfg_file[1] == '/'))
+     {
+       temp = make_homedir_lynxrc_filename (lynx_cfg_file + 2);
+       FREE(lynx_cfg_file);
+       lynx_cfg_file = temp;
+       temp = NULL;
+     }
+#endif
 
     /*
      *  If the configuration file is not available,
@@ -2180,7 +2212,7 @@
        else
            use_underscore = TRUE;
 
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE)
     } else if (strncmp(argv[0], "-use_mouse", 9) == 0) {
         LYUseMouse = TRUE;
 #endif
@@ -2341,7 +2373,7 @@
     printf("    -trace           turns on Lynx trace mode\n");
     printf("    -traversal       traverse all http links derived from 
startfile\n");
     printf("    -underscore      toggles use of _underline_ format in 
dumps\n");
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE)
     printf("    -use_mouse       enable use of the mouse\n");
 #endif
     printf("    -validate        accept only http URLs (for validation)\n");
diff -ur lynx2.7.1ac-0.24/src/LYOptions.c lynx2-7-1/src/LYOptions.c
--- lynx2.7.1ac-0.24/src/LYOptions.c    Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYOptions.c   Sat May 17 17:04:56 1997
@@ -111,15 +111,14 @@
     response = 0;
     clear(); 
     move(0, 5);
-    if (bold_H1 || bold_headers)
-        start_bold();
+    
+    lynx_start_h1_color ();
     addstr("         Options Menu (");
     addstr(LYNX_NAME);
     addstr(" Version ");
     addstr(LYNX_VERSION);
     addch(')');
-    if (bold_H1 || bold_headers)
-        stop_bold();
+    lynx_stop_h1_color ();
     move(L_EDITOR, 5);  
     addstr("E)ditor                      : ");
     addstr((editor && *editor) ? editor : "NONE");
@@ -258,9 +257,9 @@
           response != 7 &&  response != 3) {
 
            move(LYlines-2, 0);
-          start_reverse();
+           lynx_start_prompt_color ();
           addstr(COMMAND_PROMPT);
-          stop_reverse();
+           lynx_stop_prompt_color ();
 
           refresh();
            response = LYgetch();
@@ -1094,16 +1093,17 @@
      */
     clear(); 
     move(0, 5);
-    if (bold_H1 || bold_headers)
-        start_bold();
+
+    lynx_start_h1_color ();
+
     if (LYlines < (MBM_V_MAXFILES + MULTI_OFFSET)) {
         sprintf(ehead_buffer, MULTIBOOKMARKS_EHEAD_MASK, MBM_current);
        addstr(ehead_buffer);
     } else {
         addstr(MULTIBOOKMARKS_EHEAD);
     }
-    if (bold_H1 || bold_headers)
-        stop_bold();
+    
+   lynx_stop_h1_color ();
 
     if (LYlines < (MBM_V_MAXFILES + MULTI_OFFSET)) {
        for (a = ((MBM_V_MAXFILES/2 + 1) * (MBM_current - 1));
@@ -1176,9 +1176,10 @@
           response != '>') {
 
        move((LYlines - 2), 0);
-       start_reverse();
+        
+       lynx_start_prompt_color ();
        addstr(MULTIBOOKMARKS_LETTER);
-       stop_reverse();
+       lynx_stop_prompt_color ();
 
        refresh();
         response = (def_response ? def_response : LYgetch());
diff -ur lynx2.7.1ac-0.24/src/LYReadCFG.c lynx2-7-1/src/LYReadCFG.c
--- lynx2.7.1ac-0.24/src/LYReadCFG.c    Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYReadCFG.c   Sat May 17 17:04:56 1997
@@ -1132,7 +1132,7 @@
            UseFixedRecords = is_true(buffer+18);
 #endif /* VMS */
 
-#ifdef NCURSES_MOUSE_VERSION
+#if defined(NCURSES_MOUSE_VERSION) || defined(USE_SLANG_MOUSE)
        } else if(!strncasecomp(buffer, "USE_MOUSE:",10)) {
                LYUseMouse = is_true(buffer+10);
 #endif
diff -ur lynx2.7.1ac-0.24/src/LYStrings.c lynx2-7-1/src/LYStrings.c
--- lynx2.7.1ac-0.24/src/LYStrings.c    Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYStrings.c   Sat May 17 17:04:56 1997
@@ -189,6 +189,47 @@
 }
 #endif
 
+#ifdef USE_SLANG_MOUSE
+PRIVATE int sl_parse_mouse_event ARGS3(int *, x, int *, y, int *, button)
+{
+   /* "ESC [ M" has already been processed.  There more characters are 
+    * expected:  BUTTON X Y
+    */
+   *button = SLang_getkey ();
+   switch (*button)
+     {
+      case 040:                               /* left button */
+      case 041:                               /* middle button */
+      case 042:                               /* right button */
+       *button -= 040;
+       break;
+
+      default:                        /* Hmmm.... */
+       SLang_flush_input ();
+       return -1;
+     }
+
+   *x = SLang_getkey () - 33;
+   *y = SLang_getkey () - 33;
+   return 0;
+}
+#endif
+
+PRIVATE int map_function_to_key ARGS1(char, keysym)
+{
+   int i;
+   
+   /* I would prefer to use sizeof keymap but its size is not available.
+    * A better method would be to declare it as some fixed size.
+    */
+   for (i = 1; i < 256; i++)
+     {
+       if (keymap[i] == keysym)
+         return i - 1;
+     }
+   return -1;
+}
+
 /*
  * LYgetch() translates some escape sequences and may fake noecho
  */
@@ -299,7 +340,32 @@
         case 's': c = PGDOWN; break;  /* keypad on pc ncsa telnet */
         case 'w': c = HOME; break;  /* keypad on pc ncsa telnet */
         case 'q': c = END; break;  /* keypad on pc ncsa telnet */
-        case 'M': c = '\n'; break; /* kepad enter on pc ncsa telnet */
+        case 'M':
+#ifdef USE_SLANG_MOUSE
+          if ((c == 27) && (b == '['))
+            {
+               int mouse_x, mouse_y, button;
+               
+               mouse_link = -1;
+               c = -1;
+               if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y, &button))
+                 {
+                    if (button == 0)  /* left */
+                      c = set_clicked_link (mouse_x, mouse_y);
+                    else if (button == 2)   /* right */
+                      {
+                         /* Right button: go back to prev document.  
+                          * The problem is that we need to determine 
+                          * what to return to achieve this.
+                          */
+                         c = map_function_to_key (LYK_PREV_DOC);
+                      }
+                 }
+            }
+          else 
+#endif
+            c = '\n'; /* kepad enter on pc ncsa telnet */
+          break; 
 
         case 'm':
 #ifdef VMS
@@ -448,6 +514,7 @@
           c=127;                  /* backspace key (delete, not Ctrl-H) */
           break;
 #endif /* KEY_BACKSPACE */
+
 #ifdef NCURSES_MOUSE_VERSION
        case KEY_MOUSE:
          {
diff -ur lynx2.7.1ac-0.24/src/LYUtils.c lynx2-7-1/src/LYUtils.c
--- lynx2.7.1ac-0.24/src/LYUtils.c      Fri May 16 04:51:31 1997
+++ lynx2-7-1/src/LYUtils.c     Sat May 17 17:04:56 1997
@@ -106,20 +106,9 @@
 
     if (nlinks > 0) {
        move(links[cur].ly, links[cur].lx);
-       if (flag == ON) { 
-           /* makes some terminals work wrong because
-            * they can't handle two attributes at the 
-            * same time
-            */
-           /* start_bold();  */
-           start_reverse();
-#if defined(USE_SLANG) || defined(FANCY_CURSES)
-           start_underline ();
-#endif /* USE_SLANG */
-       } else {
-           start_bold();
-       }
 
+        lynx_start_link_color (flag == ON);
+       
        if (links[cur].type == WWW_FORM_LINK_TYPE) {
            int len;
            int avail_space = (LYcols-links[cur].lx)-1;
@@ -154,29 +143,16 @@
            addstr(buffer);  
        }
 
+       lynx_stop_link_color (flag == ON);
+       
        /* display a second line as well */
        if (links[cur].hightext2 && links[cur].ly < display_lines) {
-           if (flag == ON) {
-               stop_reverse();
-#if defined(USE_SLANG) || defined(FANCY_CURSES)
-               stop_underline ();
-#endif /* USE_SLANG */
-           } else {
-               stop_bold();
-           }
 
            addch('\n');
            for (i=0; i < links[cur].hightext2_offset; i++)
                addch(' ');
 
-           if (flag == ON) {
-               start_reverse();
-#if defined(USE_SLANG) || defined(FANCY_CURSES)
-               start_underline ();
-#endif /* USE_SLANG */
-           } else {
-               start_bold();
-           }
+          lynx_start_link_color (flag == ON);
 
            for (i = 0; (tmp[0] = links[cur].hightext2[i]) != '\0' &&
                      i+links[cur].hightext2_offset < LYcols; i++) {
@@ -191,15 +167,8 @@
                    }
                 }
            }
-       }
-
-       if (flag == ON) {
-           stop_reverse();
-#if defined(USE_SLANG) || defined(FANCY_CURSES)
-           stop_underline ();
-#endif /* USE_SLANG */
-       } else {
-           stop_bold();
+          
+          lynx_stop_link_color (flag == ON);
        }
 
 #if defined(FANCY_CURSES) || defined(USE_SLANG)
@@ -427,19 +396,12 @@
     }
     clrtoeol();
     if (text != NULL) {
-#ifdef COLOR_CURSES
-       lynx_set_color(2);
-       addstr(buffer);
-       lynx_set_color(0);
-#else
-       start_reverse();
-       addstr(buffer);
-       stop_reverse();
-#endif
+       
+       lynx_start_status_color ();
+       addstr (buffer);
+       lynx_stop_status_color ();
     }
     refresh();
-
-    return;
 }
 
 static char *novice_lines[] = {
@@ -471,7 +433,7 @@
        return;
 
     move(LYlines-2,0);
-    stop_reverse();
+    /* stop_reverse(); */
     clrtoeol();
     addstr(NOVICE_LINE_ONE);
     clrtoeol();

;
; 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]