window port change - putmixed() (trunk only)

Add putmixed() to the window port. It allows map symbols to
be included in the string by encoding them in a unique fashion.
This was done because Unicode symbols, for instance, could be
longer than the size of a char.

The encoding of the map symbols in this patch is done by
prefixing a glyph value with \GXXXX, where XXXX is a
random value for the current game. The reason for the random
prefix is to minimize the possibility that a player can trigger
the escape sequence processing within text under their control
(dog names, etc.) the way they could if the sequence was fixed
in the source code. The random prefix remains the same throughout
the lifetime of a game because message window strings are
saved in the save file.

(There was actually a bug present because of the embedded
character even before the recent symbol changes, because if
someone was using a  different set of characters between games,
the saved messages would reflect the original characters, rather
than the current. That bug was introduced with the ability to
save messages to the savefile.)

A window port does not have to supply an XXX_putmixed() routine,
it can use genl_putmixed() which uses the old behavior of
embedding the sequence as a character within the string
and calling putstr(). genl_putmixed() takes care of the decoding
of the escape sequence.

This also #ifdef's out code in pager.c for converting a glyph
to a character, and uses mapglyph() to do that instead. Does
anyone see a problem with doing that through mapglyph instead
of repeating similar code within pager.c?
This commit is contained in:
nethack.allison
2006-10-17 23:06:31 +00:00
parent 6873e64cf5
commit 8fc01eb6b1
16 changed files with 164 additions and 19 deletions

View File

@@ -123,6 +123,39 @@ putstr(window, attr, str)
are done consecutively the user will see the first and
then the second. In the tty port, pline() achieves this
by calling more() or displaying both on the same line.
putmixed(window, attr, str)
-- Print str on the window with the given attribute. In
addition to printable ASCII characters (040-0126),
sequences of encoded glyph values are supported.
The glyph encoding sequence is \GXXXXNNNN, where:
XXXX is a hexadecimal value. The value must match
the randomly generated value for the current
game in progress in order to be decoded.
The value for the game in progress is stored in
context.rndencode. This field minimizes
unintentional decoding of player-supplied strings
such as pet names, etc.
NNNN is a hexadecimal value representing the glyph.
If a window port does not yet support special handling of
the glyph value, it can use genl_putmixed (mapglyph.c)
which converts the encoded glyph into a character symbol.
Multiple putmixed()s are output on separate lines. Attributes
can be one of
ATR_NONE (or 0)
ATR_ULINE
ATR_BOLD
ATR_BLINK
ATR_INVERSE
If a window-port does not support all of these, it may map
unsupported attributes to a supported one (e.g. map them
all to ATR_INVERSE). putmixed() may compress spaces out of
str, break str, or truncate str, if necessary for the
display. Where putmixed() breaks a line, it has to clear
to end-of-line.
-- putstr should be implemented such that if two putmixed()s
are done consecutively the user will see the first and
then the second.
get_nh_event() -- Does window event processing (e.g. exposure events).
A noop for the tty and X window-ports.
int nhgetch() -- Returns a single character input from the user.