G
Guest
Guest
Archived from groups: rec.games.roguelike.nethack (More info?)
Hi!
Here is a patch which I have intended to write for a very long time. It
disables NetHack's default tty low-intensity color replacement code and
lets user to define which colors should be used. No more blue corridors
on Unix, you can change black to display as bright red instead.
This patch is based on MSDOS videoshades-code and Jason Short's color
bright black-patch. Patch should work on any platform which uses
win/tty/ for graphics. I have tested this on OS/2 and Linux.
Slash'EM version can be found here:
http://sourceforge.net/tracker/index.php?func=detail&aid=215062&group_id=9746&atid=109746
And finally, here comes the patch.
- Pekka
diff -purd -X excluded nethack-3.4.3-vanilla/doc/Guidebook.mn
nethack-3.4.3/doc/Guidebook.mn
--- nethack-3.4.3-vanilla/doc/Guidebook.mn 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/doc/Guidebook.mn 2005-08-09 20:42:04.000000000 +0300
@@ -2310,6 +2310,10 @@ Set the color palette for PC systems usi
The order of colors is red, green, brown, blue, magenta, cyan,
bright.white, bright.red, bright.green, yellow, bright.blue,
bright.magenta, and bright.cyan.
+Other systems compiled with TTY_GRAPHICS and VIDEOSHADES allow defining
+three more colors. The order of colors is red, green, brown, blue,
+magenta, cyan, gray, black, bright.red, bright.green, yellow,
+bright.blue, bright.magenta, bright.cyan and white.
Cannot be set with the `O' command.
.lp videoshades
Set the intensity level of the three gray scales available
diff -purd -X excluded nethack-3.4.3-vanilla/doc/Guidebook.tex
nethack-3.4.3/doc/Guidebook.tex
--- nethack-3.4.3-vanilla/doc/Guidebook.tex 2003-12-08
01:39:13.000000000 +0200
+++ nethack-3.4.3/doc/Guidebook.tex 2005-08-09 20:42:34.000000000 +0300
@@ -2847,6 +2847,10 @@ Set the color palette for PC systems usi
The order of colors is red, green, brown, blue, magenta, cyan,
bright.white, bright.red, bright.green, yellow, bright.blue,
bright.magenta, and bright.cyan.
+Other systems compiled with TTY_GRAPHICS and VIDEOSHADES allow defining
+three more colors. The order of colors is red, green, brown, blue,
+magenta, cyan, gray, black, bright.red, bright.green, yellow,
+bright.blue, bright.magenta, bright.cyan and white.
Cannot be set with the `{\tt O}' command.
\end{sloppypar}
%.lp
diff -purd -X excluded nethack-3.4.3-vanilla/include/color.h
nethack-3.4.3/include/color.h
--- nethack-3.4.3-vanilla/include/color.h 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/include/color.h 2005-08-09 07:18:02.000000000 +0300
@@ -11,7 +11,12 @@
* exceptions, these are listed below. Bright black doesn't mean very
* much, so it is used as the "default" foreground color of the screen.
*/
-#define CLR_BLACK 0
+
+#ifndef VIDEOSHADES
+# define CLR_BLACK 0
+#else
+# define CLR_BLACK 8
+#endif
#define CLR_RED 1
#define CLR_GREEN 2
#define CLR_BROWN 3 /* on IBM, low-intensity yellow is brown */
@@ -19,7 +24,11 @@
#define CLR_MAGENTA 5
#define CLR_CYAN 6
#define CLR_GRAY 7 /* low-intensity white */
-#define NO_COLOR 8
+#ifndef VIDEOSHADES
+# define NO_COLOR 8
+#else
+# define NO_COLOR 0
+#endif
#define CLR_ORANGE 9
#define CLR_BRIGHT_GREEN 10
#define CLR_YELLOW 11
@@ -49,4 +58,8 @@
#define DRAGON_SILVER CLR_BRIGHT_CYAN
#define HI_ZAP CLR_BRIGHT_BLUE
+#ifndef MSDOS
+char ttycolors[CLR_MAX]; /* also used/set in options.c */
+#endif
+
#endif /* COLOR_H */
diff -purd -X excluded nethack-3.4.3-vanilla/include/config.h
nethack-3.4.3/include/config.h
--- nethack-3.4.3-vanilla/include/config.h 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/include/config.h 2005-08-09 18:53:28.000000000 +0300
@@ -132,6 +132,9 @@
# endif
#endif
+#ifdef TTY_GRAPHICS
+# define VIDEOSHADES
+#endif
/*
* Section 2: Some global parameters and filenames.
diff -purd -X excluded nethack-3.4.3-vanilla/src/options.c
nethack-3.4.3/src/options.c
--- nethack-3.4.3-vanilla/src/options.c 2003-12-08 01:39:13.000000000 +0200
+++ nethack-3.4.3/src/options.c 2005-08-09 07:18:02.000000000 +0300
@@ -323,9 +323,11 @@ static struct Comp_Opt
#ifdef VIDEOSHADES
{ "videocolors", "color mappings for internal screen routines",
40, DISP_IN_GAME },
+#ifdef MSDOS
{ "videoshades", "gray shades to map to black/gray/white",
32, DISP_IN_GAME },
#endif
+#endif
#ifdef WIN32CON
{"subkeyvalue", "override keystroke value", 7, SET_IN_FILE},
#endif
@@ -1863,6 +1865,7 @@ goodfruit:
badoption(opts);
return;
}
+# ifdef MSDOS
/* videoshades:string */
fullname = "videoshades";
if (match_optname(opts, fullname, 6, TRUE)) {
@@ -1877,6 +1880,7 @@ goodfruit:
badoption(opts);
return;
}
+# endif
#endif /* VIDEOSHADES */
#ifdef MSDOS
# ifdef NO_TERMS
@@ -3108,6 +3112,7 @@ char *buf;
Sprintf(buf, "%s", to_be_done);
#endif
#ifdef VIDEOSHADES
+# ifdef MSDOS
else if (!strcmp(optname, "videoshades"))
Sprintf(buf, "%s-%s-%s", shade[0],shade[1],shade[2]);
else if (!strcmp(optname, "videocolors"))
@@ -3119,6 +3124,18 @@ char *buf;
ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
ttycolors[CLR_BRIGHT_MAGENTA],
ttycolors[CLR_BRIGHT_CYAN]);
+# else
+ else if (!strcmp(optname, "videocolors"))
+ Sprintf(buf, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",
+ ttycolors[CLR_RED], ttycolors[CLR_GREEN],
+ ttycolors[CLR_BROWN], ttycolors[CLR_BLUE],
+ ttycolors[CLR_MAGENTA], ttycolors[CLR_CYAN],
+ ttycolors[CLR_GRAY], ttycolors[CLR_BLACK],
+ ttycolors[CLR_ORANGE], ttycolors[CLR_BRIGHT_GREEN],
+ ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
+ ttycolors[CLR_BRIGHT_MAGENTA],
+ ttycolors[CLR_BRIGHT_CYAN], ttycolors[CLR_WHITE]);
+# endif /* MSDOS */
#endif /* VIDEOSHADES */
else if (!strcmp(optname, "windowtype"))
Sprintf(buf, "%s", windowprocs.name);
diff -purd -X excluded nethack-3.4.3-vanilla/win/tty/termcap.c
nethack-3.4.3/win/tty/termcap.c
--- nethack-3.4.3-vanilla/win/tty/termcap.c 2003-12-08
01:39:14.000000000 +0200
+++ nethack-3.4.3/win/tty/termcap.c 2005-08-09 21:42:16.000000000 +0300
@@ -87,6 +87,117 @@ STATIC_VAR char tgotobuf[20];
# endif
#endif /* TERMLIB */
+#ifndef MSDOS
+
+STATIC_DCL void NDECL(init_ttycolor);
+
+#ifdef VIDEOSHADES
+boolean colorflag = FALSE; /* colors are initialized */
+#endif
+
+void
+init_ttycolor()
+{
+#ifdef VIDEOSHADES
+ if (!colorflag) {
+#endif
+ ttycolors[CLR_RED] = CLR_RED;
+ ttycolors[CLR_GREEN] = CLR_GREEN;
+ ttycolors[CLR_BROWN] = CLR_BROWN;
+ ttycolors[CLR_BLUE] = CLR_BLUE;
+ ttycolors[CLR_MAGENTA] = CLR_MAGENTA;
+ ttycolors[CLR_CYAN] = CLR_CYAN;
+ ttycolors[CLR_GRAY] = CLR_GRAY;
+ ttycolors[CLR_BLACK] = CLR_BLACK;
+ ttycolors[CLR_ORANGE] = CLR_ORANGE;
+ ttycolors[CLR_BRIGHT_GREEN] = CLR_BRIGHT_GREEN;
+ ttycolors[CLR_YELLOW] = CLR_YELLOW;
+ ttycolors[CLR_BRIGHT_BLUE] = CLR_BRIGHT_BLUE;
+ ttycolors[CLR_BRIGHT_MAGENTA] = CLR_BRIGHT_MAGENTA;
+ ttycolors[CLR_BRIGHT_CYAN] = CLR_BRIGHT_CYAN;
+ ttycolors[CLR_WHITE] = CLR_WHITE;
+#ifdef VIDEOSHADES
+ }
+#endif
+}
+
+# ifdef VIDEOSHADES
+
+static int FDECL(convert_uchars,(char *, uchar *, int));
+
+/*
+ * OPTIONS=videocolors:1-2-3-4-5-6-7-8-9-10-11-12-13-14-15
+ * Left to right assignments for:
+ * red green brown blue magenta cyan gray black
+ * orange br.green yellow br.blue br.mag br.cyan white
+ */
+int assign_videocolors(char *colorvals)
+{
+ int i,icolor;
+ uchar *tmpcolor;
+
+ init_ttycolor();
+
+ i = strlen(colorvals);
+ tmpcolor = (uchar *)alloc(i);
+ if (convert_uchars(colorvals,tmpcolor,i) < 0) return FALSE;
+
+ icolor = CLR_RED;
+ for( i = 0; tmpcolor != 0; ++i) {
+ if (icolor <= CLR_WHITE)
+ ttycolors[icolor++] = tmpcolor;
+ }
+
+ colorflag = TRUE;
+ free((genericptr_t)tmpcolor);
+ return 1;
+}
+
+static int
+convert_uchars(bufp,list,size)
+ char *bufp; /* current pointer */
+ uchar *list; /* return list */
+ int size;
+{
+ unsigned int num = 0;
+ int count = 0;
+
+ list[count] = 0;
+
+ while (1) {
+ switch(*bufp) {
+ case ' ': case '\0':
+ case '\t': case '-':
+ case '\n':
+ if (num) {
+ list[count++] = num;
+ list[count] = 0;
+ num = 0;
+ }
+ if ((count==size) || !*bufp) return count;
+ bufp++;
+ break;
+ case '#':
+ if (num) {
+ list[count++] = num;
+ list[count] = 0;
+ }
+ return count;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ num = num*10 + (*bufp-'0');
+ if (num > 15) return -1;
+ bufp++;
+ break;
+ default: return -1;
+ }
+ }
+ /*NOTREACHED*/
+}
+# endif /* !MSDOS */
+# endif /* VIDEOSHADES*/
+
#ifdef OVLB
void
@@ -98,12 +209,19 @@ int *wid, *hgt;
register const char *term;
register char *tptr;
char *tbufptr, *pc;
+#endif
+
+#ifdef TEXTCOLOR
+ init_ttycolor();
+#endif
+
+#ifdef TERMLIB
# ifdef VMS
term = verify_termcap();
if (!term)
# endif
- term = getenv("TERM");
+ term = getenv("TERM");
# if defined(TOS) && defined(__GNUC__)
if (!term)
@@ -177,10 +295,12 @@ int *wid, *hgt;
if (i != CLR_BLACK) {
hilites[i|BRIGHT] = (char *) alloc(sizeof("\033[1;3%dm"));
Sprintf(hilites[i|BRIGHT], "\033[1;3%dm", i);
+# ifndef VIDEOSHADES
if (i != CLR_GRAY)
-# ifdef MICRO
+# ifdef MICRO
if (i == CLR_BLUE) hilites[CLR_BLUE] = hilites[CLR_BLUE|BRIGHT];
else
+# endif
# endif
{
hilites = (char *) alloc(sizeof("\033[0;3%dm"));
@@ -446,10 +566,14 @@ tty_ascgraphics_hilite_fixup()
if (c != CLR_BLACK) {
hilites[c|BRIGHT] = (char *) alloc(sizeof("\033[1;3%dm"));
Sprintf(hilites[c|BRIGHT], "\033[1;3%dm", c);
+#ifndef VIDEOSHADES
if (c != CLR_GRAY) {
+#endif
hilites[c] = (char *) alloc(sizeof("\033[0;3%dm"));
Sprintf(hilites[c], "\033[0;3%dm", c);
+#ifndef VIDEOSHADES
}
+#endif
}
}
#endif /* PC9800 */
@@ -840,9 +964,14 @@ extern char *tparm();
#endif
# ifdef COLOR_BLACK /* trust include file */
+#ifndef VIDEOSHADES
#undef COLOR_BLACK
+#endif
# else
# ifndef _M_UNIX /* guess BGR */
+#ifdef VIDEOSHADES
+#define COLOR_BLACK 0
+#endif
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_CYAN 3
@@ -860,7 +989,9 @@ extern char *tparm();
#define COLOR_WHITE 7
# endif
# endif
+#ifndef VIDEOSHADES
#define COLOR_BLACK COLOR_BLUE
+#endif
const int ti_map[8] = {
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
@@ -883,10 +1014,14 @@ init_hilite()
for (c = 0; c < CLR_MAX / 2; c++) {
scratch = tparm(setf, ti_map[c]);
+#ifndef VIDEOSHADES
if (c != CLR_GRAY) {
+#endif
hilites[c] = (char *) alloc(strlen(scratch) + 1);
Strcpy(hilites[c], scratch);
+#ifndef VIDEOSHADES
}
+#endif
if (c != CLR_BLACK) {
hilites[c|BRIGHT] = (char*) alloc(strlen(scratch)+strlen(MD)+1);
Strcpy(hilites[c|BRIGHT], MD);
@@ -1018,7 +1153,7 @@ init_hilite()
for (c = 0; c < SIZE(hilites); c++)
/* avoid invisibility */
if ((backg & ~BRIGHT) != c) {
-# ifdef MICRO
+# if defined(MICRO) && !defined(VIDEOSHADES)
if (c == CLR_BLUE) continue;
# endif
if (c == foreg)
@@ -1034,7 +1169,7 @@ init_hilite()
}
}
-# ifdef MICRO
+# if defined(MICRO) && !defined(VIDEOSHADES)
/* brighten low-visibility colors */
hilites[CLR_BLUE] = hilites[CLR_BLUE|BRIGHT];
# endif
@@ -1146,7 +1281,11 @@ void
term_start_color(color)
int color;
{
+#ifdef VIDEOSHADES
+ xputs(hilites[ttycolors[color]]);
+#else
xputs(hilites[color]);
+#endif
}
Hi!
Here is a patch which I have intended to write for a very long time. It
disables NetHack's default tty low-intensity color replacement code and
lets user to define which colors should be used. No more blue corridors
on Unix, you can change black to display as bright red instead.
This patch is based on MSDOS videoshades-code and Jason Short's color
bright black-patch. Patch should work on any platform which uses
win/tty/ for graphics. I have tested this on OS/2 and Linux.
Slash'EM version can be found here:
http://sourceforge.net/tracker/index.php?func=detail&aid=215062&group_id=9746&atid=109746
And finally, here comes the patch.
- Pekka
diff -purd -X excluded nethack-3.4.3-vanilla/doc/Guidebook.mn
nethack-3.4.3/doc/Guidebook.mn
--- nethack-3.4.3-vanilla/doc/Guidebook.mn 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/doc/Guidebook.mn 2005-08-09 20:42:04.000000000 +0300
@@ -2310,6 +2310,10 @@ Set the color palette for PC systems usi
The order of colors is red, green, brown, blue, magenta, cyan,
bright.white, bright.red, bright.green, yellow, bright.blue,
bright.magenta, and bright.cyan.
+Other systems compiled with TTY_GRAPHICS and VIDEOSHADES allow defining
+three more colors. The order of colors is red, green, brown, blue,
+magenta, cyan, gray, black, bright.red, bright.green, yellow,
+bright.blue, bright.magenta, bright.cyan and white.
Cannot be set with the `O' command.
.lp videoshades
Set the intensity level of the three gray scales available
diff -purd -X excluded nethack-3.4.3-vanilla/doc/Guidebook.tex
nethack-3.4.3/doc/Guidebook.tex
--- nethack-3.4.3-vanilla/doc/Guidebook.tex 2003-12-08
01:39:13.000000000 +0200
+++ nethack-3.4.3/doc/Guidebook.tex 2005-08-09 20:42:34.000000000 +0300
@@ -2847,6 +2847,10 @@ Set the color palette for PC systems usi
The order of colors is red, green, brown, blue, magenta, cyan,
bright.white, bright.red, bright.green, yellow, bright.blue,
bright.magenta, and bright.cyan.
+Other systems compiled with TTY_GRAPHICS and VIDEOSHADES allow defining
+three more colors. The order of colors is red, green, brown, blue,
+magenta, cyan, gray, black, bright.red, bright.green, yellow,
+bright.blue, bright.magenta, bright.cyan and white.
Cannot be set with the `{\tt O}' command.
\end{sloppypar}
%.lp
diff -purd -X excluded nethack-3.4.3-vanilla/include/color.h
nethack-3.4.3/include/color.h
--- nethack-3.4.3-vanilla/include/color.h 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/include/color.h 2005-08-09 07:18:02.000000000 +0300
@@ -11,7 +11,12 @@
* exceptions, these are listed below. Bright black doesn't mean very
* much, so it is used as the "default" foreground color of the screen.
*/
-#define CLR_BLACK 0
+
+#ifndef VIDEOSHADES
+# define CLR_BLACK 0
+#else
+# define CLR_BLACK 8
+#endif
#define CLR_RED 1
#define CLR_GREEN 2
#define CLR_BROWN 3 /* on IBM, low-intensity yellow is brown */
@@ -19,7 +24,11 @@
#define CLR_MAGENTA 5
#define CLR_CYAN 6
#define CLR_GRAY 7 /* low-intensity white */
-#define NO_COLOR 8
+#ifndef VIDEOSHADES
+# define NO_COLOR 8
+#else
+# define NO_COLOR 0
+#endif
#define CLR_ORANGE 9
#define CLR_BRIGHT_GREEN 10
#define CLR_YELLOW 11
@@ -49,4 +58,8 @@
#define DRAGON_SILVER CLR_BRIGHT_CYAN
#define HI_ZAP CLR_BRIGHT_BLUE
+#ifndef MSDOS
+char ttycolors[CLR_MAX]; /* also used/set in options.c */
+#endif
+
#endif /* COLOR_H */
diff -purd -X excluded nethack-3.4.3-vanilla/include/config.h
nethack-3.4.3/include/config.h
--- nethack-3.4.3-vanilla/include/config.h 2003-12-08 01:39:13.000000000
+0200
+++ nethack-3.4.3/include/config.h 2005-08-09 18:53:28.000000000 +0300
@@ -132,6 +132,9 @@
# endif
#endif
+#ifdef TTY_GRAPHICS
+# define VIDEOSHADES
+#endif
/*
* Section 2: Some global parameters and filenames.
diff -purd -X excluded nethack-3.4.3-vanilla/src/options.c
nethack-3.4.3/src/options.c
--- nethack-3.4.3-vanilla/src/options.c 2003-12-08 01:39:13.000000000 +0200
+++ nethack-3.4.3/src/options.c 2005-08-09 07:18:02.000000000 +0300
@@ -323,9 +323,11 @@ static struct Comp_Opt
#ifdef VIDEOSHADES
{ "videocolors", "color mappings for internal screen routines",
40, DISP_IN_GAME },
+#ifdef MSDOS
{ "videoshades", "gray shades to map to black/gray/white",
32, DISP_IN_GAME },
#endif
+#endif
#ifdef WIN32CON
{"subkeyvalue", "override keystroke value", 7, SET_IN_FILE},
#endif
@@ -1863,6 +1865,7 @@ goodfruit:
badoption(opts);
return;
}
+# ifdef MSDOS
/* videoshades:string */
fullname = "videoshades";
if (match_optname(opts, fullname, 6, TRUE)) {
@@ -1877,6 +1880,7 @@ goodfruit:
badoption(opts);
return;
}
+# endif
#endif /* VIDEOSHADES */
#ifdef MSDOS
# ifdef NO_TERMS
@@ -3108,6 +3112,7 @@ char *buf;
Sprintf(buf, "%s", to_be_done);
#endif
#ifdef VIDEOSHADES
+# ifdef MSDOS
else if (!strcmp(optname, "videoshades"))
Sprintf(buf, "%s-%s-%s", shade[0],shade[1],shade[2]);
else if (!strcmp(optname, "videocolors"))
@@ -3119,6 +3124,18 @@ char *buf;
ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
ttycolors[CLR_BRIGHT_MAGENTA],
ttycolors[CLR_BRIGHT_CYAN]);
+# else
+ else if (!strcmp(optname, "videocolors"))
+ Sprintf(buf, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",
+ ttycolors[CLR_RED], ttycolors[CLR_GREEN],
+ ttycolors[CLR_BROWN], ttycolors[CLR_BLUE],
+ ttycolors[CLR_MAGENTA], ttycolors[CLR_CYAN],
+ ttycolors[CLR_GRAY], ttycolors[CLR_BLACK],
+ ttycolors[CLR_ORANGE], ttycolors[CLR_BRIGHT_GREEN],
+ ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
+ ttycolors[CLR_BRIGHT_MAGENTA],
+ ttycolors[CLR_BRIGHT_CYAN], ttycolors[CLR_WHITE]);
+# endif /* MSDOS */
#endif /* VIDEOSHADES */
else if (!strcmp(optname, "windowtype"))
Sprintf(buf, "%s", windowprocs.name);
diff -purd -X excluded nethack-3.4.3-vanilla/win/tty/termcap.c
nethack-3.4.3/win/tty/termcap.c
--- nethack-3.4.3-vanilla/win/tty/termcap.c 2003-12-08
01:39:14.000000000 +0200
+++ nethack-3.4.3/win/tty/termcap.c 2005-08-09 21:42:16.000000000 +0300
@@ -87,6 +87,117 @@ STATIC_VAR char tgotobuf[20];
# endif
#endif /* TERMLIB */
+#ifndef MSDOS
+
+STATIC_DCL void NDECL(init_ttycolor);
+
+#ifdef VIDEOSHADES
+boolean colorflag = FALSE; /* colors are initialized */
+#endif
+
+void
+init_ttycolor()
+{
+#ifdef VIDEOSHADES
+ if (!colorflag) {
+#endif
+ ttycolors[CLR_RED] = CLR_RED;
+ ttycolors[CLR_GREEN] = CLR_GREEN;
+ ttycolors[CLR_BROWN] = CLR_BROWN;
+ ttycolors[CLR_BLUE] = CLR_BLUE;
+ ttycolors[CLR_MAGENTA] = CLR_MAGENTA;
+ ttycolors[CLR_CYAN] = CLR_CYAN;
+ ttycolors[CLR_GRAY] = CLR_GRAY;
+ ttycolors[CLR_BLACK] = CLR_BLACK;
+ ttycolors[CLR_ORANGE] = CLR_ORANGE;
+ ttycolors[CLR_BRIGHT_GREEN] = CLR_BRIGHT_GREEN;
+ ttycolors[CLR_YELLOW] = CLR_YELLOW;
+ ttycolors[CLR_BRIGHT_BLUE] = CLR_BRIGHT_BLUE;
+ ttycolors[CLR_BRIGHT_MAGENTA] = CLR_BRIGHT_MAGENTA;
+ ttycolors[CLR_BRIGHT_CYAN] = CLR_BRIGHT_CYAN;
+ ttycolors[CLR_WHITE] = CLR_WHITE;
+#ifdef VIDEOSHADES
+ }
+#endif
+}
+
+# ifdef VIDEOSHADES
+
+static int FDECL(convert_uchars,(char *, uchar *, int));
+
+/*
+ * OPTIONS=videocolors:1-2-3-4-5-6-7-8-9-10-11-12-13-14-15
+ * Left to right assignments for:
+ * red green brown blue magenta cyan gray black
+ * orange br.green yellow br.blue br.mag br.cyan white
+ */
+int assign_videocolors(char *colorvals)
+{
+ int i,icolor;
+ uchar *tmpcolor;
+
+ init_ttycolor();
+
+ i = strlen(colorvals);
+ tmpcolor = (uchar *)alloc(i);
+ if (convert_uchars(colorvals,tmpcolor,i) < 0) return FALSE;
+
+ icolor = CLR_RED;
+ for( i = 0; tmpcolor != 0; ++i) {
+ if (icolor <= CLR_WHITE)
+ ttycolors[icolor++] = tmpcolor;
+ }
+
+ colorflag = TRUE;
+ free((genericptr_t)tmpcolor);
+ return 1;
+}
+
+static int
+convert_uchars(bufp,list,size)
+ char *bufp; /* current pointer */
+ uchar *list; /* return list */
+ int size;
+{
+ unsigned int num = 0;
+ int count = 0;
+
+ list[count] = 0;
+
+ while (1) {
+ switch(*bufp) {
+ case ' ': case '\0':
+ case '\t': case '-':
+ case '\n':
+ if (num) {
+ list[count++] = num;
+ list[count] = 0;
+ num = 0;
+ }
+ if ((count==size) || !*bufp) return count;
+ bufp++;
+ break;
+ case '#':
+ if (num) {
+ list[count++] = num;
+ list[count] = 0;
+ }
+ return count;
+ case '0': case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ case '8': case '9':
+ num = num*10 + (*bufp-'0');
+ if (num > 15) return -1;
+ bufp++;
+ break;
+ default: return -1;
+ }
+ }
+ /*NOTREACHED*/
+}
+# endif /* !MSDOS */
+# endif /* VIDEOSHADES*/
+
#ifdef OVLB
void
@@ -98,12 +209,19 @@ int *wid, *hgt;
register const char *term;
register char *tptr;
char *tbufptr, *pc;
+#endif
+
+#ifdef TEXTCOLOR
+ init_ttycolor();
+#endif
+
+#ifdef TERMLIB
# ifdef VMS
term = verify_termcap();
if (!term)
# endif
- term = getenv("TERM");
+ term = getenv("TERM");
# if defined(TOS) && defined(__GNUC__)
if (!term)
@@ -177,10 +295,12 @@ int *wid, *hgt;
if (i != CLR_BLACK) {
hilites[i|BRIGHT] = (char *) alloc(sizeof("\033[1;3%dm"));
Sprintf(hilites[i|BRIGHT], "\033[1;3%dm", i);
+# ifndef VIDEOSHADES
if (i != CLR_GRAY)
-# ifdef MICRO
+# ifdef MICRO
if (i == CLR_BLUE) hilites[CLR_BLUE] = hilites[CLR_BLUE|BRIGHT];
else
+# endif
# endif
{
hilites = (char *) alloc(sizeof("\033[0;3%dm"));
@@ -446,10 +566,14 @@ tty_ascgraphics_hilite_fixup()
if (c != CLR_BLACK) {
hilites[c|BRIGHT] = (char *) alloc(sizeof("\033[1;3%dm"));
Sprintf(hilites[c|BRIGHT], "\033[1;3%dm", c);
+#ifndef VIDEOSHADES
if (c != CLR_GRAY) {
+#endif
hilites[c] = (char *) alloc(sizeof("\033[0;3%dm"));
Sprintf(hilites[c], "\033[0;3%dm", c);
+#ifndef VIDEOSHADES
}
+#endif
}
}
#endif /* PC9800 */
@@ -840,9 +964,14 @@ extern char *tparm();
#endif
# ifdef COLOR_BLACK /* trust include file */
+#ifndef VIDEOSHADES
#undef COLOR_BLACK
+#endif
# else
# ifndef _M_UNIX /* guess BGR */
+#ifdef VIDEOSHADES
+#define COLOR_BLACK 0
+#endif
#define COLOR_BLUE 1
#define COLOR_GREEN 2
#define COLOR_CYAN 3
@@ -860,7 +989,9 @@ extern char *tparm();
#define COLOR_WHITE 7
# endif
# endif
+#ifndef VIDEOSHADES
#define COLOR_BLACK COLOR_BLUE
+#endif
const int ti_map[8] = {
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
@@ -883,10 +1014,14 @@ init_hilite()
for (c = 0; c < CLR_MAX / 2; c++) {
scratch = tparm(setf, ti_map[c]);
+#ifndef VIDEOSHADES
if (c != CLR_GRAY) {
+#endif
hilites[c] = (char *) alloc(strlen(scratch) + 1);
Strcpy(hilites[c], scratch);
+#ifndef VIDEOSHADES
}
+#endif
if (c != CLR_BLACK) {
hilites[c|BRIGHT] = (char*) alloc(strlen(scratch)+strlen(MD)+1);
Strcpy(hilites[c|BRIGHT], MD);
@@ -1018,7 +1153,7 @@ init_hilite()
for (c = 0; c < SIZE(hilites); c++)
/* avoid invisibility */
if ((backg & ~BRIGHT) != c) {
-# ifdef MICRO
+# if defined(MICRO) && !defined(VIDEOSHADES)
if (c == CLR_BLUE) continue;
# endif
if (c == foreg)
@@ -1034,7 +1169,7 @@ init_hilite()
}
}
-# ifdef MICRO
+# if defined(MICRO) && !defined(VIDEOSHADES)
/* brighten low-visibility colors */
hilites[CLR_BLUE] = hilites[CLR_BLUE|BRIGHT];
# endif
@@ -1146,7 +1281,11 @@ void
term_start_color(color)
int color;
{
+#ifdef VIDEOSHADES
+ xputs(hilites[ttycolors[color]]);
+#else
xputs(hilites[color]);
+#endif
}