Files
nethack/include/wintty.h
nethack.allison 7f0f43e6f9 add some unicode support (trunk only)
This patch attempts to add some levels of unicode support
to NetHack.

The master on/off switch for any Unicode support is
defining UNICODE_SUPPORT in config.h. Currently
there is code support for two subsets of unicode support:

UNICODE_DRAWING

If UNICODE_DRAWING is defined, then the data
structures used to house drawing symbols are expanded
to the size of wchar_t, big enough to hold unicode characters.
A typdef called `nhsym' is involved and if UNICODE_DRAWING
is defined, it is wchar_t, otherwise it is uchar.

UNICODE_WIDEWINPORT

If UNICODE_WIDEWINPORT is defined, then the data
structures inside the window port are expanded to the size of
wchar_t, big enough to hold unicode characters.  Both map
symbols and text within the window port are expanded, in order
for potential support for displaying multinational characters some
day, but this patch only provides viewing of map symbols.
A typdef called `nhwchar' is involved and if UNICODE_WIDEWINPORT
is defined, it is wchar_t, otherwise it is char.

The only window port with code support for UNICODE_WIDEWINPORT
currently is the TTY port.  Don't enable UNICODE_WIDEWINPORT
unless:
- it is a TTY port
- the underlying platform specific routines can
handle the larger data structures.

Don't enable UNICODE_SUPPORT unless:
- your compiler can handle wchar_t.
- your compiler can accept L'a' characters.
- your compiler can accept L"wide" strings.

Note that if your compiler can handle the above, you could
enable the larger data structures (currently if TTY) even if your
platform can't actually display unicode or UTF-8, by messing
with u_putch() in win/tty/wintty.c to only deal regular chars.
That should be the only function that actually pushes wide characters
out to the display.

If you enable UNICODE_SUPPORT, and your platform is capable
you will need to turn on the unicode run-time option to be able to
load unicode character sets from the symbol file, to be able to
push unicode characters to the display. You'll also want to load
a unicode symbol set once the unicode option is toggled on. In
a config file you would do that via these two lines:
OPTIONS=unicode
OPTIONS=symset:Unicode_non_US

The repository was stamped with NETHACK_PRE_UNICODE
prior to applying this patch, and stamped with
NETHACK_POST_UNICODE afterwards. The code differences
between those two tagged versions are this patch.
2006-10-17 23:55:42 +00:00

265 lines
8.2 KiB
C

