[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
LYNX-DEV ac-0.24: more patches
From: |
John E. Davis |
Subject: |
LYNX-DEV ac-0.24: more patches |
Date: |
Sat, 17 May 1997 13:57:22 -0400 |
Here are some more patches to ac-0.24. These patches do two things:
1. Add mouse support to the slang compiled versions of lynx. In
an effort to clean up and unify the mouse code, I created a
new function called `lynx_enable_mouse'. By doing this, I was
able to change code that looks like:
#ifndef _WINDOWS
mousemask(BUTTON1_CLICKED, NULL);
#else
mouse_set(BUTTON1_CLICKED && BUTTON2_CLICKED && BUTTON3_CLICKED);
#endif /* _WINDOWS */
#endif /* NCURSES_MOUSE_VERSION */
to simply:
lynx_enable_mouse (1);
I made this function public in the hope that when the user is
prompted by lynx for, e.g., a URL name, code such as:
lynx_enable_mouse (0); /* Turn off mouse */
read_string_from_user ();
lynx_enable_mouse (1); /* Turn mouse on */
The affected files include
LYCurses.c
LYCurses.h
LYMain.c
LYReadCFG.c
LYStrings.c
and the patches are minor.
2. I have been having a horrible time getting my ~/.lynxrc file
to load. The problem stems from the way the lynx config
filename is determined. Currently, it is determined by:
IF specified on command line, use that value
ELSE if specified via environment, use that value
ELSE use hard-coded value (/usr/local/lib/lynx.rc)
My patch changes the logic to:
IF specified on command line, use that value
ELSE if specified via environment, use that value
ELSE if a config file exists in home directory, use that value
ELSE use hard-coded value (/usr/local/lib/lynx.rc)
To this end, I created a new function
`make_homedir_lynxrc_filename' to clean-up some other code in main.
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 04:53:42 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);
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 04:40:44 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,7 @@
#endif /* FANCY_CURSES */
#endif /* USE_SLANG */
+
+extern void lynx_enable_mouse PARAMS((int));
#endif /* LYCURSES_H */
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 13:22:13 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/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 04:29:26 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 05:27:08 1997
@@ -189,6 +189,32 @@
}
#endif
+#ifdef USE_SLANG_MOUSE
+PRIVATE int sl_parse_mouse_event ARGS2(int *, x, int *, y)
+{
+ /* "ESC [ M" has already been processed. There more characters are
+ * expected: BUTTON X Y
+ */
+ switch (SLang_getkey ())
+ {
+ case 040: /* left button */
+ break;
+
+ case 041: /* middle button */
+ case 042: /* right button */
+
+ /* drop: for now lets just handle the left button. */
+ default: /* Hmmm.... */
+ SLang_flush_input ();
+ return -1;
+ }
+
+ *x = SLang_getkey () - 33;
+ *y = SLang_getkey () - 33;
+ return 0;
+}
+#endif
+
/*
* LYgetch() translates some escape sequences and may fake noecho
*/
@@ -299,7 +325,21 @@
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;
+
+ mouse_link = -1;
+ if (-1 != sl_parse_mouse_event (&mouse_x, &mouse_y))
+ c = set_clicked_link (mouse_x, mouse_y);
+ else c = -1;
+ }
+ else
+#endif
+ c = '\n'; /* kepad enter on pc ncsa telnet */
+ break;
case 'm':
#ifdef VMS
@@ -448,6 +488,7 @@
c=127; /* backspace key (delete, not Ctrl-H) */
break;
#endif /* KEY_BACKSPACE */
+
#ifdef NCURSES_MOUSE_VERSION
case KEY_MOUSE:
{
;
; To UNSUBSCRIBE: Send a mail message to address@hidden
; with "unsubscribe lynx-dev" (without the
; quotation marks) on a line by itself.
;
- LYNX-DEV ac-0.24: more patches,
John E. Davis <=