ENHANCED_SYMBOLS
A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h
With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
ucolor RGB color for use with truecolor terminals/platforms.
A ucolor value of zero means "not set." The actual
rgb value of 0 has the 0x1000000 bit set.
u256coloridx 256 color index value for use with 256 color
terminals, the closest color match to ucolor.
utf8str Custom representation via utf-8 string (can be null).
There is a new symset included in the symbols file, called enhanced1.
Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.
The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.
Examples:
OPTIONS=glyph:G_fountain/U+03A8/0-150-255
(Your platform/terminal font needs to be able to include/display the
character, of course.)
The NetHack core code does parsing and storing the customized
entries, and adding them to the glyphmap data structure.
Any window port can utilize the additional information in the glyphinfo
that is passed to them, once code is added to do so.
Also, consolidate some symbol-related code into symbols.c, and remove it from
files.c and options.c
This commit is contained in:
@@ -547,7 +547,7 @@ void NetHackQtMapViewport::PrintGlyph(int x, int y,
|
||||
{
|
||||
Glyph(x, y) = (unsigned short) glyphinfo->glyph;
|
||||
Glyphttychar(x, y) = (unsigned short) glyphinfo->ttychar;
|
||||
Glyphcolor(x, y) = (unsigned short) glyphinfo->gm.color;
|
||||
Glyphcolor(x, y) = (unsigned short) glyphinfo->gm.sym.color;
|
||||
Glyphflags(x, y) = glyphinfo->gm.glyphflags;
|
||||
Glyphtileidx(x, y) = (unsigned short) glyphinfo->gm.tileidx;
|
||||
Changed(x, y);
|
||||
|
||||
@@ -113,7 +113,7 @@ X11_print_glyph(
|
||||
register unsigned char *co_ptr;
|
||||
#endif
|
||||
|
||||
color = glyphinfo->gm.color;
|
||||
color = glyphinfo->gm.sym.color;
|
||||
special = glyphinfo->gm.glyphflags;
|
||||
och = glyphinfo->ttychar;
|
||||
ch = (uchar) och;
|
||||
|
||||
@@ -741,8 +741,8 @@ curses_init_options(void)
|
||||
set_option_mod_status("eight_bit_tty", set_in_config);
|
||||
|
||||
/* If we don't have a symset defined, load the curses symset by default */
|
||||
if (!g.symset[PRIMARY].explicitly)
|
||||
load_symset("curses", PRIMARY);
|
||||
if (!g.symset[PRIMARYSET].explicitly)
|
||||
load_symset("curses", PRIMARYSET);
|
||||
if (!g.symset[ROGUESET].explicitly)
|
||||
load_symset("default", ROGUESET);
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
#include "hack.h"
|
||||
#include "color.h"
|
||||
#include "wincurs.h"
|
||||
#ifdef CURSES_UNICODE
|
||||
#include "locale.h"
|
||||
#endif
|
||||
|
||||
/* define this if not linking with <foo>tty.o|.obj for some reason */
|
||||
#ifdef CURSES_DEFINE_ERASE_CHAR
|
||||
@@ -41,6 +44,9 @@ struct window_procs curses_procs = {
|
||||
#endif
|
||||
| WC_PERM_INVENT | WC_POPUP_DIALOG | WC_SPLASH_SCREEN),
|
||||
(WC2_DARKGRAY | WC2_HITPOINTBAR
|
||||
#ifdef CURSES_UNICODE
|
||||
| WC2_U_UTF8STR
|
||||
#endif
|
||||
#ifdef SELECTSAVED
|
||||
| WC2_SELECTSAVED
|
||||
#endif
|
||||
@@ -150,6 +156,10 @@ curses_init_nhwindows(int *argcp UNUSED,
|
||||
char window_title[BUFSZ];
|
||||
#endif
|
||||
|
||||
#ifdef CURSES_UNICODE
|
||||
setlocale(LC_CTYPE, "");
|
||||
#endif
|
||||
|
||||
#ifdef XCURSES
|
||||
base_term = Xinitscr(*argcp, argv);
|
||||
#else
|
||||
@@ -760,7 +770,7 @@ curses_print_glyph(winid wid, xchar x, xchar y,
|
||||
glyph = glyphinfo->glyph;
|
||||
special = glyphinfo->gm.glyphflags;
|
||||
ch = glyphinfo->ttychar;
|
||||
color = glyphinfo->gm.color;
|
||||
color = glyphinfo->gm.sym.color;
|
||||
if ((special & MG_PET) && iflags.hilite_pet) {
|
||||
attr = iflags.wc2_petattr;
|
||||
}
|
||||
@@ -789,7 +799,17 @@ curses_print_glyph(winid wid, xchar x, xchar y,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
if (SYMHANDLING(H_UTF8)
|
||||
&& glyphinfo->gm.u
|
||||
&& glyphinfo->gm.u->utf8str) {
|
||||
curses_putch(wid, x, y, ch, glyphinfo->gm.u, color, attr);
|
||||
} else {
|
||||
curses_putch(wid, x, y, ch, NULL, color, attr);
|
||||
}
|
||||
#else
|
||||
curses_putch(wid, x, y, ch, color, attr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef struct nhchar {
|
||||
int ch; /* character */
|
||||
int color; /* color info for character */
|
||||
int attr; /* attributes of character */
|
||||
struct unicode_representation *unicode_representation;
|
||||
} nethack_char;
|
||||
|
||||
static boolean map_clipped; /* Map window smaller than 80x21 */
|
||||
@@ -363,7 +364,13 @@ curs_destroy_all_wins(void)
|
||||
/* Print a single character in the given window at the given coordinates */
|
||||
|
||||
void
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
curses_putch(winid wid, int x, int y, int ch,
|
||||
struct unicode_representation *unicode_representation,
|
||||
int color, int attr)
|
||||
#else
|
||||
curses_putch(winid wid, int x, int y, int ch, int color, int attr)
|
||||
#endif
|
||||
{
|
||||
static boolean map_initted = FALSE;
|
||||
int sx, sy, ex, ey;
|
||||
@@ -387,6 +394,9 @@ curses_putch(winid wid, int x, int y, int ch, int color, int attr)
|
||||
map[y][x].ch = ch;
|
||||
map[y][x].color = color;
|
||||
map[y][x].attr = attr;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
map[y][x].unicode_representation = unicode_representation;
|
||||
#endif
|
||||
nch = map[y][x];
|
||||
|
||||
(void) curses_map_borders(&sx, &sy, &ex, &ey, -1, -1);
|
||||
@@ -589,7 +599,10 @@ write_char(WINDOW * win, int x, int y, nethack_char nch)
|
||||
#ifdef PDCURSES
|
||||
mvwaddrawch(win, y, x, nch.ch);
|
||||
#else
|
||||
mvwaddch(win, y, x, nch.ch);
|
||||
if (nch.unicode_representation && nch.unicode_representation->utf8str)
|
||||
mvwprintw(win, y, x, "%s", nch.unicode_representation->utf8str);
|
||||
else
|
||||
mvwaddch(win, y, x, nch.ch);
|
||||
#endif
|
||||
curses_toggle_color_attr(win, nch.color, nch.attr, OFF);
|
||||
}
|
||||
@@ -694,6 +707,7 @@ clear_map(void)
|
||||
map[y][x].ch = ' ';
|
||||
map[y][x].color = NO_COLOR;
|
||||
map[y][x].attr = A_NORMAL;
|
||||
map[y][x].unicode_representation = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,12 @@ void curses_refresh_nhwin(winid wid);
|
||||
void curses_del_nhwin(winid wid);
|
||||
void curses_del_wid(winid wid);
|
||||
void curs_destroy_all_wins(void);
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
void curses_putch(winid wid, int x, int y, int ch,
|
||||
struct unicode_representation *ur, int color, int attrs);
|
||||
#else
|
||||
void curses_putch(winid wid, int x, int y, int ch, int color, int attrs);
|
||||
#endif
|
||||
void curses_get_window_xy(winid wid, int *x, int *y);
|
||||
boolean curses_window_has_border(winid wid);
|
||||
boolean curses_window_exists(winid wid);
|
||||
|
||||
@@ -1341,22 +1341,32 @@ main(int argc UNUSED, char *argv[] UNUSED)
|
||||
Fprintf(ofp, "int maxmontile = %d,\n", lastmontile);
|
||||
Fprintf(ofp, "%smaxobjtile = %d,\n", indent, lastobjtile);
|
||||
Fprintf(ofp, "%smaxothtile = %d;\n\n", indent, lastothtile);
|
||||
Fprintf(ofp,
|
||||
"/* glyph, ttychar, { color, symidx, ovidx, glyphflags, tileidx} */\n");
|
||||
Fprintf(ofp,
|
||||
"/* glyph, ttychar, { glyphflags, {color, symidx}, ovidx, tileidx, 0 } */\n");
|
||||
Fprintf(ofp, "const glyph_info nul_glyphinfo = { \n");
|
||||
Fprintf(ofp, "%sNO_GLYPH, ' ',\n", indent);
|
||||
Fprintf(ofp, "%s%s{ /* glyph_map */\n", indent, indent);
|
||||
Fprintf(ofp, "%s%s%sNO_COLOR, SYM_UNEXPLORED + SYM_OFF_X,\n",
|
||||
Fprintf(ofp, "%s%s%sMG_UNEXPL, { NO_COLOR, SYM_UNEXPLORED + SYM_OFF_X },\n",
|
||||
indent, indent, indent);
|
||||
Fprintf(ofp, "%s%s%sMG_UNEXPL, %d\n", indent, indent, indent,
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
Fprintf(ofp, "%s%s%s%d, 0\n", indent, indent, indent,
|
||||
TILE_unexplored);
|
||||
#else
|
||||
Fprintf(ofp, "%s%s%s%d\n", indent, indent, indent,
|
||||
TILE_unexplored);
|
||||
#endif
|
||||
Fprintf(ofp, "%s%s}\n", indent, indent);
|
||||
Fprintf(ofp, "};\n");
|
||||
Fprintf(ofp, "\nglyph_map glyphmap[MAX_GLYPH] = {\n");
|
||||
|
||||
for (i = 0; i < MAX_GLYPH; i++) {
|
||||
tilenum = tilemap[i].tilenum;
|
||||
Fprintf(ofp, " { 0, 0, 0U, %4d }, /* [%04d] %s=%03d %s */\n",
|
||||
Fprintf(ofp,
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
" { 0U, { 0, 0 }, %4d, 0 }, /* [%04d] %s:%03d %s */\n",
|
||||
#else
|
||||
" { 0U, { 0, 0 }, %4d}, /* [%04d] %s:%03d %s */\n",
|
||||
#endif
|
||||
tilenum, i,
|
||||
tilesrc_texts[tilelist[tilenum]->src],
|
||||
tilelist[tilenum]->file_entry,
|
||||
|
||||
@@ -17,6 +17,9 @@ static char *e_atr2str(int);
|
||||
|
||||
void cmov(int, int);
|
||||
void nocmov(int, int);
|
||||
void term_start_24bitcolor(struct unicode_representation *);
|
||||
void term_end_24bitcolor(void);
|
||||
|
||||
#if defined(TEXTCOLOR) && defined(TERMLIB)
|
||||
#if (!defined(UNIX) || !defined(TERMINFO)) && !defined(TOS)
|
||||
static void analyze_seq(char *, int *, int *);
|
||||
@@ -430,11 +433,12 @@ tty_decgraphics_termcap_fixup(void)
|
||||
#endif /* TERMLIB */
|
||||
|
||||
#if defined(ASCIIGRAPH) && defined(PC9800)
|
||||
extern void (*ibmgraphics_mode_callback)(void); /* defined in drawing.c */
|
||||
extern void (*ibmgraphics_mode_callback)(void); /* defined in symbols.c */
|
||||
#endif
|
||||
extern void (*utf8graphics_mode_callback)(void); /* defined in symbols.c */
|
||||
|
||||
#ifdef PC9800
|
||||
extern void (*ascgraphics_mode_callback)(void); /* defined in drawing.c */
|
||||
extern void (*ascgraphics_mode_callback)(void); /* defined in symbols.c */
|
||||
static void tty_ascgraphics_hilite_fixup(void);
|
||||
|
||||
static void
|
||||
@@ -478,6 +482,10 @@ tty_start_screen(void)
|
||||
/* set up callback in case option is not set yet but toggled later */
|
||||
decgraphics_mode_callback = tty_decgraphics_termcap_fixup;
|
||||
#endif
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
utf8graphics_mode_callback = tty_utf8graphics_fixup;
|
||||
#endif
|
||||
|
||||
if (g.Cmd.num_pad)
|
||||
tty_number_pad(1); /* make keypad send digits */
|
||||
}
|
||||
@@ -870,14 +878,21 @@ const struct {
|
||||
{ COLOR_MAGENTA, CLR_MAGENTA, CLR_BRIGHT_MAGENTA },
|
||||
{ COLOR_CYAN, CLR_CYAN, CLR_BRIGHT_CYAN } };
|
||||
|
||||
typedef struct {
|
||||
unsigned char r, g, b;
|
||||
} RGB;
|
||||
|
||||
static char nilstring[] = "";
|
||||
|
||||
static void
|
||||
init_hilite(void)
|
||||
{
|
||||
int c, colors;
|
||||
char *setf, *scratch;
|
||||
int c, md_len = 0;
|
||||
int colors = tgetnum("Co");
|
||||
|
||||
colors = tgetnum("Co");
|
||||
iflags.colorcount = colors;
|
||||
int md_len = 0;
|
||||
|
||||
if (colors < 8 || (MD == NULL) || (strlen(MD) == 0)
|
||||
|| ((setf = tgetstr("AF", (char **) 0)) == (char *) 0
|
||||
@@ -1410,9 +1425,66 @@ term_start_color(int color)
|
||||
if (color < CLR_MAX && hilites[color] && *hilites[color])
|
||||
xputs(hilites[color]);
|
||||
}
|
||||
|
||||
#endif /* TEXTCOLOR */
|
||||
|
||||
#endif /* TTY_GRAPHICS && !NO_TERMS */
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
|
||||
#ifndef SEP2
|
||||
#define tcfmtstr "\033[38;2;%ld;%ld;%ldm"
|
||||
#ifdef UNIX
|
||||
#define tcfmtstr24bit "\033[38;2;%u;%u;%um"
|
||||
#define tcfmtstr256 "\033[38;5;%dm"
|
||||
#else
|
||||
#define tcfmtstr "\033[38:2:%ld:%ld:%ldm"
|
||||
#define tcfmtstr24bit "\033[38;2;%lu;%lu;%lum"
|
||||
#define tcfmtstr256 "\033[38:5:%ldm"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static void emit24bit(long mcolor);
|
||||
static void emit256(int u256coloridx);
|
||||
|
||||
static void emit24bit(long mcolor)
|
||||
{
|
||||
static char tcolorbuf[QBUFSZ];
|
||||
|
||||
Snprintf(tcolorbuf, sizeof tcolorbuf, tcfmtstr,
|
||||
((mcolor >> 16) & 0xFF), /* red */
|
||||
((mcolor >> 8) & 0xFF), /* green */
|
||||
((mcolor >> 0) & 0xFF)); /* blue */
|
||||
xputs(tcolorbuf);
|
||||
}
|
||||
|
||||
static void emit256(int u256coloridx)
|
||||
{
|
||||
static char tcolorbuf[QBUFSZ];
|
||||
|
||||
Snprintf(tcolorbuf, sizeof tcolorbuf, tcfmtstr256,
|
||||
u256coloridx);
|
||||
xputs(tcolorbuf);
|
||||
}
|
||||
|
||||
void
|
||||
term_start_24bitcolor(struct unicode_representation *urep)
|
||||
{
|
||||
if (urep && SYMHANDLING(H_UTF8)) {
|
||||
/* color 0 has bit 0x1000000 set */
|
||||
long mcolor = (urep->ucolor & 0xFFFFFF);
|
||||
if (iflags.colorcount == 256)
|
||||
emit256(urep->u256coloridx);
|
||||
else
|
||||
emit24bit(mcolor);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
term_end_24bitcolor(void)
|
||||
{
|
||||
if (SYMHANDLING(H_UTF8)) {
|
||||
xputs("\033[0m");
|
||||
}
|
||||
}
|
||||
#endif /* ENHANCED_SYMBOLS */
|
||||
#endif /* TTY_GRAPHICS && !NO_TERMS */
|
||||
|
||||
/*termcap.c*/
|
||||
|
||||
@@ -124,13 +124,15 @@ redotoplin(const char *str)
|
||||
int otoplin = ttyDisplay->toplin;
|
||||
|
||||
home();
|
||||
if (*str & 0x80) {
|
||||
/* kludge for the / command, the only time we ever want a */
|
||||
/* graphics character on the top line */
|
||||
g_putch((int) *str++);
|
||||
ttyDisplay->curx++;
|
||||
if (!ttyDisplay->topl_utf8) {
|
||||
if (*str & 0x80) {
|
||||
/* kludge for the / command, the only time we ever want a */
|
||||
/* graphics character on the top line */
|
||||
g_putch((int) *str++);
|
||||
ttyDisplay->curx++;
|
||||
}
|
||||
end_glyphout(); /* in case message printed during graphics output */
|
||||
}
|
||||
end_glyphout(); /* in case message printed during graphics output */
|
||||
putsyms(str);
|
||||
cl_end();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE;
|
||||
|
||||
142
win/tty/wintty.c
142
win/tty/wintty.c
@@ -97,7 +97,7 @@ struct window_procs tty_procs = {
|
||||
#ifdef MSDOS
|
||||
| WC_TILED_MAP | WC_ASCII_MAP
|
||||
#endif
|
||||
#if defined(WIN32CON)
|
||||
#if defined(WIN32)
|
||||
| WC_MOUSE_SUPPORT
|
||||
#endif
|
||||
| WC_COLOR | WC_HILITE_PET | WC_INVERSE | WC_EIGHT_BIT_IN),
|
||||
@@ -109,7 +109,12 @@ struct window_procs tty_procs = {
|
||||
| WC2_HILITE_STATUS | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
|
||||
| WC2_RESET_STATUS
|
||||
#endif
|
||||
| WC2_DARKGRAY | WC2_SUPPRESS_HIST | WC2_URGENT_MESG | WC2_STATUSLINES),
|
||||
| WC2_DARKGRAY | WC2_SUPPRESS_HIST | WC2_URGENT_MESG | WC2_STATUSLINES)
|
||||
| WC2_U_UTF8STR
|
||||
#if !defined(NO_TERMS) || defined(WIN32)
|
||||
| WC2_U_24BITCOLOR
|
||||
#endif
|
||||
,
|
||||
#ifdef TEXTCOLOR
|
||||
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, /* color availability */
|
||||
#else
|
||||
@@ -118,7 +123,8 @@ struct window_procs tty_procs = {
|
||||
tty_init_nhwindows, tty_player_selection, tty_askname, tty_get_nh_event,
|
||||
tty_exit_nhwindows, tty_suspend_nhwindows, tty_resume_nhwindows,
|
||||
tty_create_nhwindow, tty_clear_nhwindow, tty_display_nhwindow,
|
||||
tty_destroy_nhwindow, tty_curs, tty_putstr, genl_putmixed,
|
||||
tty_destroy_nhwindow, tty_curs, tty_putstr,
|
||||
tty_putmixed,
|
||||
tty_display_file, tty_start_menu, tty_add_menu, tty_end_menu,
|
||||
tty_select_menu, tty_message_menu, tty_update_inventory, tty_mark_synch,
|
||||
tty_wait_synch,
|
||||
@@ -159,6 +165,7 @@ struct DisplayDesc *ttyDisplay; /* the tty display descriptor */
|
||||
|
||||
extern void cmov(int, int); /* from termcap.c */
|
||||
extern void nocmov(int, int); /* from termcap.c */
|
||||
|
||||
#if defined(UNIX) || defined(VMS)
|
||||
static char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */
|
||||
#endif
|
||||
@@ -231,6 +238,9 @@ static void shrink_dlvl(int);
|
||||
static void status_sanity_check(void);
|
||||
#endif /* NH_DEVEL_STATUS */
|
||||
#endif
|
||||
#if !defined(NO_TERMS) && !defined(WIN32)
|
||||
void g_pututf8(uint8 *utf8str);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A string containing all the default commands -- to add to a list
|
||||
@@ -442,6 +452,7 @@ tty_init_nhwindows(int *argcp UNUSED, char **argv UNUSED)
|
||||
/* set up tty descriptor */
|
||||
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->topl_utf8 = 0; /* putmixed may set this */
|
||||
ttyDisplay->rows = hgt;
|
||||
ttyDisplay->cols = wid;
|
||||
ttyDisplay->curx = ttyDisplay->cury = 0;
|
||||
@@ -2344,9 +2355,14 @@ process_text_window(winid window, struct WinDesc *cw)
|
||||
) {
|
||||
/* message recall for msg_window:full/combination/reverse
|
||||
might have output from '/' in it (see redotoplin()) */
|
||||
if (linestart && (*cp & 0x80) != 0) {
|
||||
g_putch(*cp);
|
||||
end_glyphout();
|
||||
if (linestart) {
|
||||
if (SYMHANDLING(H_UTF8)) {
|
||||
/* FIXME: what is actually in that line? is it the \GNNNNNNNN or UTF-8? */
|
||||
g_putch(*cp);
|
||||
} else if ((*cp & 0x80) != 0) {
|
||||
g_putch(*cp);
|
||||
end_glyphout();
|
||||
}
|
||||
linestart = FALSE;
|
||||
} else {
|
||||
(void) putchar(*cp);
|
||||
@@ -3367,8 +3383,11 @@ g_putch(int in_ch)
|
||||
register char ch = (char) in_ch;
|
||||
|
||||
HUPSKIP();
|
||||
|
||||
#if defined(ASCIIGRAPH) && !defined(NO_TERMS)
|
||||
if (SYMHANDLING(H_IBM)
|
||||
if (SYMHANDLING(H_UTF8)) {
|
||||
(void) putchar(ch);
|
||||
} else if (SYMHANDLING(H_IBM)
|
||||
/* for DECgraphics, lower-case letters with high bit set mean
|
||||
switch character set and render with high bit clear;
|
||||
user might want 8-bits for other characters */
|
||||
@@ -3397,6 +3416,17 @@ g_putch(int in_ch)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
g_pututf8(uint8 *utf8str)
|
||||
{
|
||||
HUPSKIP();
|
||||
while (*utf8str) {
|
||||
(void) putchar(*utf8str);
|
||||
utf8str++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* !WIN32 */
|
||||
|
||||
#ifdef CLIPPING
|
||||
@@ -3458,6 +3488,11 @@ tty_print_glyph(winid window, xchar x, xchar y,
|
||||
boolean inverse_on = FALSE;
|
||||
int ch, color;
|
||||
unsigned special;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
#if !defined(NO_TERMS) || defined(WIN32)
|
||||
boolean color24bit_on = FALSE;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
HUPSKIP();
|
||||
#ifdef CLIPPING
|
||||
@@ -3468,7 +3503,7 @@ tty_print_glyph(winid window, xchar x, xchar y,
|
||||
#endif
|
||||
/* get glyph ttychar, color, and special flags */
|
||||
ch = glyphinfo->ttychar;
|
||||
color = glyphinfo->gm.color;
|
||||
color = glyphinfo->gm.sym.color;
|
||||
special = glyphinfo->gm.glyphflags;
|
||||
|
||||
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||
@@ -3484,24 +3519,33 @@ tty_print_glyph(winid window, xchar x, xchar y,
|
||||
backsp();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (iflags.use_color) {
|
||||
#ifdef TEXTCOLOR
|
||||
if (iflags.wizmgender && (special & MG_FEMALE) && iflags.use_inverse) {
|
||||
if (ttyDisplay->color != NO_COLOR)
|
||||
term_end_color();
|
||||
term_start_attr(ATR_INVERSE);
|
||||
inverse_on = TRUE;
|
||||
ttyDisplay->color = CLR_RED;
|
||||
term_start_color(ttyDisplay->color);
|
||||
} else if (color != ttyDisplay->color) {
|
||||
if (ttyDisplay->color != NO_COLOR)
|
||||
term_end_color();
|
||||
ttyDisplay->color = color;
|
||||
if (color != NO_COLOR)
|
||||
term_start_color(color);
|
||||
}
|
||||
if (color != ttyDisplay->color) {
|
||||
if (ttyDisplay->color != NO_COLOR)
|
||||
term_end_color();
|
||||
}
|
||||
#endif
|
||||
#if !defined(NO_TERMS) || defined(WIN32)
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
/* we don't link with termcap.o if NO_TERMS is defined */
|
||||
if ((tty_procs.wincap2 & WC2_U_24BITCOLOR) && SYMHANDLING(H_UTF8)
|
||||
&& glyphinfo->gm.u && glyphinfo->gm.u->ucolor) {
|
||||
term_start_24bitcolor(glyphinfo->gm.u);
|
||||
color24bit_on = TRUE;
|
||||
} else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
#ifdef TEXTCOLOR
|
||||
ttyDisplay->color = color;
|
||||
if (color != NO_COLOR)
|
||||
term_start_color(color);
|
||||
#endif /* TEXTCOLOR */
|
||||
|
||||
#if !defined(NO_TERMS) || defined(WIN32)
|
||||
}
|
||||
#endif
|
||||
} /* iflags.use_color aka iflags.wc_color */
|
||||
/* must be after color check; term_end_color may turn off inverse too;
|
||||
BW_LAVA and BW_ICE won't ever be set when color is on;
|
||||
(tried bold for ice but it didn't look very good; inverse is easier
|
||||
@@ -3519,21 +3563,34 @@ tty_print_glyph(winid window, xchar x, xchar y,
|
||||
xputg(glyphinfo);
|
||||
else
|
||||
#endif
|
||||
g_putch(ch); /* print the character */
|
||||
|
||||
if (inverse_on) {
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
if ((tty_procs.wincap2 & WC2_U_UTF8STR) && SYMHANDLING(H_UTF8)
|
||||
&& glyphinfo->gm.u && glyphinfo->gm.u->utf8str) {
|
||||
/* we have a sequence to do */
|
||||
g_pututf8(glyphinfo->gm.u->utf8str);
|
||||
} else
|
||||
#endif
|
||||
g_putch(ch); /* print the character */
|
||||
|
||||
if (inverse_on)
|
||||
term_end_attr(ATR_INVERSE);
|
||||
if (iflags.use_color) {
|
||||
#ifdef TEXTCOLOR
|
||||
/* turn off color as well, turning off ATR_INVERSE may have done
|
||||
this already and if so, we won't know the current state unless
|
||||
we do it explicitly */
|
||||
this already and if so, we won't know the current state unless
|
||||
we do it explicitly */
|
||||
if (ttyDisplay->color != NO_COLOR) {
|
||||
term_end_color();
|
||||
ttyDisplay->color = NO_COLOR;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
#if !defined(NO_TERMS) || defined(WIN32)
|
||||
if (color24bit_on)
|
||||
term_end_24bitcolor();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
print_vt_code1(AVTC_GLYPH_END);
|
||||
|
||||
wins[window]->curx++; /* one character over */
|
||||
@@ -3688,6 +3745,31 @@ tty_update_positionbar(char *posbar)
|
||||
}
|
||||
#endif /* POSITIONBAR */
|
||||
|
||||
void
|
||||
tty_putmixed(winid window, int attr, const char *str)
|
||||
{
|
||||
struct WinDesc *cw;
|
||||
char buf[BUFSZ];
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
int utf8flag = 0;
|
||||
#endif
|
||||
|
||||
if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0) {
|
||||
tty_raw_print(str);
|
||||
return;
|
||||
}
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
if ((windowprocs.wincap2 & WC2_U_UTF8STR) && SYMHANDLING(H_UTF8)) {
|
||||
mixed_to_utf8(buf, sizeof buf, str, &utf8flag);
|
||||
if (cw->type == NHW_MESSAGE)
|
||||
ttyDisplay->topl_utf8 = utf8flag;
|
||||
} else
|
||||
#endif
|
||||
decode_mixed(buf, str);
|
||||
/* now send it to the normal tty_putstr */
|
||||
tty_putstr(window, attr, buf);
|
||||
ttyDisplay->topl_utf8 = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* +------------------+
|
||||
|
||||
@@ -930,7 +930,7 @@ paintGlyph(PNHMapWindow data, int i, int j, RECT * rect)
|
||||
OldFg = SetTextColor(hDC, nhcolor_to_RGB(color));
|
||||
#else
|
||||
ch = (char) data->map[i][j].ttychar;
|
||||
color = (int) data->map[i][j].gm.color;
|
||||
color = (int) data->map[i][j].gm.sym.color;
|
||||
if (((data->map[i][j].gm.glyphflags & MG_PET) && iflags.hilite_pet)
|
||||
|| ((data->map[i][j].gm.glyphflags & (MG_DETECT | MG_BW_LAVA))
|
||||
&& iflags.use_inverse)) {
|
||||
@@ -1000,7 +1000,7 @@ static void setGlyph(PNHMapWindow data, int i, int j,
|
||||
if ((data->map[i][j].glyph != fg->glyph)
|
||||
|| (data->bkmap[i][j].glyph != bg->glyph)
|
||||
|| data->map[i][j].ttychar != fg->ttychar
|
||||
|| data->map[i][j].gm.color != fg->gm.color
|
||||
|| data->map[i][j].gm.sym.color != fg->gm.sym.color
|
||||
|| data->map[i][j].gm.glyphflags != fg->gm.glyphflags
|
||||
|| data->map[i][j].gm.tileidx != fg->gm.tileidx) {
|
||||
data->map[i][j] = *fg;
|
||||
|
||||
Reference in New Issue
Block a user