pull in the recent unconditionals merge from master
This commit is contained in:
347
win/tty/wintty.c
347
win/tty/wintty.c
@@ -1,4 +1,5 @@
|
||||
/* NetHack 3.5 wintty.c $Date$ $Revision$ */
|
||||
/* NetHack 3.5 wintty.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.5 wintty.c $Date: 2012/01/22 06:27:09 $ $Revision: 1.66 $ */
|
||||
/* Copyright (c) David Cohrs, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -42,11 +43,6 @@ extern char mapped_menu_cmds[]; /* from options.c */
|
||||
/* this is only needed until tty_status_* routines are written */
|
||||
extern NEARDATA winid WIN_STATUS;
|
||||
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
void FDECL(tty_putmixed,(winid,int,const char *));
|
||||
void FDECL(tty_putstr_core,(winid,int,const nhwchar *));
|
||||
#endif
|
||||
|
||||
/* Interface definition, for windows.c */
|
||||
struct window_procs tty_procs = {
|
||||
"tty",
|
||||
@@ -74,11 +70,7 @@ struct window_procs tty_procs = {
|
||||
tty_destroy_nhwindow,
|
||||
tty_curs,
|
||||
tty_putstr,
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
tty_putmixed,
|
||||
#else
|
||||
genl_putmixed,
|
||||
#endif
|
||||
tty_display_file,
|
||||
tty_start_menu,
|
||||
tty_add_menu,
|
||||
@@ -150,12 +142,7 @@ static char obuf[BUFSIZ]; /* BUFSIZ is defined in stdio.h */
|
||||
#endif
|
||||
|
||||
static char winpanicstr[] = "Bad window id %d";
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
nhwchar defmorestr[] = L"--More--";
|
||||
#else
|
||||
nhwchar defmorestr[] = "--More--";
|
||||
#endif
|
||||
nhwchar emptysym[1] = {0};
|
||||
char defmorestr[] = "--More--";
|
||||
|
||||
#ifdef CLIPPING
|
||||
# if defined(USE_TILES) && defined(MSDOS)
|
||||
@@ -195,11 +182,8 @@ STATIC_DCL void FDECL(process_menu_window, (winid,struct WinDesc *));
|
||||
STATIC_DCL void FDECL(process_text_window, (winid,struct WinDesc *));
|
||||
STATIC_DCL tty_menu_item *FDECL(reverse, (tty_menu_item *));
|
||||
STATIC_DCL const char * FDECL(compress_str, (const char *));
|
||||
STATIC_DCL void FDECL(tty_putsym, (winid, int, int, NHWCHAR_P));
|
||||
STATIC_DCL void FDECL(tty_putsym, (winid, int, int, CHAR_P));
|
||||
STATIC_DCL char *FDECL(copy_of, (const char *));
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
STATIC_DCL nhwchar *FDECL(nhwchar_copy_of, (const nhwchar *));
|
||||
#endif
|
||||
STATIC_DCL void FDECL(bail, (const char *)); /* __attribute__((noreturn)) */
|
||||
|
||||
/*
|
||||
@@ -294,11 +278,7 @@ if(wc_tracelogf)
|
||||
for(i=WIN_INVEN; i < MAXWIN; i++)
|
||||
if(wins[i] && wins[i]->active) {
|
||||
/* cop-out */
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
addtopl(L"Press Return to continue: ");
|
||||
#else
|
||||
addtopl("Press Return to continue: ");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
(void) fflush(stdout);
|
||||
@@ -1119,24 +1099,24 @@ tty_create_nhwindow(type)
|
||||
|
||||
if(newwin->maxrow) {
|
||||
newwin->data =
|
||||
(nhwchar **) alloc(sizeof(nhwchar *) * (unsigned)newwin->maxrow);
|
||||
(char **) alloc(sizeof(char *) * (unsigned)newwin->maxrow);
|
||||
newwin->datlen =
|
||||
(short *) alloc(sizeof(short) * (unsigned)newwin->maxrow);
|
||||
if(newwin->maxcol) {
|
||||
for (i = 0; i < newwin->maxrow; i++) {
|
||||
newwin->data[i] = (nhwchar *) alloc(sizeof(nhwchar) * (unsigned)newwin->maxcol);
|
||||
newwin->data[i] = (char *) alloc((unsigned)newwin->maxcol);
|
||||
newwin->datlen[i] = newwin->maxcol;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < newwin->maxrow; i++) {
|
||||
newwin->data[i] = (nhwchar *) 0;
|
||||
newwin->data[i] = (char *) 0;
|
||||
newwin->datlen[i] = 0;
|
||||
}
|
||||
}
|
||||
if(newwin->type == NHW_MESSAGE)
|
||||
newwin->maxrow = 0;
|
||||
} else {
|
||||
newwin->data = (nhwchar **)0;
|
||||
newwin->data = (char **)0;
|
||||
newwin->datlen = (short *)0;
|
||||
}
|
||||
|
||||
@@ -1174,12 +1154,12 @@ free_window_info(cw, free_data)
|
||||
for(i=0; i<cw->maxrow; i++)
|
||||
if(cw->data[i]) {
|
||||
free((genericptr_t)cw->data[i]);
|
||||
cw->data[i] = (nhwchar *)0;
|
||||
cw->data[i] = (char *)0;
|
||||
if (cw->datlen) cw->datlen[i] = 0;
|
||||
}
|
||||
if (free_data) {
|
||||
free((genericptr_t)cw->data);
|
||||
cw->data = (nhwchar **)0;
|
||||
cw->data = (char **)0;
|
||||
if (cw->datlen) free((genericptr_t)cw->datlen);
|
||||
cw->datlen = (short *)0;
|
||||
cw->rows = 0;
|
||||
@@ -1253,25 +1233,15 @@ dmore(cw, s)
|
||||
register struct WinDesc *cw;
|
||||
const char *s; /* valid responses */
|
||||
{
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
char buf[BUFSZ];
|
||||
#endif
|
||||
const nhwchar *prompt = cw->morestr ? cw->morestr : defmorestr;
|
||||
|
||||
const char *prompt = cw->morestr ? cw->morestr : defmorestr;
|
||||
int offset = (cw->type == NHW_TEXT) ? 1 : 2;
|
||||
|
||||
tty_curs(BASE_WINDOW,
|
||||
(int)ttyDisplay->curx + offset, (int)ttyDisplay->cury);
|
||||
if(flags.standout)
|
||||
standoutbeg();
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
strnhwcpy(buf, prompt);
|
||||
xputs(buf);
|
||||
ttyDisplay->curx += strlen(buf);
|
||||
#else
|
||||
xputs(prompt);
|
||||
ttyDisplay->curx += strlen(prompt);
|
||||
#endif
|
||||
if(flags.standout)
|
||||
standoutend();
|
||||
|
||||
@@ -1386,13 +1356,13 @@ struct WinDesc *cw;
|
||||
long count;
|
||||
int n, curr_page, page_lines;
|
||||
boolean finished, counting, reset_count;
|
||||
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ];
|
||||
nhwchar *msave, *morestr;
|
||||
char *cp, *rp, resp[QBUFSZ], gacc[QBUFSZ],
|
||||
*msave, *morestr;
|
||||
|
||||
curr_page = page_lines = 0;
|
||||
page_start = page_end = 0;
|
||||
msave = cw->morestr; /* save the morestr */
|
||||
cw->morestr = morestr = (nhwchar*) alloc(sizeof(nhwchar) * (unsigned) QBUFSZ);
|
||||
cw->morestr = morestr = (char*) alloc((unsigned) QBUFSZ);
|
||||
counting = FALSE;
|
||||
count = 0L;
|
||||
reset_count = TRUE;
|
||||
@@ -1509,41 +1479,20 @@ struct WinDesc *cw;
|
||||
Strcat(resp, gacc); /* group accelerators */
|
||||
Strcat(resp, mapped_menu_cmds);
|
||||
|
||||
if (cw->npages > 1) {
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
char buf[BUFSZ];
|
||||
Sprintf(buf, "(%d of %d)",
|
||||
curr_page + 1, (int) cw->npages);
|
||||
(void)nhwstrcpy(cw->morestr, buf);
|
||||
#else
|
||||
if (cw->npages > 1)
|
||||
Sprintf(cw->morestr, "(%d of %d)",
|
||||
curr_page + 1, (int) cw->npages);
|
||||
#endif
|
||||
} else if (msave) {
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
(void)nhwcpy(cw->morestr, msave);
|
||||
#else
|
||||
else if (msave)
|
||||
Strcpy(cw->morestr, msave);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
(void)nhwcpy(cw->morestr, defmorestr);
|
||||
#else
|
||||
else
|
||||
Strcpy(cw->morestr, defmorestr);
|
||||
#endif
|
||||
}
|
||||
|
||||
tty_curs(window, 1, page_lines);
|
||||
cl_end();
|
||||
dmore(cw, resp);
|
||||
} else {
|
||||
/* just put the cursor back... */
|
||||
tty_curs(window,
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
(int) nhwlen(cw->morestr) + 2,
|
||||
#else
|
||||
(int) strlen(cw->morestr) + 2,
|
||||
#endif
|
||||
page_lines);
|
||||
tty_curs(window, (int) strlen(cw->morestr) + 2, page_lines);
|
||||
xwaitforspace(resp);
|
||||
}
|
||||
|
||||
@@ -1707,7 +1656,7 @@ winid window;
|
||||
struct WinDesc *cw;
|
||||
{
|
||||
int i, n, attr;
|
||||
register nhwchar *cp;
|
||||
register char *cp;
|
||||
|
||||
for (n = 0, i = 0; i < cw->maxrow; i++) {
|
||||
if (!cw->offx && (n + cw->offy == ttyDisplay->rows - 1)) {
|
||||
@@ -1745,11 +1694,7 @@ struct WinDesc *cw;
|
||||
*cp && (int) ttyDisplay->curx < (int) ttyDisplay->cols;
|
||||
cp++, ttyDisplay->curx++)
|
||||
#endif
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
u_putch(*cp);
|
||||
#else
|
||||
(void) putchar(*cp);
|
||||
#endif
|
||||
term_end_attr(attr);
|
||||
}
|
||||
}
|
||||
@@ -1945,7 +1890,7 @@ register int x, y; /* not xchar: perhaps xchar is unsigned and
|
||||
case NHW_TEXT: s = "[text window]"; break;
|
||||
case NHW_BASE: s = "[base window]"; break;
|
||||
}
|
||||
impossible("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
|
||||
debugpline("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1995,7 +1940,7 @@ STATIC_OVL void
|
||||
tty_putsym(window, x, y, ch)
|
||||
winid window;
|
||||
int x, y;
|
||||
nhwchar ch;
|
||||
char ch;
|
||||
{
|
||||
register struct WinDesc *cw = 0;
|
||||
|
||||
@@ -2007,11 +1952,7 @@ tty_putsym(window, x, y, ch)
|
||||
case NHW_MAP:
|
||||
case NHW_BASE:
|
||||
tty_curs(window, x, y);
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
u_putch(ch);
|
||||
#else
|
||||
(void) putchar(ch);
|
||||
#endif
|
||||
ttyDisplay->curx++;
|
||||
cw->curx++;
|
||||
break;
|
||||
@@ -2054,14 +1995,9 @@ tty_putstr(window, attr, str)
|
||||
const char *str;
|
||||
{
|
||||
register struct WinDesc *cw = 0;
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
nhwchar symbuf[BUFSZ];
|
||||
register const nhwchar *symstr = symbuf;
|
||||
#else
|
||||
register const nhwchar *nb;
|
||||
register nhwchar *ob;
|
||||
register char *ob;
|
||||
register const char *nb;
|
||||
register int i, j, n0;
|
||||
#endif
|
||||
|
||||
/* Assume there's a real problem if the window is missing --
|
||||
* probably a panic message
|
||||
@@ -2076,52 +2012,21 @@ tty_putstr(window, attr, str)
|
||||
return;
|
||||
if(cw->type != NHW_MESSAGE)
|
||||
str = compress_str(str);
|
||||
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
||||
else
|
||||
play_sound_for_message(str);
|
||||
#endif
|
||||
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
nhwstrcpy(symbuf, str);
|
||||
tty_putstr_core(window, attr, symstr);
|
||||
}
|
||||
|
||||
void
|
||||
tty_putstr_core(window, attr, symstr)
|
||||
winid window;
|
||||
int attr;
|
||||
const nhwchar *symstr;
|
||||
{
|
||||
register struct WinDesc *cw = wins[window];
|
||||
register const nhwchar *nb;
|
||||
register nhwchar *ob;
|
||||
register int i, j, n0;
|
||||
#endif
|
||||
|
||||
ttyDisplay->lastwin = window;
|
||||
|
||||
switch(cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
/* really do this later */
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
update_topl(symstr);
|
||||
#else
|
||||
update_topl(str);
|
||||
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
||||
play_sound_for_message(str);
|
||||
#endif
|
||||
update_topl(str);
|
||||
break;
|
||||
|
||||
case NHW_STATUS:
|
||||
ob = &cw->data[cw->cury][j = cw->curx];
|
||||
if(context.botlx) *ob = 0;
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
if(!cw->cury && (int)nhwlen(symstr) >= CO) {
|
||||
/* the characters before "St:" are unnecessary */
|
||||
nb = nhwindex(symstr, L':');
|
||||
if(nb && nb > symstr+2)
|
||||
symstr = nb - 2;
|
||||
}
|
||||
nb = symstr;
|
||||
#else
|
||||
if(!cw->cury && (int)strlen(str) >= CO) {
|
||||
/* the characters before "St:" are unnecessary */
|
||||
nb = index(str, ':');
|
||||
@@ -2129,8 +2034,6 @@ tty_putstr_core(window, attr, symstr)
|
||||
str = nb - 2;
|
||||
}
|
||||
nb = str;
|
||||
#endif
|
||||
|
||||
for(i = cw->curx+1, n0 = cw->cols; i < n0; i++, nb++) {
|
||||
if(!*nb) {
|
||||
if(*ob || context.botlx) {
|
||||
@@ -2145,31 +2048,19 @@ tty_putstr_core(window, attr, symstr)
|
||||
if(*ob) ob++;
|
||||
}
|
||||
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
(void) nhwncpy(&cw->data[cw->cury][j], symstr, cw->cols - j - 1);
|
||||
#else
|
||||
(void) strncpy(&cw->data[cw->cury][j], str, cw->cols - j - 1);
|
||||
#endif
|
||||
cw->data[cw->cury][cw->cols-1] = (nhwchar)0; /* null terminate */
|
||||
cw->data[cw->cury][cw->cols-1] = '\0'; /* null terminate */
|
||||
cw->cury = (cw->cury+1) % 2;
|
||||
cw->curx = 0;
|
||||
break;
|
||||
case NHW_MAP:
|
||||
tty_curs(window, cw->curx+1, cw->cury);
|
||||
term_start_attr(attr);
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
while(*symstr && (int) ttyDisplay->curx < (int) ttyDisplay->cols-1) {
|
||||
u_putch(*symstr);
|
||||
symstr++;
|
||||
ttyDisplay->curx++;
|
||||
}
|
||||
#else
|
||||
while(*str && (int) ttyDisplay->curx < (int) ttyDisplay->cols-1) {
|
||||
(void) putchar(*str);
|
||||
str++;
|
||||
ttyDisplay->curx++;
|
||||
}
|
||||
#endif
|
||||
cw->curx = 0;
|
||||
cw->cury++;
|
||||
term_end_attr(attr);
|
||||
@@ -2177,23 +2068,14 @@ tty_putstr_core(window, attr, symstr)
|
||||
case NHW_BASE:
|
||||
tty_curs(window, cw->curx+1, cw->cury);
|
||||
term_start_attr(attr);
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
while (*symstr) {
|
||||
#else
|
||||
while (*str) {
|
||||
#endif
|
||||
if ((int) ttyDisplay->curx >= (int) ttyDisplay->cols-1) {
|
||||
cw->curx = 0;
|
||||
cw->cury++;
|
||||
tty_curs(window, cw->curx+1, cw->cury);
|
||||
}
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
u_putch(*symstr);
|
||||
symstr++;
|
||||
#else
|
||||
(void) putchar(*str);
|
||||
str++;
|
||||
#endif
|
||||
ttyDisplay->curx++;
|
||||
}
|
||||
cw->curx = 0;
|
||||
@@ -2220,10 +2102,10 @@ tty_putstr_core(window, attr, symstr)
|
||||
}
|
||||
/* always grows one at a time, but alloc 12 at a time */
|
||||
if(cw->cury >= cw->rows) {
|
||||
nhwchar **tmp;
|
||||
char **tmp;
|
||||
|
||||
cw->rows += 12;
|
||||
tmp = (nhwchar **) alloc(sizeof(nhwchar *) * (unsigned)cw->rows);
|
||||
tmp = (char **) alloc(sizeof(char *) * (unsigned)cw->rows);
|
||||
for(i=0; i<cw->maxrow; i++)
|
||||
tmp[i] = cw->data[i];
|
||||
if(cw->data)
|
||||
@@ -2235,19 +2117,10 @@ tty_putstr_core(window, attr, symstr)
|
||||
}
|
||||
if(cw->data[cw->cury])
|
||||
free((genericptr_t)cw->data[cw->cury]);
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
n0 = nhwlen(symstr) + 1;
|
||||
#else
|
||||
n0 = strlen(str) + 1;
|
||||
#endif
|
||||
|
||||
ob = cw->data[cw->cury] = (nhwchar *)alloc(sizeof(nhwchar) * ((unsigned)n0 + 1));
|
||||
*ob++ = (nhwchar)(attr + 1); /* avoid nuls, for convenience */
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
(void)nhwcpy(ob, symstr);
|
||||
#else
|
||||
ob = cw->data[cw->cury] = (char *)alloc((unsigned)n0 + 1);
|
||||
*ob++ = (char)(attr + 1); /* avoid nuls, for convenience */
|
||||
Strcpy(ob, str);
|
||||
#endif
|
||||
|
||||
if(n0 > cw->maxcol)
|
||||
cw->maxcol = n0;
|
||||
@@ -2255,19 +2128,11 @@ tty_putstr_core(window, attr, symstr)
|
||||
cw->maxrow = cw->cury;
|
||||
if(n0 > CO) {
|
||||
/* attempt to break the line */
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
for(i = CO-1; i && symstr[i] != L' ' && symstr[i] != L'\n';)
|
||||
#else
|
||||
for(i = CO-1; i && str[i] != ' ' && str[i] != '\n';)
|
||||
#endif
|
||||
i--;
|
||||
if(i) {
|
||||
cw->data[cw->cury-1][++i] = (nhwchar)0;
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
tty_putstr_core(window, attr, &symstr[i]);
|
||||
#else
|
||||
cw->data[cw->cury-1][++i] = '\0';
|
||||
tty_putstr(window, attr, &str[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2275,60 +2140,6 @@ tty_putstr_core(window, attr, symstr)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
/*
|
||||
* This differs from putstr() because the str parameter can
|
||||
* contain a sequence of characters representing:
|
||||
* \GXXXXNNNN a glyph value, encoded by encglyph().
|
||||
*
|
||||
*/
|
||||
void
|
||||
tty_putmixed(window, attr, str)
|
||||
winid window;
|
||||
int attr;
|
||||
const char *str;
|
||||
{
|
||||
nhwchar wbuf[BUFSZ];
|
||||
const char *cp = str;
|
||||
nhwchar *put = wbuf;
|
||||
while (*cp) {
|
||||
if (*cp == '\\') {
|
||||
int rndchk = 0, so = 0, gv = 0, ch, oc, dcount;
|
||||
unsigned os;
|
||||
const char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
|
||||
const char *save_cp = cp;
|
||||
|
||||
cp++;
|
||||
switch(*cp) {
|
||||
case 'G': /* glyph value \GXXXXNNNN*/
|
||||
dcount = 0;
|
||||
for (++cp; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++)
|
||||
rndchk = (int)((rndchk * 16) + ((int)(dp - hex) / 2));
|
||||
|
||||
if (rndchk == context.rndencode) {
|
||||
dcount = 0;
|
||||
for (; *cp && (dp = index(hex, *cp)) && (dcount++ < 4); cp++)
|
||||
gv = (int)((gv * 16) + ((int)(dp - hex) / 2));
|
||||
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
|
||||
*put++ = (nhwchar)showsyms[so];
|
||||
continue;
|
||||
} else {
|
||||
/* possible forgery - leave it the way it is */
|
||||
cp = save_cp;
|
||||
}
|
||||
break;
|
||||
case '\\':
|
||||
break;
|
||||
}
|
||||
}
|
||||
*put++ = (nhwchar)*cp++;
|
||||
}
|
||||
*put = (nhwchar)0;
|
||||
/* now send it to tty_putstr_core() */
|
||||
tty_putstr_core(window, attr, wbuf);
|
||||
}
|
||||
#endif /*UNICODE_WIDEWINPORT*/
|
||||
|
||||
void
|
||||
tty_display_file(fname, complain)
|
||||
const char *fname;
|
||||
@@ -2514,7 +2325,7 @@ tty_end_menu(window, prompt)
|
||||
/* Reverse the list so that items are in correct order. */
|
||||
cw->mlist = reverse(cw->mlist);
|
||||
|
||||
/* Put the prompt at the beginning of the menu. */
|
||||
/* Put the promt at the beginning of the menu. */
|
||||
if (prompt) {
|
||||
anything any;
|
||||
|
||||
@@ -2566,19 +2377,10 @@ tty_end_menu(window, prompt)
|
||||
/* produce the largest demo string */
|
||||
Sprintf(buf, "(%d of %d) ", cw->npages, cw->npages);
|
||||
len = strlen(buf);
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
cw->morestr = nhwchar_copy_of(emptysym);
|
||||
#else
|
||||
cw->morestr = copy_of("");
|
||||
#endif
|
||||
} else {
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
cw->morestr = nhwchar_copy_of(L"(end) ");
|
||||
len = nhwlen(cw->morestr);
|
||||
#else
|
||||
cw->morestr = copy_of("(end) ");
|
||||
len = strlen(cw->morestr);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (len > (int)ttyDisplay->cols) {
|
||||
@@ -2698,11 +2500,7 @@ tty_wait_synch()
|
||||
} else {
|
||||
tty_display_nhwindow(WIN_MAP, FALSE);
|
||||
if(ttyDisplay->inmore) {
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
addtopl(L"--More--");
|
||||
#else
|
||||
addtopl("--More--");
|
||||
#endif
|
||||
(void) fflush(stdout);
|
||||
} else if(ttyDisplay->inread > program_state.gameover) {
|
||||
/* this can only happen if we were reading and got interrupted */
|
||||
@@ -2774,58 +2572,6 @@ end_glyphout()
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef UNICODE_WIDEWINPORT
|
||||
/*
|
||||
* Parts of u_putch() were contributed by Adam Wozniak, 2005.
|
||||
*/
|
||||
void
|
||||
u_putch(sym)
|
||||
nhwchar sym;
|
||||
{
|
||||
unsigned long unicode = sym;
|
||||
if (!iflags.unicodedisp)
|
||||
putchar((char)sym);
|
||||
else {
|
||||
#if defined(UNIX) || defined(VMS)
|
||||
/* send utf8 to display */
|
||||
if (unicode < 0x80) {
|
||||
(void) putchar(unicode);
|
||||
} else if (unicode < 0x00000800) {
|
||||
(void) putchar(0xC0 | (unicode >> 6));
|
||||
(void) putchar(0x80 | (unicode & 0x3F));
|
||||
} else if (unicode < 0x00010000) {
|
||||
(void) putchar(0xE0 | (unicode >> 12));
|
||||
(void) putchar(0x80 | ((unicode >> 6) & 0x3F));
|
||||
(void) putchar(0x80 | (unicode & 0x3F));
|
||||
} else if (unicode < 0x00200000) {
|
||||
(void) putchar(0xF0 | (unicode >> 18));
|
||||
(void) putchar(0x80 | ((unicode >> 12) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 6) & 0x3F));
|
||||
(void) putchar(0x80 | (unicode & 0x3F));
|
||||
} else if (unicode < 0x04000000) {
|
||||
(void) putchar(0xF8 | (unicode >> 24));
|
||||
(void) putchar(0x80 | ((unicode >> 18) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 12) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 6) & 0x3F));
|
||||
(void) putchar(0x80 | (unicode & 0x3F));
|
||||
} else {
|
||||
(void) putchar(0xFC | (unicode >> 30));
|
||||
(void) putchar(0x80 | ((unicode >> 24) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 18) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 12) & 0x3F));
|
||||
(void) putchar(0x80 | ((unicode >> 6) & 0x3F));
|
||||
(void) putchar(0x80 | (unicode & 0x3F));
|
||||
}
|
||||
#else
|
||||
/* it is assumed that whatever is being substituted for
|
||||
putchar() can handle unicode characters directly at
|
||||
this point (nttty's xputc() for example) */
|
||||
(void) putchar(sym);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /*UNICODE_WIDEWINPORT*/
|
||||
|
||||
#ifndef WIN32
|
||||
void
|
||||
g_putch(in_ch)
|
||||
@@ -2834,11 +2580,6 @@ int in_ch;
|
||||
register char ch = (char)in_ch;
|
||||
|
||||
# if defined(ASCIIGRAPH) && !defined(NO_TERMS)
|
||||
# if defined(UNICODE_WIDEWINPORT) && defined(UNICODE_DRAWING)
|
||||
if (iflags.unicodedisp && symset[currentgraphics].name) {
|
||||
u_putch(in_ch);
|
||||
} else
|
||||
# endif
|
||||
if (SYMHANDLING(H_IBM) || iflags.eight_bit_tty) {
|
||||
/* IBM-compatible displays don't need other stuff */
|
||||
(void) putchar(ch);
|
||||
@@ -2922,9 +2663,9 @@ tty_print_glyph(window, x, y, glyph)
|
||||
xchar x, y;
|
||||
int glyph;
|
||||
{
|
||||
int ch, idx;
|
||||
int ch;
|
||||
boolean reverse_on = FALSE;
|
||||
int color;
|
||||
int color;
|
||||
unsigned special;
|
||||
|
||||
#ifdef CLIPPING
|
||||
@@ -2934,7 +2675,7 @@ tty_print_glyph(window, x, y, glyph)
|
||||
}
|
||||
#endif
|
||||
/* map glyph to character and color */
|
||||
idx = mapglyph(glyph, &ch, &color, &special, x, y);
|
||||
(void)mapglyph(glyph, &ch, &color, &special, x, y);
|
||||
|
||||
/* Move the cursor. */
|
||||
tty_curs(window, x,y);
|
||||
@@ -2967,11 +2708,6 @@ tty_print_glyph(window, x, y, glyph)
|
||||
if (iflags.grmode && iflags.tile_view)
|
||||
xputg(glyph,ch,special);
|
||||
else
|
||||
#endif
|
||||
#if defined(UNICODE_WIDEWINPORT) && defined(UNICODE_DRAWING)
|
||||
if (iflags.unicodedisp && symset[currentgraphics].name)
|
||||
g_putch(showsyms[idx]); /* use the unicode symset */
|
||||
else
|
||||
#endif
|
||||
g_putch(ch); /* print the character */
|
||||
|
||||
@@ -3126,15 +2862,6 @@ copy_of(s)
|
||||
return strcpy((char *) alloc((unsigned) (strlen(s) + 1)), s);
|
||||
}
|
||||
|
||||
# ifdef UNICODE_WIDEWINPORT
|
||||
STATIC_OVL nhwchar *
|
||||
nhwchar_copy_of(s)
|
||||
const nhwchar *s;
|
||||
{
|
||||
if (!s) s = emptysym;
|
||||
return nhwcpy((nhwchar *) alloc(sizeof(nhwchar) * (unsigned) (nhwlen(s) + 1)), s);
|
||||
}
|
||||
# endif /*UNICODE_WIDEWINPORT*/
|
||||
#endif /* TTY_GRAPHICS */
|
||||
|
||||
/*wintty.c*/
|
||||
|
||||
Reference in New Issue
Block a user