/* SCCS Id: @(#)wintty.h 3.5 1996/02/18 */
/* Copyright (c) David Cohrs, 1991,1992 */
/* NetHack may be freely redistributed. See license for details. */
#ifndef WINTTY_H
#define WINTTY_H
#define E extern
#ifndef WINDOW_STRUCTS
#define WINDOW_STRUCTS
/* menu structure */
typedef struct tty_mi {
struct tty_mi *next;
anything identifier; /* user identifier */
long count; /* user count */
char *str; /* description string (including accelerator) */
int attr; /* string attribute */
boolean selected; /* TRUE if selected by user */
char selector; /* keyboard accelerator */
char gselector; /* group accelerator */
} tty_menu_item;
/* descriptor for tty-based windows */
struct WinDesc {
int flags; /* window flags */
xchar type; /* type of window */
boolean active; /* true if window is active */
uchar offx, offy; /* offset from topleft of display */
short rows, cols; /* dimensions */
short curx, cury; /* current cursor position */
short maxrow, maxcol; /* the maximum size used -- for MENU wins */
/* maxcol is also used by WIN_MESSAGE for */
/* tracking the ^P command */
short *datlen; /* allocation size for *data */
nhwchar **data; /* window data [row][column] */
nhwchar *morestr; /* string to display instead of default */
tty_menu_item *mlist; /* menu information (MENU) */
tty_menu_item **plist; /* menu page pointers (MENU) */
short plist_size; /* size of allocated plist (MENU) */
short npages; /* number of pages in menu (MENU) */
short nitems; /* total number of items (MENU) */
short how; /* menu mode - pick 1 or N (MENU) */
char menu_ch; /* menu char (MENU) */
};
/* window flags */
#define WIN_CANCELLED 1
#define WIN_STOP 1 /* for NHW_MESSAGE; stops output */
/* descriptor for tty-based displays -- all the per-display data */
struct DisplayDesc {
uchar rows, cols; /* width and height of tty display */
uchar curx, cury; /* current cursor position on the screen */
#ifdef TEXTCOLOR
int color; /* current color */
#endif
int attrs; /* attributes in effect */
int toplin; /* flag for topl stuff */
int rawprint; /* number of raw_printed lines since synch */
int inmore; /* non-zero if more() is active */
int inread; /* non-zero if reading a character */
int intr; /* non-zero if inread was interrupted */
winid lastwin; /* last window used for I/O */
char dismiss_more; /* extra character accepted at --More-- */
};
#endif /* WINDOW_STRUCTS */
#define MAXWIN 20 /* maximum number of windows, cop-out */
/* tty dependent window types */
#ifdef NHW_BASE
#undef NHW_BASE
#endif
#define NHW_BASE 6
extern struct window_procs tty_procs;
/* port specific variable declarations */
extern winid BASE_WINDOW;
extern struct WinDesc *wins[MAXWIN];
extern struct DisplayDesc *ttyDisplay; /* the tty display descriptor */
extern char morc; /* last character typed to xwaitforspace */
extern nhwchar defmorestr[]; /* default --more-- prompt */
/* port specific external function references */
/* ### getline.c ### */
E void FDECL(xwaitforspace, (const char *));
/* ### termcap.c, video.c ### */
E void FDECL(tty_startup,(int*, int*));
#ifndef NO_TERMS
E void NDECL(tty_shutdown);
#endif
#if defined(apollo)
/* Apollos don't widen old-style function definitions properly -- they try to
* be smart and use the prototype, or some such strangeness. So we have to
* define UNWIDENDED_PROTOTYPES (in tradstdc.h), which makes CHAR_P below a
* char. But the tputs termcap call was compiled as if xputc's argument
* actually would be expanded. So here, we have to make an exception. */
E void FDECL(xputc, (int));
#else
# ifndef WIN32CON
E void FDECL(xputc, (CHAR_P));
# endif
#endif
E void FDECL(xputs, (const char *));
#if defined(SCREEN_VGA) || defined(SCREEN_8514)
E void FDECL(xputg, (int, int, unsigned));
#endif
E void NDECL(cl_end);
E void NDECL(clear_screen);
E void NDECL(home);
E void NDECL(standoutbeg);
E void NDECL(standoutend);
# if 0
E void NDECL(revbeg);
E void NDECL(boldbeg);
E void NDECL(blinkbeg);
E void NDECL(dimbeg);
E void NDECL(m_end);
# endif
E void NDECL(backsp);
E void NDECL(graph_on);
E void NDECL(graph_off);
E void NDECL(cl_eos);
/*
* termcap.c (or facsimiles in other ports) is the right place for doing
* strange and arcane things such as outputting escape sequences to select
* a color or whatever. wintty.c should concern itself with WHERE to put
* stuff in a window.
*/
E void FDECL(term_start_attr,(int attr));
E void FDECL(term_end_attr,(int attr));
E void NDECL(term_start_raw_bold);
E void NDECL(term_end_raw_bold);
#ifdef TEXTCOLOR
E void NDECL(term_end_color);
E void FDECL(term_start_color,(int color));
E int FDECL(has_color,(int color));
#endif /* TEXTCOLOR */
/* ### topl.c ### */
E void FDECL(addtopl, (const nhwchar *));
E void NDECL(more);
E void FDECL(update_topl, (const nhwchar *));
E void FDECL(putsyms, (const nhwchar *));
/* ### wintty.c ### */
#ifdef CLIPPING
E void NDECL(setclipped);
#endif
E void FDECL(docorner, (int, int));
E void NDECL(end_glyphout);
E void FDECL(g_putch, (int));
E void NDECL(win_tty_init);
#ifdef UNICODE_WIDEWINPORT
E void FDECL(u_putch, (nhwchar));
#endif
/* external declarations */
E void FDECL(tty_init_nhwindows, (int *, char **));
E void NDECL(tty_player_selection);
E void NDECL(tty_askname);
E void NDECL(tty_get_nh_event) ;
E void FDECL(tty_exit_nhwindows, (const char *));
E void FDECL(tty_suspend_nhwindows, (const char *));
E void NDECL(tty_resume_nhwindows);
E winid FDECL(tty_create_nhwindow, (int));
E void FDECL(tty_clear_nhwindow, (winid));
E void FDECL(tty_display_nhwindow, (winid, BOOLEAN_P));
E void FDECL(tty_dismiss_nhwindow, (winid));
E void FDECL(tty_destroy_nhwindow, (winid));
E void FDECL(tty_curs, (winid,int,int));
E void FDECL(tty_putstr, (winid, int, const char *));
E void FDECL(tty_display_file, (const char *, BOOLEAN_P));
E void FDECL(tty_start_menu, (winid));
E void FDECL(tty_add_menu, (winid,int,const ANY_P *,
CHAR_P,CHAR_P,int,const char *, BOOLEAN_P));
E void FDECL(tty_end_menu, (winid, const char *));
E int FDECL(tty_select_menu, (winid, int, MENU_ITEM_P **));
E char FDECL(tty_message_menu, (CHAR_P,int,const char *));
E void NDECL(tty_update_inventory);
E void NDECL(tty_mark_synch);
E void NDECL(tty_wait_synch);
#ifdef CLIPPING
E void FDECL(tty_cliparound, (int, int));
#endif
#ifdef POSITIONBAR
E void FDECL(tty_update_positionbar, (char *));
#endif
E void FDECL(tty_print_glyph, (winid,XCHAR_P,XCHAR_P,int));
E void FDECL(tty_raw_print, (const char *));
E void FDECL(tty_raw_print_bold, (const char *));
E int NDECL(tty_nhgetch);
E int FDECL(tty_nh_poskey, (int *, int *, int *));
E void NDECL(tty_nhbell);
E int NDECL(tty_doprev_message);
E char FDECL(tty_yn_function, (const char *, const char *, CHAR_P));
E void FDECL(tty_getlin, (const char *,char *));
E int NDECL(tty_get_ext_cmd);
E void FDECL(tty_number_pad, (int));
E void NDECL(tty_delay_output);
#ifdef CHANGE_COLOR
E void FDECL(tty_change_color,(int color,long rgb,int reverse));
#ifdef MAC
E void FDECL(tty_change_background,(int white_or_black));
E short FDECL(set_tty_font_name, (winid, char *));
#endif
E char * NDECL(tty_get_color_string);
#endif
/* other defs that really should go away (they're tty specific) */
E void NDECL(tty_start_screen);
E void NDECL(tty_end_screen);
E void FDECL(genl_outrip, (winid,int));
E char *FDECL(tty_getmsghistory, (BOOLEAN_P));
E void FDECL(tty_putmsghistory, (const char *));
#ifdef NO_TERMS
# ifdef MAC
# ifdef putchar
# undef putchar
# undef putc
# endif
# define putchar term_putc
# define fflush term_flush
# define puts term_puts
E int FDECL(term_putc, (int c));
E int FDECL(term_flush, (void *desc));
E int FDECL(term_puts, (const char *str));
# endif /* MAC */
# if defined(MSDOS) || defined(WIN32CON)
# if defined(SCREEN_BIOS) || defined(SCREEN_DJGPPFAST) || defined(WIN32CON)
# undef putchar
# undef putc
# undef puts
# define putchar(x) xputc(x) /* these are in video.c, nttty.c */
# define putc(x) xputc(x)
# define puts(x) xputs(x)
# endif/*SCREEN_BIOS || SCREEN_DJGPPFAST || WIN32CON */
# ifdef POSITIONBAR
E void FDECL(video_update_positionbar, (char *));
# endif
# endif/*MSDOS*/
#endif/*NO_TERMS*/
#undef E
#endif /* WINTTY_H */