some updates to nttty.c
Changes to be committed: modified: sys/winnt/nttty.c better attribute support more functional inverse support
This commit is contained in:
+193
-189
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 nttty.c $NHDT-Date: 1449893262 2015/12/12 04:07:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.64 $ */
|
/* NetHack 3.6 nttty.c $NHDT-Date: 1454281677 2016/01/31 23:07:57 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.65 $ */
|
||||||
/* Copyright (c) NetHack PC Development Team 1993 */
|
/* Copyright (c) NetHack PC Development Team 1993 */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -20,11 +20,6 @@
|
|||||||
#include <sys\stat.h>
|
#include <sys\stat.h>
|
||||||
#include "win32api.h"
|
#include "win32api.h"
|
||||||
|
|
||||||
void FDECL(cmov, (int, int));
|
|
||||||
void FDECL(nocmov, (int, int));
|
|
||||||
int FDECL(process_keystroke,
|
|
||||||
(INPUT_RECORD *, boolean *, BOOLEAN_P numberpad, int portdebug));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following WIN32 Console API routines are used in this file.
|
* The following WIN32 Console API routines are used in this file.
|
||||||
*
|
*
|
||||||
@@ -41,6 +36,17 @@ int FDECL(process_keystroke,
|
|||||||
* GetConsoleOutputCP
|
* GetConsoleOutputCP
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static BOOL FDECL(CtrlHandler, (DWORD));
|
||||||
|
static void FDECL(xputc_core, (char));
|
||||||
|
void FDECL(cmov, (int, int));
|
||||||
|
void FDECL(nocmov, (int, int));
|
||||||
|
int FDECL(process_keystroke,
|
||||||
|
(INPUT_RECORD *, boolean *, BOOLEAN_P numberpad, int portdebug));
|
||||||
|
#ifdef TEXTCOLOR
|
||||||
|
static void NDECL(init_ttycolor);
|
||||||
|
#endif
|
||||||
|
static void NDECL(really_move_cursor);
|
||||||
|
|
||||||
/* Win32 Console handles for input and output */
|
/* Win32 Console handles for input and output */
|
||||||
HANDLE hConIn;
|
HANDLE hConIn;
|
||||||
HANDLE hConOut;
|
HANDLE hConOut;
|
||||||
@@ -50,6 +56,9 @@ CONSOLE_SCREEN_BUFFER_INFO csbi, origcsbi;
|
|||||||
COORD ntcoord;
|
COORD ntcoord;
|
||||||
INPUT_RECORD ir;
|
INPUT_RECORD ir;
|
||||||
|
|
||||||
|
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
||||||
|
extern int redirect_stdout;
|
||||||
|
|
||||||
/* Flag for whether NetHack was launched via the GUI, not the command line.
|
/* Flag for whether NetHack was launched via the GUI, not the command line.
|
||||||
* The reason we care at all, is so that we can get
|
* The reason we care at all, is so that we can get
|
||||||
* a final RETURN at the end of the game when launched from the GUI
|
* a final RETURN at the end of the game when launched from the GUI
|
||||||
@@ -58,17 +67,56 @@ INPUT_RECORD ir;
|
|||||||
* from the command line.
|
* from the command line.
|
||||||
*/
|
*/
|
||||||
int GUILaunched;
|
int GUILaunched;
|
||||||
extern int redirect_stdout;
|
|
||||||
static BOOL FDECL(CtrlHandler, (DWORD));
|
|
||||||
|
|
||||||
/* Flag for whether unicode is supported */
|
/* Flag for whether unicode is supported */
|
||||||
static boolean has_unicode;
|
static boolean has_unicode;
|
||||||
|
|
||||||
#ifdef PORT_DEBUG
|
#ifdef PORT_DEBUG
|
||||||
static boolean display_cursor_info = FALSE;
|
static boolean display_cursor_info = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CHANGE_COLOR
|
||||||
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
|
static void NDECL(adjust_palette);
|
||||||
|
static int FDECL(match_color_name, (const char *));
|
||||||
|
typedef HWND(WINAPI *GETCONSOLEWINDOW)();
|
||||||
|
static HWND GetConsoleHandle(void);
|
||||||
|
static HWND GetConsoleHwnd(void);
|
||||||
|
static boolean altered_palette;
|
||||||
|
static COLORREF UserDefinedColors[CLR_MAX];
|
||||||
|
static COLORREF NetHackColors[CLR_MAX] = {
|
||||||
|
0x00000000, 0x00c80000, 0x0000c850, 0x00b4b432, 0x000000d2, 0x00800080,
|
||||||
|
0x000064b4, 0x00c0c0c0, 0x00646464, 0x00f06464, 0x0000ff00, 0x00ffff00,
|
||||||
|
0x000000ff, 0x00ff00ff, 0x0000ffff, 0x00ffffff
|
||||||
|
};
|
||||||
|
static COLORREF DefaultColors[CLR_MAX] = {
|
||||||
|
0x00000000, 0x00800000, 0x00008000, 0x00808000, 0x00000080, 0x00800080,
|
||||||
|
0x00008080, 0x00c0c0c0, 0x00808080, 0x00ff0000, 0x0000ff00, 0x00ffff00,
|
||||||
|
0x000000ff, 0x00ff00ff, 0x0000ffff, 0x00ffffff
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
struct console_t {
|
||||||
|
WORD background;
|
||||||
|
WORD foreground;
|
||||||
|
WORD attr;
|
||||||
|
int current_nhcolor;
|
||||||
|
int current_nhattr[ATR_INVERSE+1];
|
||||||
|
COORD cursor;
|
||||||
|
} console = {
|
||||||
|
0,
|
||||||
|
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED),
|
||||||
|
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED),
|
||||||
|
NO_COLOR,
|
||||||
|
{FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE},
|
||||||
|
{0, 0}
|
||||||
|
};
|
||||||
|
static DWORD ccount, acount;
|
||||||
|
#ifndef CLR_MAX
|
||||||
|
#define CLR_MAX 16
|
||||||
|
#endif
|
||||||
|
int ttycolors[CLR_MAX];
|
||||||
|
int ttycolors_inv[CLR_MAX];
|
||||||
|
#define MAX_OVERRIDES 256
|
||||||
|
unsigned char key_overrides[MAX_OVERRIDES];
|
||||||
|
static char nullstr[] = "";
|
||||||
|
char erase_char, kill_char;
|
||||||
|
#define DEFTEXTCOLOR ttycolors[7]
|
||||||
|
|
||||||
/* dynamic keystroke handling .DLL support */
|
/* dynamic keystroke handling .DLL support */
|
||||||
typedef int(__stdcall *PROCESS_KEYSTROKE)(HANDLE, INPUT_RECORD *, boolean *,
|
typedef int(__stdcall *PROCESS_KEYSTROKE)(HANDLE, INPUT_RECORD *, boolean *,
|
||||||
@@ -93,49 +141,6 @@ SOURCEWHERE pSourceWhere;
|
|||||||
SOURCEAUTHOR pSourceAuthor;
|
SOURCEAUTHOR pSourceAuthor;
|
||||||
KEYHANDLERNAME pKeyHandlerName;
|
KEYHANDLERNAME pKeyHandlerName;
|
||||||
|
|
||||||
#ifdef CHANGE_COLOR
|
|
||||||
static void NDECL(adjust_palette);
|
|
||||||
static int FDECL(match_color_name, (const char *));
|
|
||||||
typedef HWND(WINAPI *GETCONSOLEWINDOW)();
|
|
||||||
static HWND GetConsoleHandle(void);
|
|
||||||
static HWND GetConsoleHwnd(void);
|
|
||||||
static boolean altered_palette;
|
|
||||||
static COLORREF UserDefinedColors[CLR_MAX];
|
|
||||||
static COLORREF NetHackColors[CLR_MAX] = {
|
|
||||||
0x00000000, 0x00c80000, 0x0000c850, 0x00b4b432, 0x000000d2, 0x00800080,
|
|
||||||
0x000064b4, 0x00c0c0c0, 0x00646464, 0x00f06464, 0x0000ff00, 0x00ffff00,
|
|
||||||
0x000000ff, 0x00ff00ff, 0x0000ffff, 0x00ffffff
|
|
||||||
};
|
|
||||||
static COLORREF DefaultColors[CLR_MAX] = {
|
|
||||||
0x00000000, 0x00800000, 0x00008000, 0x00808000, 0x00000080, 0x00800080,
|
|
||||||
0x00008080, 0x00c0c0c0, 0x00808080, 0x00ff0000, 0x0000ff00, 0x00ffff00,
|
|
||||||
0x000000ff, 0x00ff00ff, 0x0000ffff, 0x00ffffff
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CLR_MAX
|
|
||||||
#define CLR_MAX 16
|
|
||||||
#endif
|
|
||||||
int ttycolors[CLR_MAX];
|
|
||||||
#ifdef TEXTCOLOR
|
|
||||||
static void NDECL(init_ttycolor);
|
|
||||||
#endif
|
|
||||||
static void NDECL(really_move_cursor);
|
|
||||||
|
|
||||||
#define MAX_OVERRIDES 256
|
|
||||||
unsigned char key_overrides[MAX_OVERRIDES];
|
|
||||||
|
|
||||||
static char nullstr[] = "";
|
|
||||||
char erase_char, kill_char;
|
|
||||||
|
|
||||||
#define DEFTEXTCOLOR ttycolors[7]
|
|
||||||
static WORD background = 0;
|
|
||||||
static WORD foreground =
|
|
||||||
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
|
||||||
static WORD attr = (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
|
||||||
static DWORD ccount, acount;
|
|
||||||
static COORD cursor = { 0, 0 };
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called after returning from ! or ^Z
|
* Called after returning from ! or ^Z
|
||||||
*/
|
*/
|
||||||
@@ -299,17 +304,6 @@ int mode;
|
|||||||
*/
|
*/
|
||||||
nt_kbhit = nttty_kbhit;
|
nt_kbhit = nttty_kbhit;
|
||||||
|
|
||||||
#if 0
|
|
||||||
hConIn = CreateFile("CONIN$",
|
|
||||||
GENERIC_READ |GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ |FILE_SHARE_WRITE,
|
|
||||||
0, OPEN_EXISTING, 0, 0);
|
|
||||||
hConOut = CreateFile("CONOUT$",
|
|
||||||
GENERIC_READ |GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ |FILE_SHARE_WRITE,
|
|
||||||
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
GetConsoleMode(hConIn, &cmode);
|
GetConsoleMode(hConIn, &cmode);
|
||||||
#ifdef NO_MOUSE_ALLOWED
|
#ifdef NO_MOUSE_ALLOWED
|
||||||
mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_MOUSE_INPUT
|
mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_MOUSE_INPUT
|
||||||
@@ -329,7 +323,7 @@ int mode;
|
|||||||
cmode = 0; /* just to have a statement to break on for debugger */
|
cmode = 0; /* just to have a statement to break on for debugger */
|
||||||
}
|
}
|
||||||
get_scr_size();
|
get_scr_size();
|
||||||
cursor.X = cursor.Y = 0;
|
console.cursor.X = console.cursor.Y = 0;
|
||||||
really_move_cursor();
|
really_move_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,15 +410,15 @@ really_move_cursor()
|
|||||||
oldtitle[39] = '\0';
|
oldtitle[39] = '\0';
|
||||||
}
|
}
|
||||||
Sprintf(newtitle, "%-55s tty=(%02d,%02d) nttty=(%02d,%02d)", oldtitle,
|
Sprintf(newtitle, "%-55s tty=(%02d,%02d) nttty=(%02d,%02d)", oldtitle,
|
||||||
ttyDisplay->curx, ttyDisplay->cury, cursor.X, cursor.Y);
|
ttyDisplay->curx, ttyDisplay->cury, console.cursor.X, console.cursor.Y);
|
||||||
(void) SetConsoleTitle(newtitle);
|
(void) SetConsoleTitle(newtitle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (ttyDisplay) {
|
if (ttyDisplay) {
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
}
|
}
|
||||||
SetConsoleCursorPosition(hConOut, cursor);
|
SetConsoleCursorPosition(hConOut, console.cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -433,55 +427,26 @@ register int x, y;
|
|||||||
{
|
{
|
||||||
ttyDisplay->cury = y;
|
ttyDisplay->cury = y;
|
||||||
ttyDisplay->curx = x;
|
ttyDisplay->curx = x;
|
||||||
cursor.X = x;
|
console.cursor.X = x;
|
||||||
cursor.Y = y;
|
console.cursor.Y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nocmov(x, y)
|
nocmov(x, y)
|
||||||
int x, y;
|
int x, y;
|
||||||
{
|
{
|
||||||
cursor.X = x;
|
console.cursor.X = x;
|
||||||
cursor.Y = y;
|
console.cursor.Y = y;
|
||||||
ttyDisplay->curx = x;
|
ttyDisplay->curx = x;
|
||||||
ttyDisplay->cury = y;
|
ttyDisplay->cury = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
xputc_core(ch)
|
|
||||||
char ch;
|
|
||||||
{
|
|
||||||
switch (ch) {
|
|
||||||
case '\n':
|
|
||||||
cursor.Y++;
|
|
||||||
/* fall through */
|
|
||||||
case '\r':
|
|
||||||
cursor.X = 1;
|
|
||||||
break;
|
|
||||||
case '\b':
|
|
||||||
cursor.X--;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
WriteConsoleOutputAttribute(hConOut, &attr, 1, cursor, &acount);
|
|
||||||
if (has_unicode) {
|
|
||||||
/* Avoid bug in ANSI API on WinNT */
|
|
||||||
WCHAR c2[2];
|
|
||||||
int rc;
|
|
||||||
rc = MultiByteToWideChar(GetConsoleOutputCP(), 0, &ch, 1, c2, 2);
|
|
||||||
WriteConsoleOutputCharacterW(hConOut, c2, rc, cursor, &ccount);
|
|
||||||
} else {
|
|
||||||
WriteConsoleOutputCharacterA(hConOut, &ch, 1, cursor, &ccount);
|
|
||||||
}
|
|
||||||
cursor.X++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xputc(ch)
|
xputc(ch)
|
||||||
char ch;
|
char ch;
|
||||||
{
|
{
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
xputc_core(ch);
|
xputc_core(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,8 +458,8 @@ const char *s;
|
|||||||
int slen = strlen(s);
|
int slen = strlen(s);
|
||||||
|
|
||||||
if (ttyDisplay) {
|
if (ttyDisplay) {
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
@@ -503,6 +468,47 @@ const char *s;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* xputc_core() and g_putch() are the only
|
||||||
|
* two routines that actually place output
|
||||||
|
* on the display.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xputc_core(ch)
|
||||||
|
char ch;
|
||||||
|
{
|
||||||
|
boolean inverse = FALSE;
|
||||||
|
switch (ch) {
|
||||||
|
case '\n':
|
||||||
|
console.cursor.Y++;
|
||||||
|
/* fall through */
|
||||||
|
case '\r':
|
||||||
|
console.cursor.X = 1;
|
||||||
|
break;
|
||||||
|
case '\b':
|
||||||
|
console.cursor.X--;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
|
||||||
|
console.attr = (inverse) ?
|
||||||
|
ttycolors_inv[console.current_nhcolor] :
|
||||||
|
ttycolors[console.current_nhcolor];
|
||||||
|
if (console.current_nhattr[ATR_BOLD])
|
||||||
|
console.attr |= (inverse) ?
|
||||||
|
BACKGROUND_INTENSITY : FOREGROUND_INTENSITY;
|
||||||
|
WriteConsoleOutputAttribute(hConOut, &console.attr, 1, console.cursor, &acount);
|
||||||
|
if (has_unicode) {
|
||||||
|
/* Avoid bug in ANSI API on WinNT */
|
||||||
|
WCHAR c2[2];
|
||||||
|
int rc;
|
||||||
|
rc = MultiByteToWideChar(GetConsoleOutputCP(), 0, &ch, 1, c2, 2);
|
||||||
|
WriteConsoleOutputCharacterW(hConOut, c2, rc, console.cursor, &ccount);
|
||||||
|
} else {
|
||||||
|
WriteConsoleOutputCharacterA(hConOut, &ch, 1, console.cursor, &ccount);
|
||||||
|
}
|
||||||
|
console.cursor.X++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Overrides wintty.c function of the same name
|
* Overrides wintty.c function of the same name
|
||||||
* for win32. It is used for glyphs only, not text.
|
* for win32. It is used for glyphs only, not text.
|
||||||
@@ -546,26 +552,35 @@ int in_ch;
|
|||||||
0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
|
0x2261, 0x00b1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00f7, 0x2248,
|
||||||
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
0x00b0, 0x2219, 0x00b7, 0x221a, 0x207f, 0x00b2, 0x25a0, 0x00a0
|
||||||
};
|
};
|
||||||
|
boolean inverse = FALSE;
|
||||||
unsigned char ch = (unsigned char) in_ch;
|
unsigned char ch = (unsigned char) in_ch;
|
||||||
|
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
WriteConsoleOutputAttribute(hConOut, &attr, 1, cursor, &acount);
|
|
||||||
|
inverse = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse);
|
||||||
|
console.attr = (console.current_nhattr[ATR_INVERSE] && iflags.wc_inverse) ?
|
||||||
|
ttycolors_inv[console.current_nhcolor] :
|
||||||
|
ttycolors[console.current_nhcolor];
|
||||||
|
if (console.current_nhattr[ATR_BOLD])
|
||||||
|
console.attr |= (inverse) ? BACKGROUND_INTENSITY : FOREGROUND_INTENSITY;
|
||||||
|
WriteConsoleOutputAttribute(hConOut, &console.attr, 1, console.cursor, &acount);
|
||||||
|
|
||||||
if (has_unicode)
|
if (has_unicode)
|
||||||
WriteConsoleOutputCharacterW(hConOut, &cp437[ch], 1, cursor, &ccount);
|
WriteConsoleOutputCharacterW(hConOut, &cp437[ch], 1, console.cursor, &ccount);
|
||||||
else
|
else
|
||||||
WriteConsoleOutputCharacterA(hConOut, &ch, 1, cursor, &ccount);
|
WriteConsoleOutputCharacterA(hConOut, &ch, 1, console.cursor, &ccount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cl_end()
|
cl_end()
|
||||||
{
|
{
|
||||||
int cx;
|
int cx;
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
cx = CO - cursor.X;
|
cx = CO - console.cursor.X;
|
||||||
FillConsoleOutputAttribute(hConOut, DEFTEXTCOLOR, cx, cursor, &acount);
|
FillConsoleOutputAttribute(hConOut, DEFTEXTCOLOR, cx, console.cursor, &acount);
|
||||||
FillConsoleOutputCharacter(hConOut, ' ', cx, cursor, &ccount);
|
FillConsoleOutputCharacter(hConOut, ' ', cx, console.cursor, &ccount);
|
||||||
tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1, (int) ttyDisplay->cury);
|
tty_curs(BASE_WINDOW, (int) ttyDisplay->curx + 1, (int) ttyDisplay->cury);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,15 +611,15 @@ clear_screen()
|
|||||||
void
|
void
|
||||||
home()
|
home()
|
||||||
{
|
{
|
||||||
cursor.X = cursor.Y = 0;
|
console.cursor.X = console.cursor.Y = 0;
|
||||||
ttyDisplay->curx = ttyDisplay->cury = 0;
|
ttyDisplay->curx = ttyDisplay->cury = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
backsp()
|
backsp()
|
||||||
{
|
{
|
||||||
cursor.X = ttyDisplay->curx;
|
console.cursor.X = ttyDisplay->curx;
|
||||||
cursor.Y = ttyDisplay->cury;
|
console.cursor.Y = ttyDisplay->cury;
|
||||||
xputc_core('\b');
|
xputc_core('\b');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,27 +691,42 @@ tty_delay_output()
|
|||||||
static void
|
static void
|
||||||
init_ttycolor()
|
init_ttycolor()
|
||||||
{
|
{
|
||||||
ttycolors[CLR_BLACK] = FOREGROUND_INTENSITY; /* fix by Quietust */
|
ttycolors[CLR_BLACK] = FOREGROUND_INTENSITY; /* fix by Quietust */
|
||||||
ttycolors[CLR_RED] = FOREGROUND_RED;
|
ttycolors[CLR_RED] = FOREGROUND_RED;
|
||||||
ttycolors[CLR_GREEN] = FOREGROUND_GREEN;
|
ttycolors[CLR_GREEN] = FOREGROUND_GREEN;
|
||||||
ttycolors[CLR_BROWN] = FOREGROUND_GREEN | FOREGROUND_RED;
|
ttycolors[CLR_BROWN] = FOREGROUND_GREEN | FOREGROUND_RED;
|
||||||
ttycolors[CLR_BLUE] = FOREGROUND_BLUE;
|
ttycolors[CLR_BLUE] = FOREGROUND_BLUE;
|
||||||
ttycolors[CLR_MAGENTA] = FOREGROUND_BLUE | FOREGROUND_RED;
|
ttycolors[CLR_MAGENTA] = FOREGROUND_BLUE | FOREGROUND_RED;
|
||||||
ttycolors[CLR_CYAN] = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
ttycolors[CLR_CYAN] = FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||||
ttycolors[CLR_GRAY] = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE;
|
ttycolors[CLR_GRAY] = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE;
|
||||||
ttycolors[BRIGHT] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED
|
ttycolors[NO_COLOR] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED;
|
||||||
| FOREGROUND_INTENSITY;
|
ttycolors[CLR_ORANGE] = FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
ttycolors[CLR_ORANGE] = FOREGROUND_RED | FOREGROUND_INTENSITY;
|
|
||||||
ttycolors[CLR_BRIGHT_GREEN] = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
ttycolors[CLR_BRIGHT_GREEN] = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||||
ttycolors[CLR_YELLOW] =
|
ttycolors[CLR_YELLOW] = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
ttycolors[CLR_BRIGHT_BLUE] = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
||||||
ttycolors[CLR_BRIGHT_BLUE] = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
ttycolors[CLR_BRIGHT_MAGENTA]=FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
ttycolors[CLR_BRIGHT_MAGENTA] =
|
ttycolors[CLR_BRIGHT_CYAN] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
||||||
FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
ttycolors[CLR_WHITE] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED
|
||||||
ttycolors[CLR_BRIGHT_CYAN] =
|
| FOREGROUND_INTENSITY;
|
||||||
FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY;
|
|
||||||
ttycolors[CLR_WHITE] = FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED
|
ttycolors_inv[CLR_BLACK] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED
|
||||||
| FOREGROUND_INTENSITY;
|
| BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_RED] = BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_GREEN] = BACKGROUND_GREEN;
|
||||||
|
ttycolors_inv[CLR_BROWN] = BACKGROUND_GREEN | BACKGROUND_RED;
|
||||||
|
ttycolors_inv[CLR_BLUE] = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_MAGENTA] = BACKGROUND_BLUE | BACKGROUND_RED;
|
||||||
|
ttycolors_inv[CLR_CYAN] = BACKGROUND_GREEN | BACKGROUND_BLUE;
|
||||||
|
ttycolors_inv[CLR_GRAY] = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE;
|
||||||
|
ttycolors_inv[NO_COLOR] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED;
|
||||||
|
ttycolors_inv[CLR_ORANGE] = BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_BRIGHT_GREEN]= BACKGROUND_GREEN | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_YELLOW] = BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_BRIGHT_BLUE] = BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_BRIGHT_MAGENTA] =BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_BRIGHT_CYAN] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY;
|
||||||
|
ttycolors_inv[CLR_WHITE] = BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED
|
||||||
|
| BACKGROUND_INTENSITY;
|
||||||
}
|
}
|
||||||
#endif /* TEXTCOLOR */
|
#endif /* TEXTCOLOR */
|
||||||
|
|
||||||
@@ -704,64 +734,42 @@ int
|
|||||||
has_color(int color)
|
has_color(int color)
|
||||||
{
|
{
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
return 1;
|
if ((color >= 0) || (color < CLR_MAX))
|
||||||
|
return 1;
|
||||||
#else
|
#else
|
||||||
if (color == CLR_BLACK)
|
if ((color == CLR_BLACK) || (color == CLR_WHITE))
|
||||||
return 1;
|
|
||||||
else if (color == CLR_WHITE)
|
|
||||||
return 1;
|
return 1;
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_start_attr(int attrib)
|
term_start_attr(int attrib)
|
||||||
{
|
{
|
||||||
switch (attrib) {
|
console.current_nhattr[attrib] = TRUE;
|
||||||
case ATR_INVERSE:
|
if (attrib) console.current_nhattr[ATR_NONE] = FALSE;
|
||||||
if (iflags.wc_inverse) {
|
|
||||||
/* Suggestion by Lee Berger */
|
|
||||||
if ((foreground
|
|
||||||
& (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED))
|
|
||||||
== (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED))
|
|
||||||
foreground &=
|
|
||||||
~(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
|
||||||
background =
|
|
||||||
(BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/*FALLTHRU*/
|
|
||||||
case ATR_ULINE:
|
|
||||||
case ATR_BLINK:
|
|
||||||
case ATR_BOLD:
|
|
||||||
foreground |= FOREGROUND_INTENSITY;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
foreground &= ~FOREGROUND_INTENSITY;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
attr = (foreground | background);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_end_attr(int attrib)
|
term_end_attr(int attrib)
|
||||||
{
|
{
|
||||||
|
int k;
|
||||||
|
|
||||||
switch (attrib) {
|
switch (attrib) {
|
||||||
case ATR_INVERSE:
|
case ATR_INVERSE:
|
||||||
if ((foreground
|
|
||||||
& (FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED)) == 0)
|
|
||||||
foreground |=
|
|
||||||
(FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED);
|
|
||||||
background = 0;
|
|
||||||
break;
|
|
||||||
case ATR_ULINE:
|
case ATR_ULINE:
|
||||||
case ATR_BLINK:
|
case ATR_BLINK:
|
||||||
case ATR_BOLD:
|
case ATR_BOLD:
|
||||||
foreground &= ~FOREGROUND_INTENSITY;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
attr = (foreground | background);
|
console.current_nhattr[attrib] = FALSE;
|
||||||
|
console.current_nhattr[ATR_NONE] = TRUE;
|
||||||
|
/* re-evaluate all attr now for performance at output time */
|
||||||
|
for (k=ATR_NONE; k <= ATR_INVERSE; ++k) {
|
||||||
|
if (console.current_nhattr[k])
|
||||||
|
console.current_nhattr[ATR_NONE] = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -781,24 +789,20 @@ term_start_color(int color)
|
|||||||
{
|
{
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
if (color >= 0 && color < CLR_MAX) {
|
if (color >= 0 && color < CLR_MAX) {
|
||||||
foreground =
|
console.current_nhcolor = color;
|
||||||
(background != 0 && (color == CLR_GRAY || color == CLR_WHITE))
|
} else
|
||||||
? ttycolors[0]
|
|
||||||
: ttycolors[color];
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
foreground = DEFTEXTCOLOR;
|
|
||||||
#endif
|
#endif
|
||||||
attr = (foreground | background);
|
console.current_nhcolor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_end_color(void)
|
term_end_color(void)
|
||||||
{
|
{
|
||||||
#ifdef TEXTCOLOR
|
#ifdef TEXTCOLOR
|
||||||
foreground = DEFTEXTCOLOR;
|
console.foreground = DEFTEXTCOLOR;
|
||||||
#endif
|
#endif
|
||||||
attr = (foreground | background);
|
console.attr = (console.foreground | console.background);
|
||||||
|
console.current_nhcolor = NO_COLOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1023,7 +1027,7 @@ VA_DECL(const char *, fmt)
|
|||||||
else {
|
else {
|
||||||
xputs(buf);
|
xputs(buf);
|
||||||
if (ttyDisplay)
|
if (ttyDisplay)
|
||||||
curs(BASE_WINDOW, cursor.X + 1, cursor.Y);
|
curs(BASE_WINDOW, console.cursor.X + 1, console.cursor.Y);
|
||||||
}
|
}
|
||||||
VA_END();
|
VA_END();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user