petattr: Change accepted parameters, add support for tty
This commit is contained in:
@@ -909,7 +909,7 @@ curses_print_glyph(
|
||||
ch = glyphinfo->ttychar;
|
||||
color = glyphinfo->gm.sym.color;
|
||||
if ((special & MG_PET) && iflags.hilite_pet) {
|
||||
attr = iflags.wc2_petattr;
|
||||
attr = curses_convert_attr(iflags.wc2_petattr);
|
||||
}
|
||||
if ((special & MG_DETECT) && iflags.use_inverse) {
|
||||
attr = A_REVERSE;
|
||||
|
||||
@@ -768,92 +768,8 @@ curses_convert_attr(int attr)
|
||||
return curses_attr;
|
||||
}
|
||||
|
||||
|
||||
/* Map letter attributes from a string to bitmask. Return mask on
|
||||
success (might be 0), or -1 if not found. */
|
||||
|
||||
int
|
||||
curses_read_attrs(const char *attrs)
|
||||
{
|
||||
int retattr = 0;
|
||||
|
||||
if (!attrs || !*attrs)
|
||||
return A_NORMAL;
|
||||
|
||||
if (strchr(attrs, 'b') || strchr(attrs, 'B'))
|
||||
retattr |= A_BOLD;
|
||||
if (strchr(attrs, 'i') || strchr(attrs, 'I')) /* inverse */
|
||||
retattr |= A_REVERSE;
|
||||
if (strchr(attrs, 'u') || strchr(attrs, 'U'))
|
||||
retattr |= A_UNDERLINE;
|
||||
if (strchr(attrs, 'k') || strchr(attrs, 'K'))
|
||||
retattr |= A_BLINK;
|
||||
if (strchr(attrs, 'd') || strchr(attrs, 'D'))
|
||||
retattr |= A_DIM;
|
||||
#ifdef A_ITALIC
|
||||
if (strchr(attrs, 't') || strchr(attrs, 'T'))
|
||||
retattr |= A_ITALIC;
|
||||
#endif
|
||||
#ifdef A_LEFTLINE
|
||||
if (strchr(attrs, 'l') || strchr(attrs, 'L'))
|
||||
retattr |= A_LEFTLINE;
|
||||
#endif
|
||||
#ifdef A_RIGHTLINE
|
||||
if (strchr(attrs, 'r') || strchr(attrs, 'R'))
|
||||
retattr |= A_RIGHTLINE;
|
||||
#endif
|
||||
if (retattr == 0) {
|
||||
/* still default; check for none/normal */
|
||||
if (strchr(attrs, 'n') || strchr(attrs, 'N'))
|
||||
retattr = A_NORMAL;
|
||||
else
|
||||
retattr = -1; /* error */
|
||||
}
|
||||
return retattr;
|
||||
}
|
||||
|
||||
/* format iflags.wc2_petattr into "+a+b..." for set bits a, b, ...
|
||||
(used by core's 'O' command; return value points past leading '+') */
|
||||
char *
|
||||
curses_fmt_attrs(char *outbuf)
|
||||
{
|
||||
int attr = iflags.wc2_petattr;
|
||||
|
||||
outbuf[0] = '\0';
|
||||
if (attr == A_NORMAL) {
|
||||
Strcpy(outbuf, "+N(None)");
|
||||
} else {
|
||||
if (attr & A_BOLD)
|
||||
Strcat(outbuf, "+B(Bold)");
|
||||
if (attr & A_REVERSE)
|
||||
Strcat(outbuf, "+I(Inverse)");
|
||||
if (attr & A_UNDERLINE)
|
||||
Strcat(outbuf, "+U(Underline)");
|
||||
if (attr & A_BLINK)
|
||||
Strcat(outbuf, "+K(blinK)");
|
||||
if (attr & A_DIM)
|
||||
Strcat(outbuf, "+D(Dim)");
|
||||
#ifdef A_ITALIC
|
||||
if (attr & A_ITALIC)
|
||||
Strcat(outbuf, "+T(iTalic)");
|
||||
#endif
|
||||
#ifdef A_LEFTLINE
|
||||
if (attr & A_LEFTLINE)
|
||||
Strcat(outbuf, "+L(Left line)");
|
||||
#endif
|
||||
#ifdef A_RIGHTLINE
|
||||
if (attr & A_RIGHTLINE)
|
||||
Strcat(outbuf, "+R(Right line)");
|
||||
#endif
|
||||
}
|
||||
if (!*outbuf)
|
||||
Sprintf(outbuf, "+unknown [%d]", attr);
|
||||
return &outbuf[1];
|
||||
}
|
||||
|
||||
/* Convert special keys into values that NetHack can understand.
|
||||
Currently this is limited to arrow keys, but this may be expanded. */
|
||||
|
||||
int
|
||||
curses_convert_keys(int key)
|
||||
{
|
||||
|
||||
@@ -120,7 +120,7 @@ struct window_procs tty_procs = {
|
||||
| WC2_RESET_STATUS
|
||||
#endif
|
||||
| WC2_DARKGRAY | WC2_SUPPRESS_HIST | WC2_URGENT_MESG | WC2_STATUSLINES
|
||||
| WC2_U_UTF8STR
|
||||
| WC2_U_UTF8STR | WC2_PETATTR
|
||||
#if !defined(NO_TERMS) || defined(WIN32CON)
|
||||
| WC2_U_24BITCOLOR
|
||||
#endif
|
||||
@@ -3786,6 +3786,7 @@ tty_print_glyph(
|
||||
const glyph_info *bkglyphinfo)
|
||||
{
|
||||
boolean inverse_on = FALSE, colordone = FALSE, glyphdone = FALSE;
|
||||
boolean petattr = FALSE;
|
||||
int ch, color;
|
||||
unsigned special;
|
||||
#ifdef ENHANCED_SYMBOLS
|
||||
@@ -3850,8 +3851,10 @@ tty_print_glyph(
|
||||
&& bkglyphinfo && bkglyphinfo->framecolor != NO_COLOR) {
|
||||
ttyDisplay->framecolor = bkglyphinfo->framecolor;
|
||||
term_start_bgcolor(bkglyphinfo->framecolor);
|
||||
} else if ((((special & MG_PET) != 0 && iflags.hilite_pet)
|
||||
|| ((special & MG_OBJPILE) != 0 && iflags.hilite_pile)
|
||||
} else if ((special & MG_PET) != 0 && iflags.hilite_pet) {
|
||||
term_start_attr(iflags.wc2_petattr);
|
||||
petattr = TRUE;
|
||||
} else if ((((special & MG_OBJPILE) != 0 && iflags.hilite_pile)
|
||||
|| ((special & MG_FEMALE) != 0 && wizard && iflags.wizmgender)
|
||||
|| ((special & (MG_DETECT | MG_BW_LAVA | MG_BW_ICE
|
||||
| MG_BW_SINK | MG_BW_ENGR)) != 0))
|
||||
@@ -3880,6 +3883,8 @@ tty_print_glyph(
|
||||
|
||||
if (inverse_on)
|
||||
term_end_attr(ATR_INVERSE);
|
||||
else if (petattr)
|
||||
term_end_attr(iflags.wc2_petattr);
|
||||
if (iflags.use_color) {
|
||||
/* 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
|
||||
|
||||
Reference in New Issue
Block a user