From 3ebf94ca67e5a11b1eeb7d519cba87d37dd0d65b Mon Sep 17 00:00:00 2001 From: William McBrine Date: Thu, 15 Jun 2006 12:33:27 +0000 Subject: [PATCH] Minimal implementation of Unicode support -- compile with -DUNICODE. Only for Win32, for now. Mostly this consists of new ACS_* definitions (which could use refinement). To Do: Other platforms; standard wide-char functions; and update PDC_putc() and PDC_putctty() -- then again, those two aren't really used. Drop them instead? --- curses.h | 182 +++++++++++++++++++++++++++++------------------ win32/pdcdisp.c | 6 +- win32/pdcsetsc.c | 4 +- 3 files changed, 120 insertions(+), 72 deletions(-) diff --git a/curses.h b/curses.h index dcb3284d..7b942be7 100644 --- a/curses.h +++ b/curses.h @@ -15,7 +15,7 @@ * See the file maintain.er for details of the current maintainer. * ************************************************************************/ -/* $Id: curses.h,v 1.171 2006/05/02 17:21:02 wmcbrine Exp $ */ +/* $Id: curses.h,v 1.172 2006/06/15 12:33:26 wmcbrine Exp $ */ /*----------------------------------------------------------------------* * PDCurses * @@ -779,94 +779,138 @@ currently used.) /* VT100-compatible symbols -- box chars */ -#ifdef XCURSES -# define ACS_ULCORNER ((chtype)13 | A_ALTCHARSET) -# define ACS_LLCORNER ((chtype)14 | A_ALTCHARSET) -# define ACS_URCORNER ((chtype)12 | A_ALTCHARSET) -# define ACS_LRCORNER ((chtype)11 | A_ALTCHARSET) -# define ACS_RTEE ((chtype)22 | A_ALTCHARSET) -# define ACS_LTEE ((chtype)21 | A_ALTCHARSET) -# define ACS_BTEE ((chtype)23 | A_ALTCHARSET) -# define ACS_TTEE ((chtype)24 | A_ALTCHARSET) -# define ACS_HLINE ((chtype)18 | A_ALTCHARSET) -# define ACS_VLINE ((chtype)25 | A_ALTCHARSET) -# define ACS_PLUS ((chtype)15 | A_ALTCHARSET) +#ifdef UNICODE +# define ACS_ULCORNER (chtype)0x250c +# define ACS_LLCORNER (chtype)0x2514 +# define ACS_URCORNER (chtype)0x2510 +# define ACS_LRCORNER (chtype)0x2518 +# define ACS_RTEE (chtype)0x2524 +# define ACS_LTEE (chtype)0x251c +# define ACS_BTEE (chtype)0x2534 +# define ACS_TTEE (chtype)0x252c +# define ACS_HLINE (chtype)0x2500 +# define ACS_VLINE (chtype)0x2502 +# define ACS_PLUS (chtype)0x253c #else -# define ACS_ULCORNER (chtype)0xda -# define ACS_LLCORNER (chtype)0xc0 -# define ACS_URCORNER (chtype)0xbf -# define ACS_LRCORNER (chtype)0xd9 -# define ACS_RTEE (chtype)0xb4 -# define ACS_LTEE (chtype)0xc3 -# define ACS_BTEE (chtype)0xc1 -# define ACS_TTEE (chtype)0xc2 -# define ACS_HLINE (chtype)0xc4 -# define ACS_VLINE (chtype)0xb3 -# define ACS_PLUS (chtype)0xc5 +# ifdef XCURSES +# define ACS_ULCORNER ((chtype)13 | A_ALTCHARSET) +# define ACS_LLCORNER ((chtype)14 | A_ALTCHARSET) +# define ACS_URCORNER ((chtype)12 | A_ALTCHARSET) +# define ACS_LRCORNER ((chtype)11 | A_ALTCHARSET) +# define ACS_RTEE ((chtype)22 | A_ALTCHARSET) +# define ACS_LTEE ((chtype)21 | A_ALTCHARSET) +# define ACS_BTEE ((chtype)23 | A_ALTCHARSET) +# define ACS_TTEE ((chtype)24 | A_ALTCHARSET) +# define ACS_HLINE ((chtype)18 | A_ALTCHARSET) +# define ACS_VLINE ((chtype)25 | A_ALTCHARSET) +# define ACS_PLUS ((chtype)15 | A_ALTCHARSET) +# else +# define ACS_ULCORNER (chtype)0xda +# define ACS_LLCORNER (chtype)0xc0 +# define ACS_URCORNER (chtype)0xbf +# define ACS_LRCORNER (chtype)0xd9 +# define ACS_RTEE (chtype)0xb4 +# define ACS_LTEE (chtype)0xc3 +# define ACS_BTEE (chtype)0xc1 +# define ACS_TTEE (chtype)0xc2 +# define ACS_HLINE (chtype)0xc4 +# define ACS_VLINE (chtype)0xb3 +# define ACS_PLUS (chtype)0xc5 +# endif #endif /* VT100-compatible symbols -- other */ -#ifdef XCURSES -# define ACS_S1 ((chtype)16 | A_ALTCHARSET) -# define ACS_S9 ((chtype)20 | A_ALTCHARSET) -# define ACS_DIAMOND ((chtype)1 | A_ALTCHARSET) -# define ACS_CKBOARD ((chtype)2 | A_ALTCHARSET) -# define ACS_DEGREE ((chtype)7 | A_ALTCHARSET) -# define ACS_PLMINUS ((chtype)8 | A_ALTCHARSET) -# define ACS_BULLET (chtype)'*' +#ifdef UNICODE +# define ACS_S1 (chtype)0x2594 +# define ACS_S9 (chtype)0x005f +# define ACS_DIAMOND (chtype)0x2666 +# define ACS_CKBOARD (chtype)0x2592 +# define ACS_DEGREE (chtype)0x00b0 +# define ACS_PLMINUS (chtype)0x00b1 +# define ACS_BULLET (chtype)0x00b7 #else -# define ACS_S1 (chtype)0x2d -# define ACS_S9 (chtype)0x5f -# define ACS_DIAMOND ((chtype)0x04 | A_ALTCHARSET) -# define ACS_CKBOARD (chtype)0xb1 -# define ACS_DEGREE (chtype)0xf8 -# define ACS_PLMINUS (chtype)0xf1 -# define ACS_BULLET (chtype)0xf9 +# ifdef XCURSES +# define ACS_S1 ((chtype)16 | A_ALTCHARSET) +# define ACS_S9 ((chtype)20 | A_ALTCHARSET) +# define ACS_DIAMOND ((chtype)1 | A_ALTCHARSET) +# define ACS_CKBOARD ((chtype)2 | A_ALTCHARSET) +# define ACS_DEGREE ((chtype)7 | A_ALTCHARSET) +# define ACS_PLMINUS ((chtype)8 | A_ALTCHARSET) +# define ACS_BULLET (chtype)'*' +# else +# define ACS_S1 (chtype)0x2d +# define ACS_S9 (chtype)0x5f +# define ACS_DIAMOND ((chtype)0x04 | A_ALTCHARSET) +# define ACS_CKBOARD (chtype)0xb1 +# define ACS_DEGREE (chtype)0xf8 +# define ACS_PLMINUS (chtype)0xf1 +# define ACS_BULLET (chtype)0xf9 +# endif #endif /* Teletype 5410v1 symbols -- these are defined in SysV curses, but are not well-supported by most terminals. Stick to VT100 characters for optimum portability. */ -#ifdef XCURSES -# define ACS_LARROW (chtype)'<' -# define ACS_RARROW (chtype)'>' -# define ACS_DARROW (chtype)'v' -# define ACS_UARROW (chtype)'^' -# define ACS_BOARD (chtype)'#' -# define ACS_LANTERN (chtype)'#' -# define ACS_BLOCK ((chtype)0 | A_ALTCHARSET) +#ifdef UNICODE +# define ACS_LARROW (chtype)0x2190 +# define ACS_RARROW (chtype)0x2192 +# define ACS_DARROW (chtype)0x2193 +# define ACS_UARROW (chtype)0x2191 +# define ACS_BOARD (chtype)0x2591 +# define ACS_LANTERN (chtype)0x00a4 +# define ACS_BLOCK (chtype)0x2588 #else -# define ACS_LARROW ((chtype)0x1b | A_ALTCHARSET) -# define ACS_RARROW ((chtype)0x1a | A_ALTCHARSET) -# define ACS_DARROW ((chtype)0x19 | A_ALTCHARSET) -# define ACS_UARROW ((chtype)0x18 | A_ALTCHARSET) -# define ACS_BOARD (chtype)0xb0 -# define ACS_LANTERN ((chtype)0x0f | A_ALTCHARSET) -# define ACS_BLOCK (chtype)0xdb +# ifdef XCURSES +# define ACS_LARROW (chtype)'<' +# define ACS_RARROW (chtype)'>' +# define ACS_DARROW (chtype)'v' +# define ACS_UARROW (chtype)'^' +# define ACS_BOARD (chtype)'#' +# define ACS_LANTERN (chtype)'#' +# define ACS_BLOCK ((chtype)0 | A_ALTCHARSET) +# else +# define ACS_LARROW ((chtype)0x1b | A_ALTCHARSET) +# define ACS_RARROW ((chtype)0x1a | A_ALTCHARSET) +# define ACS_DARROW ((chtype)0x19 | A_ALTCHARSET) +# define ACS_UARROW ((chtype)0x18 | A_ALTCHARSET) +# define ACS_BOARD (chtype)0xb0 +# define ACS_LANTERN ((chtype)0x0f | A_ALTCHARSET) +# define ACS_BLOCK (chtype)0xdb +# endif #endif /* That goes double for these -- undocumented SysV symbols. Don't use them. Also, the definitions here aren't compatible with as many code pages as those above. */ -#ifdef XCURSES -# define ACS_S3 ((chtype)17 | A_ALTCHARSET) -# define ACS_S7 ((chtype)19 | A_ALTCHARSET) -# define ACS_LEQUAL ((chtype)26 | A_ALTCHARSET) -# define ACS_GEQUAL ((chtype)27 | A_ALTCHARSET) -# define ACS_PI ((chtype)28 | A_ALTCHARSET) -# define ACS_NEQUAL ((chtype)29 | A_ALTCHARSET) -# define ACS_STERLING ((chtype)30 | A_ALTCHARSET) +#ifdef UNICODE +# define ACS_S3 (chtype)0x2500 +# define ACS_S7 (chtype)0x2500 +# define ACS_LEQUAL (chtype)0x2264 +# define ACS_GEQUAL (chtype)0x2265 +# define ACS_PI (chtype)0x03c0 +# define ACS_NEQUAL (chtype)0x2260 +# define ACS_STERLING (chtype)0x00a3 #else -# define ACS_S3 (chtype)0x2d -# define ACS_S7 (chtype)0x2d -# define ACS_LEQUAL (chtype)0xf3 -# define ACS_GEQUAL (chtype)0xf2 -# define ACS_PI (chtype)0xe3 -# define ACS_NEQUAL (chtype)0xd8 -# define ACS_STERLING (chtype)0x9c +# ifdef XCURSES +# define ACS_S3 ((chtype)17 | A_ALTCHARSET) +# define ACS_S7 ((chtype)19 | A_ALTCHARSET) +# define ACS_LEQUAL ((chtype)26 | A_ALTCHARSET) +# define ACS_GEQUAL ((chtype)27 | A_ALTCHARSET) +# define ACS_PI ((chtype)28 | A_ALTCHARSET) +# define ACS_NEQUAL ((chtype)29 | A_ALTCHARSET) +# define ACS_STERLING ((chtype)30 | A_ALTCHARSET) +# else +# define ACS_S3 (chtype)0x2d +# define ACS_S7 (chtype)0x2d +# define ACS_LEQUAL (chtype)0xf3 +# define ACS_GEQUAL (chtype)0xf2 +# define ACS_PI (chtype)0xe3 +# define ACS_NEQUAL (chtype)0xd8 +# define ACS_STERLING (chtype)0x9c +# endif #endif /* Box char aliases */ diff --git a/win32/pdcdisp.c b/win32/pdcdisp.c index be3d069c..d882c562 100644 --- a/win32/pdcdisp.c +++ b/win32/pdcdisp.c @@ -24,7 +24,7 @@ extern HANDLE hConOut; extern unsigned char atrtab[MAX_ATRTAB]; -RCSID("$Id: pdcdisp.c,v 1.21 2006/03/29 20:06:41 wmcbrine Exp $"); +RCSID("$Id: pdcdisp.c,v 1.22 2006/06/15 12:33:27 wmcbrine Exp $"); /*man-start************************************************************** @@ -337,7 +337,11 @@ void PDC_transform_line(int lineno) for (j = 0; j < len; j++) { +#ifdef UNICODE + ci[j].Char.UnicodeChar = srcp[j] & A_CHARTEXT; +#else ci[j].Char.AsciiChar = srcp[j] & A_CHARTEXT; +#endif ci[j].Attributes = (chtype_attr(srcp[j]) & 0xFF00) >> 8; } diff --git a/win32/pdcsetsc.c b/win32/pdcsetsc.c index 232d0292..4b8b0eb0 100644 --- a/win32/pdcsetsc.c +++ b/win32/pdcsetsc.c @@ -19,7 +19,7 @@ #define INCLUDE_WINDOWS_H #include -RCSID("$Id: pdcsetsc.c,v 1.17 2006/03/29 20:06:41 wmcbrine Exp $"); +RCSID("$Id: pdcsetsc.c,v 1.18 2006/06/15 12:33:27 wmcbrine Exp $"); extern HANDLE hConOut; @@ -190,6 +190,6 @@ void PDC_set_title(const char *title) { PDC_LOG(("PDC_set_title() - called:<%s>\n", title)); - SetConsoleTitle(title); + SetConsoleTitleA(title); return; }