about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/LYCurses.c8
-rw-r--r--src/LYForms.c5
-rw-r--r--src/LYMail.c2
-rw-r--r--src/LYMain.c28
-rw-r--r--src/LYMainLoop.c2
-rw-r--r--src/LYNews.c2
-rw-r--r--src/LYOptions.c57
-rw-r--r--src/LYOptions.h12
-rw-r--r--src/LYReadCFG.c20
-rw-r--r--src/LYTraversal.c6
-rw-r--r--src/LYrcFile.c31
11 files changed, 125 insertions, 48 deletions
diff --git a/src/LYCurses.c b/src/LYCurses.c
index c3968b6d..e12e9683 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -520,7 +520,8 @@ PRIVATE void lynx_init_colors NOARGS
 	    if (n == 0 && LYShowColor)
 		bkgd(COLOR_PAIR(9));
 	}
-    }
+    } else
+	LYShowColor = FALSE;
 }
 
 PUBLIC void lynx_setup_colors NOARGS
@@ -574,7 +575,7 @@ PUBLIC void start_curses NOARGS
 
     if (slinit == 0) {
 	SLtt_get_terminfo();
-	if (Lynx_Color_Flags & SL_LYNX_USE_COLOR)
+	if (LYShowColor && (Lynx_Color_Flags & SL_LYNX_USE_COLOR))
 	    SLtt_Use_Ansi_Colors = 1;
 	size_change(0);
 
@@ -584,7 +585,7 @@ PUBLIC void start_curses NOARGS
 	 *  If set, the blink escape sequence will turn on high
 	 *  intensity background (rxvt and maybe Linux console).
 	 */
-	if (Lynx_Color_Flags & SL_LYNX_USE_BLINK)
+	if (LYShowColor && (Lynx_Color_Flags & SL_LYNX_USE_BLINK))
 	    SLtt_Blink_Mode = 1;
 	else
 	    SLtt_Blink_Mode = 0;
@@ -1495,6 +1496,7 @@ PUBLIC void lynx_force_repaint NOARGS
 {
 #if defined(COLOR_CURSES)
     chtype a = (LYShowColor) ? COLOR_PAIR(9) : A_NORMAL;
+    bkgdset(a | ' ');
     bkgd(a | ' ');
     attrset(a);
 #endif
diff --git a/src/LYForms.c b/src/LYForms.c
index 283634e3..1c053bca 100644
--- a/src/LYForms.c
+++ b/src/LYForms.c
@@ -678,9 +678,10 @@ PRIVATE int popup_options ARGS7(
 #define getbkgd(w) wgetbkgd(w)	/* workaround pre-1.9.9g bug */
 #endif
     LYsubwindow(form_window);
-#ifdef getbkgd			/* not defined in ncurses 1.8.7 */
-    wbkgd(form_window, getbkgd(stdscr));
 #endif
+#if defined(COLOR_CURSES)	/* not defined in ncurses 1.8.7 */
+    wbkgd(form_window, getbkgd(stdscr));
+    wbkgdset(form_window, getbkgd(stdscr));
 #endif
 #endif /* USE_SLANG */
 
diff --git a/src/LYMail.c b/src/LYMail.c
index 9e93fba2..474f1a3a 100644
--- a/src/LYMail.c
+++ b/src/LYMail.c
@@ -459,7 +459,7 @@ PUBLIC void mailmsg ARGS4(int,cur, char *,owner_address,
 	    chmod(TRAVERSE_ERRORS, 0600);
 	}
 
-	fprintf(ofp, "%s	%s 	in %s\n",
+	fprintf(ofp, "%s\t%s \tin %s\n",
 		     links[cur].lname, links[cur].target, filename);
 	fclose(ofp);
     }
diff --git a/src/LYMain.c b/src/LYMain.c
index 8b4e48e6..5a4c3378 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -1091,7 +1091,7 @@ PUBLIC int main ARGS2(
 #ifdef EXP_CHARTRANS
     /*
      * Make sure we have the character sets declared.
-     * This will initialize the CHARTRANS handling. - kw
+     *  This will initialize the CHARTRANS handling. - KW
      */
     if (!LYCharSetsDeclared()) {
         fprintf(stderr, "\nLynx character sets not declared.\n\n");
@@ -1101,7 +1101,7 @@ PUBLIC int main ARGS2(
 
 #if defined(USEHASH)
     /*
-     *  If no alternate lynxile file was specified on
+     *  If no alternate lynx-style file was specified on
      *  the command line, see if it's in the environment.
      */
     if (!lynx_lss_file) {
@@ -1111,14 +1111,14 @@ PUBLIC int main ARGS2(
     }
 
     /*
-     *  If we still don't have a lynxile file,
+     *  If we still don't have a lynx-style file,
      *  use the userdefs.h definition.
      */
     if (!lynx_lss_file)
         StrAllocCopy(lynx_lss_file, LYNX_LSS_FILE);
 
     /*
-     *  Convert a '~' in the lynxile file path to $HOME.
+     *  Convert a '~' in the lynx-style file path to $HOME.
      */
     if ((cp = strchr(lynx_lss_file, '~'))) {
         char *temp = NULL;
@@ -1138,7 +1138,7 @@ PUBLIC int main ARGS2(
         FREE(temp);
     }
     /*
-     *  If the lynxile file is not available,
+     *  If the lynx-style file is not available,
      *  inform the user and exit.
      */
     if ((fp = fopen(lynx_lss_file, "r")) == NULL) {
@@ -1328,6 +1328,16 @@ PUBLIC int main ARGS2(
      */
     read_rc();
 
+#ifdef USE_SLANG
+    if (LYShowColor == TRUE &&
+	!(Lynx_Color_Flags & SL_LYNX_USE_COLOR)) {
+	Lynx_Color_Flags |= SL_LYNX_USE_COLOR;
+    } else if ((Lynx_Color_Flags & SL_LYNX_USE_COLOR) ||
+	       getenv("COLORTERM") != NULL) {
+	LYShowColor = TRUE;
+    }
+#endif /* USE_SLANG */
+
 #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
 #ifdef NEVER_ALLOW_REMOTE_EXEC
     if (local_exec) {
@@ -1736,8 +1746,10 @@ PRIVATE void parse_arg ARGS3(
 	       (strncmp(argv[0], "-assume_unrec_charset", 21) == 0)) {
 	BOOL local_flag = (argv[0][8] == 'l');
 	BOOL unrec_flag = (argv[0][8] == 'u');
+
 	if (nextarg) {
 	    int j;
+
 	    for (j = 0; cp[j]; j++)
 	        cp[j] = TOLOWER(cp[j]);
 	    if (local_flag) {
@@ -1861,6 +1873,7 @@ PRIVATE void parse_arg ARGS3(
 #ifdef USE_SLANG
     } else if (strncmp(argv[0], "-color", 6) == 0) {
         Lynx_Color_Flags |= SL_LYNX_USE_COLOR;
+	LYShowColor = TRUE;
 #endif /* USE_SLANG */
 
     } else if (strncmp(argv[0], "-crawl", 6) == 0) {
@@ -2168,6 +2181,9 @@ PRIVATE void parse_arg ARGS3(
 
     } else if (strncmp(argv[0], "-nocolor", 8) == 0) {
 	LYShowColor = FALSE;
+#ifdef USE_SLANG
+	Lynx_Color_Flags &= ~SL_LYNX_USE_COLOR;
+#endif
 
 #if defined(EXEC_LINKS) || defined(EXEC_SCRIPTS)
     } else if (strncmp(argv[0], "-noexec", 7) == 0) {
@@ -2438,7 +2454,7 @@ PRIVATE void parse_arg ARGS3(
 #if defined(USEHASH)
     } else if (strncmp(argv[0], "-lss", 4) == 0) {
         /*
-         *  Already read the alternate lynxile file
+	 *  Already read the alternate lynx-style file
          *  so just check whether we need to increment i
          */
         if (nextarg)
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index 69a618dd..4f93190f 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -521,7 +521,7 @@ try_again:
 			    }
 			    chmod(TRAVERSE_ERRORS, 0600);
 		        }
-		        fprintf(ofp, "%s %s	in %s\n",
+		        fprintf(ofp, "%s %s\tin %s\n",
 		       		     links[curdoc.link].lname, 
 				     links[curdoc.link].target,
 				     history[nhist-1].address);
diff --git a/src/LYNews.c b/src/LYNews.c
index d4dafc64..bd18e4ee 100644
--- a/src/LYNews.c
+++ b/src/LYNews.c
@@ -119,7 +119,7 @@ PUBLIC char *LYNewsPost ARGS2(
     move(2,0);
     scrollok(stdscr, TRUE);	/* Enable scrolling. */
     addstr("You will be posting to:");
-    addstr("\n	");
+    addstr("\n\t");
     addstr(NewsGroups);
     addch('\n');
 
diff --git a/src/LYOptions.c b/src/LYOptions.c
index ed870958..c142671d 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -1,6 +1,5 @@
 #include "HTUtils.h"
 #include "tcp.h"
-#include "userdefs.h"
 #include "HTFTP.h"
 #include "HTML.h"
 #include "LYCurses.h"
@@ -85,6 +84,7 @@ PUBLIC void options NOARGS
 #endif /* !VMS */
     char *choices[MAXCHOICES];
     int CurrentCharSet = current_char_set;
+    int CurrentShowColor = LYShowColor;
     BOOLEAN CurrentRawMode = LYRawMode;
     BOOLEAN AddValueAccepted = FALSE;
 
@@ -176,14 +176,6 @@ draw_options:
     addstr("display (C)haracter set      : ");
     addstr(LYchar_set_names[current_char_set]);
 
-    move(L_RAWMODE, 5);
-    addstr("Raw 8-bit or CJK m(O)de      : ");
-    addstr(LYRawMode ? "ON " : "OFF");
-
-    move(L_COLOR, B_COLOR);
-    addstr("show color (&)  : ");
-    addstr(LYShowColor ? "ON " : "OFF");
-
     move(L_LANGUAGE, 5);
     addstr("preferred document lan(G)uage: ");
     addstr((language && *language) ? language : "NONE");
@@ -192,6 +184,16 @@ draw_options:
     addstr("preferred document c(H)arset : ");
     addstr((pref_charset && *pref_charset) ? pref_charset : "NONE");
 
+    move(L_RAWMODE, 5);
+    addstr("Raw 8-bit or CJK m(O)de      : ");
+    addstr(LYRawMode ? "ON " : "OFF");
+
+#if defined(USE_SLANG) || defined(COLOR_CURSES)
+    move(L_COLOR, B_COLOR);
+    addstr("show color (&)  : ");
+    addstr(LYShowColor ? "ON " : "OFF");
+#endif /* USE_SLANG || COLOR_CURSES */
+
     move(L_BOOL_A, B_VIKEYS);
     addstr("V)I keys: ");
     addstr(vi_keys ? "ON " : "OFF");
@@ -871,7 +873,14 @@ draw_options:
 		response = ' ';
 		break;
 
-	    case '@':	/* Change show cursor setting. */
+#if defined(USE_SLANG) || defined(COLOR_CURSES)
+	    case '&':	/* Change show color setting. */
+#if defined(COLOR_CURSES)
+		if (!has_colors()) {
+		    option_statusline(COLOR_TOGGLE_DISABLED);
+		    break;
+		}
+#endif
 		/*
 		 *  Copy strings into choice array.
 		 */
@@ -880,16 +889,24 @@ draw_options:
 		choices[1] = NULL;
 		StrAllocCopy(choices[1], "ON ");
 		choices[2] = NULL;
-		LYShowCursor = boolean_choice(LYShowCursor,
-					      L_BOOL_B,
-					      C_SHOW_CURSOR,
+		LYShowColor = boolean_choice(LYShowColor,
+					      L_COLOR,
+					      C_COLOR,
 					      choices);
 		FREE(choices[0]);
 		FREE(choices[1]);
+		if (CurrentShowColor != LYShowColor) {
+		    CurrentShowColor = LYShowColor;
+#ifdef USE_SLANG
+		    SLtt_Use_Ansi_Colors = LYShowColor;
+#endif
+		    lynx_force_repaint();
+		}
 		response = ' ';
 		break;
+#endif /* USE_SLANG or COLOR_CURSES */
 
-	    case '&':	/* Change show color setting. */
+	    case '@':	/* Change show cursor setting. */
 		/*
 		 *  Copy strings into choice array.
 		 */
@@ -898,14 +915,13 @@ draw_options:
 		choices[1] = NULL;
 		StrAllocCopy(choices[1], "ON ");
 		choices[2] = NULL;
-		LYShowColor = boolean_choice(LYShowColor,
-					      L_COLOR,
-					      C_COLOR,
+		LYShowCursor = boolean_choice(LYShowCursor,
+					      L_BOOL_B,
+					      C_SHOW_CURSOR,
 					      choices);
 		FREE(choices[0]);
 		FREE(choices[1]);
 		response = ' ';
-		lynx_force_repaint();
 		break;
 
 	    case 'k':	/* Change keypad mode. */
@@ -1915,9 +1931,10 @@ PRIVATE int popup_choice ARGS6(
 #define getbkgd(w) wgetbkgd(w)	/* workaround pre-1.9.9g bug */
 #endif
     LYsubwindow(form_window);
-#ifdef getbkgd			/* not defined in ncurses 1.8.7 */
-    wbkgd(form_window, getbkgd(stdscr));
 #endif
+#if defined(COLOR_CURSES)	/* not defined in ncurses 1.8.7 */
+    wbkgd(form_window, getbkgd(stdscr));
+    wbkgdset(form_window, getbkgd(stdscr));
 #endif
 #endif /* USE_SLANG */
 
diff --git a/src/LYOptions.h b/src/LYOptions.h
index f25722e0..fc6e63c2 100644
--- a/src/LYOptions.h
+++ b/src/LYOptions.h
@@ -24,14 +24,14 @@ extern void edit_bookmarks NOPARAMS;
 #define L_FTPSTYPE	 5
 #define L_MAIL_ADDRESS	 6
 #define L_SSEARCH	 7
-#define L_LANGUAGE	 8
-#define L_PREF_CHARSET	 9
-#define L_CHARSET	10
+#define L_CHARSET	 8
+#define L_LANGUAGE	 9
+#define L_PREF_CHARSET	10
 #define L_RAWMODE	11
 
-#define L_COLOR         L_RAWMODE
-#define B_COLOR         44
-#define C_COLOR         62
+#define L_COLOR		L_RAWMODE
+#define B_COLOR		44
+#define C_COLOR		62
 
 #define L_BOOL_A	12
 #define B_VIKEYS	5
diff --git a/src/LYReadCFG.c b/src/LYReadCFG.c
index 8fdeaa0e..7a6f16c2 100644
--- a/src/LYReadCFG.c
+++ b/src/LYReadCFG.c
@@ -349,7 +349,8 @@ PRIVATE int check_color ARGS1(
 /*
  *  Exit routine for failed COLOR parsing.
  */
-PRIVATE void exit_with_color_syntax NOARGS
+PRIVATE void exit_with_color_syntax ARGS1(
+	char *,	error_line)
 {
     unsigned int i;
     fprintf (stderr, "\
@@ -364,6 +365,9 @@ Here FOREGROUND and BACKGROUND must be one of:\n"
 		Color_Strings[i], Color_Strings[i + 1], 
 		Color_Strings[i + 2], Color_Strings[i + 3]);
     }
+    fprintf (stderr, "\
+Offending line:\n\
+%s\n",error_line);
 
 #ifndef NOSIGHUP
     (void) signal(SIGHUP, SIG_DFL);
@@ -387,6 +391,12 @@ PRIVATE void parse_color ARGS1(
 {
     int color;
     char *fg, *bg;
+    char parse_color_line[501];
+
+    if (strlen(buffer) < sizeof(parse_color_line))
+	strcpy(parse_color_line, buffer);
+    else
+	strcpy(parse_color_line, "Color config line too long");
 
     /*
      *  We are expecting a line of the form: 
@@ -394,22 +404,22 @@ PRIVATE void parse_color ARGS1(
      */
     color = atoi (buffer);
     if (NULL == (fg = find_colon(buffer)))
-        exit_with_color_syntax();
+        exit_with_color_syntax(parse_color_line);
     *fg++ = 0;
 
     if (NULL == (bg = find_colon(fg)))
-        exit_with_color_syntax();
+        exit_with_color_syntax(parse_color_line);
     *bg++ = 0;
 
 #if defined(USE_SLANG)
     if ((-1 == check_color(fg)) ||
         (-1 == check_color(bg)))
-	exit_with_color_syntax();
+	exit_with_color_syntax(parse_color_line);
 
     SLtt_set_color(color, NULL, fg, bg);
 #else
     if (lynx_chg_color(color, check_color(fg), check_color(bg)) < 0)
-	exit_with_color_syntax();
+	exit_with_color_syntax(parse_color_line);
 #endif
 }
 #endif /* USE_COLOR_TABLE */
diff --git a/src/LYTraversal.c b/src/LYTraversal.c
index c9c7627b..968d6e74 100644
--- a/src/LYTraversal.c
+++ b/src/LYTraversal.c
@@ -99,7 +99,7 @@ PUBLIC void add_to_traverse_list ARGS2(char *,fname, char *,prev_link_name)
     }
     chmod(TRAVERSE_FOUND_FILE, 0600);
 
-    fprintf(ifp,"%s	%s\n",fname, prev_link_name);
+    fprintf(ifp,"%s\t%s\n",fname, prev_link_name);
 
     fclose(ifp);
 }
@@ -119,10 +119,10 @@ PUBLIC void dump_traversal_history NOARGS
     chmod(TRAVERSE_FILE, 0600);
 
     fprintf(ifp, "\n\nTRAVERSAL WAS INTERUPTED\n\n\
-	    here is a list of the history stack so that you may rebuild\n\n");
+\t    here is a list of the history stack so that you may rebuild\n\n");
 
     for (x = nhist-1; x >= 0; x--) {
-	fprintf(ifp,"%s	%s\n", history[x].title, history[x].address);
+	fprintf(ifp,"%s\t%s\n", history[x].title, history[x].address);
     }
 
     fclose(ifp);
diff --git a/src/LYrcFile.c b/src/LYrcFile.c
index c462715e..3b59fbd9 100644
--- a/src/LYrcFile.c
+++ b/src/LYrcFile.c
@@ -335,6 +335,24 @@ PUBLIC void read_rc NOPARAMS
 	        show_dotfiles = TRUE;
 	    else
 	        show_dotfiles = FALSE;
+#if 0	/* UNUSED */
+#if defined(USE_SLANG) || defined(COLOR_CURSES)
+	/*
+	 *  Show color.
+	 */
+	} else if ((cp = LYstrstr(line_buffer, "show_color")) != NULL &&
+		   cp-line_buffer < number_sign) {
+
+	    if ((cp2 = (char * )strchr(cp, '=')) != NULL)
+		cp = cp2 + 1;
+	    while (isspace(*cp))
+		cp++;  /* get rid of spaces */
+	    if (!strncasecomp(cp, "off", 3))
+		LYShowColor = FALSE;
+	    else
+		LYShowColor = TRUE;
+#endif /* USE_SLANG || COLOR_CURSES */
+#endif /* UNUSED */
 
 	/*
 	 *  Select popups.
@@ -651,6 +669,19 @@ PUBLIC int save_rc NOPARAMS
     fprintf(fp, "preferred_charset=%s\n\n",
     		(pref_charset ? pref_charset : ""));
 
+#if defined(USE_SLANG) || defined(COLOR_CURSES)
+    /*
+     *  Show color.
+     */
+    fprintf(fp, "\
+# show_color specifies whether to show colors when available, or assume a\n\
+# monochrome terminal.  A value of \"on\" will force color mode on, while\n\
+# a value of \"off\" will force it off.  The default can be overridden via\n\
+# the -color and -nocolor command line switches or (if built with slang) the\n\
+# COLORTERM environment variable.\n");
+    fprintf(fp, "show_color=%s\n\n", (LYShowColor ? "on" : "off"));
+#endif /* USE_SLANG || COLOR_CURSES */
+
     /*
      *  VI keys.
      */