win32tty changes

1. Switch to low-level console routines for performance improvements.
2. Instead of moving the cursor around like a real tty, just track the
   destination coordinates of where the cursor should be, and
   defer the movement until user input is expected.

Credit to <Someone> for #2.
This commit is contained in:
nethack.allison
2003-10-05 23:00:05 +00:00
parent 4775dd3cbf
commit bc70857749
7 changed files with 149 additions and 227 deletions
+1 -12
View File
@@ -275,19 +275,8 @@ char *argv[];
# endif # endif
#endif #endif
if (!*plname) { if (!*plname)
#ifdef WIN32CON
boolean revert = FALSE;
if (!iflags.rawio) {
set_output_mode(1);
revert = TRUE;
}
#endif
askname(); askname();
#ifdef WIN32CON
if (revert && iflags.rawio) set_output_mode(0);
#endif
}
plnamesuffix(); /* strip suffix from name; calls askname() */ plnamesuffix(); /* strip suffix from name; calls askname() */
/* again if suffix was whole name */ /* again if suffix was whole name */
/* accepts any suffix */ /* accepts any suffix */
-3
View File
@@ -416,9 +416,6 @@ msmsg VA_DECL(const char *, fmt)
if (iflags.grmode) if (iflags.grmode)
gr_finish(); gr_finish();
# endif # endif
#ifdef WIN32CON
if (iflags.rawio) set_output_mode(0);
#endif
Vprintf(fmt, VA_ARGS); Vprintf(fmt, VA_ARGS);
flushout(); flushout();
VA_END(); VA_END();
-3
View File
@@ -75,9 +75,6 @@ error VA_DECL(const char *,s)
VA_INIT(s, const char *); VA_INIT(s, const char *);
/* error() may get called before tty is initialized */ /* error() may get called before tty is initialized */
if (iflags.window_inited) end_screen(); if (iflags.window_inited) end_screen();
#ifdef WIN32CON
if (iflags.rawio) set_output_mode(0);
#endif
putchar('\n'); putchar('\n');
Vprintf(s,VA_ARGS); Vprintf(s,VA_ARGS);
putchar('\n'); putchar('\n');
-6
View File
@@ -103,9 +103,6 @@ getlock()
# if defined(MSDOS) && defined(NO_TERMS) # if defined(MSDOS) && defined(NO_TERMS)
int grmode = iflags.grmode; int grmode = iflags.grmode;
# endif # endif
#ifdef WIN32CON
if (iflags.rawio) set_output_mode(0);
#endif
/* we ignore QUIT and INT at this point */ /* we ignore QUIT and INT at this point */
if (!lock_file(HLOCK, LOCKPREFIX, 10)) { if (!lock_file(HLOCK, LOCKPREFIX, 10)) {
wait_synch(); wait_synch();
@@ -263,9 +260,6 @@ gotlock:
# if defined(MSDOS) && defined(NO_TERMS) # if defined(MSDOS) && defined(NO_TERMS)
if (grmode) gr_init(); if (grmode) gr_init();
# endif # endif
#ifdef WIN32CON
if (!iflags.rawio) set_output_mode(1);
#endif
} }
#endif /* PC_LOCKING */ #endif /* PC_LOCKING */
+124 -203
View File
@@ -9,6 +9,7 @@
*/ */
#ifdef WIN32CON #ifdef WIN32CON
#define LOW_LEVEL_OUTPUT
#define NEED_VARARGS /* Uses ... */ #define NEED_VARARGS /* Uses ... */
#include "hack.h" #include "hack.h"
#include "wintty.h" #include "wintty.h"
@@ -32,7 +33,8 @@ int FDECL(process_keystroke, (INPUT_RECORD *, boolean *,
* SetConsoleCtrlHandler * SetConsoleCtrlHandler
* PeekConsoleInput * PeekConsoleInput
* ReadConsoleInput * ReadConsoleInput
* WriteConsole * WriteConsoleOutputCharacter
* FillConsoleOutputAttribute
*/ */
/* Win32 Console handles for input and output */ /* Win32 Console handles for input and output */
@@ -110,21 +112,15 @@ static void NDECL(init_ttycolor);
#define MAX_OVERRIDES 256 #define MAX_OVERRIDES 256
unsigned char key_overrides[MAX_OVERRIDES]; unsigned char key_overrides[MAX_OVERRIDES];
#define DEFTEXTCOLOR ttycolors[7]
#ifdef TEXTCOLOR
#define DEFGLYPHBGRND (0)
#else
#define DEFGLYPHBGRND (0)
#endif
static char nullstr[] = ""; static char nullstr[] = "";
char erase_char,kill_char; char erase_char,kill_char;
static char currentcolor = FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE; #define DEFTEXTCOLOR ttycolors[7]
static char noninvertedcurrentcolor = FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE; static WORD background = 0;
static char currenthilite = 0; static WORD foreground = (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);
static char currentbackground = 0; static WORD attr = (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);
static boolean colorchange = TRUE; static DWORD ccount, acount;
static COORD cursor;
/* /*
* Called after returning from ! or ^Z * Called after returning from ! or ^Z
@@ -151,42 +147,11 @@ void
settty(s) settty(s)
const char *s; const char *s;
{ {
nocmov(ttyDisplay->curx, ttyDisplay->cury);
end_screen(); end_screen();
if(s) raw_print(s); if(s) raw_print(s);
} }
/*
* mode == 0 set processed console output mode.
* mode == 1 set raw console output mode (no control character expansion).
*/
void
set_output_mode(mode)
int mode;
{
static DWORD save_output_cmode = 0;
static boolean initmode = FALSE;
DWORD cmode, mask = ENABLE_PROCESSED_OUTPUT;
if (!initmode) {
/* fetch original output mode */
GetConsoleMode(hConOut,&save_output_cmode);
initmode = TRUE;
}
if (mode == 0) {
cmode = save_output_cmode;
/* Turn ON the settings specified in the mask */
cmode |= mask;
SetConsoleMode(hConOut,cmode);
iflags.rawio = 0;
} else {
cmode = save_output_cmode;
/* Turn OFF the settings specified in the mask */
cmode &= ~mask;
SetConsoleMode(hConOut,cmode);
iflags.rawio = 1;
}
}
/* called by init_nhwindows() and resume_nhwindows() */ /* called by init_nhwindows() and resume_nhwindows() */
void void
setftty() setftty()
@@ -198,7 +163,6 @@ void
tty_startup(wid, hgt) tty_startup(wid, hgt)
int *wid, *hgt; int *wid, *hgt;
{ {
/* int twid = origcsbi.dwSize.X; */
int twid = origcsbi.srWindow.Right - origcsbi.srWindow.Left + 1; int twid = origcsbi.srWindow.Right - origcsbi.srWindow.Left + 1;
if (twid > 80) twid = 80; if (twid > 80) twid = 80;
@@ -253,7 +217,6 @@ DWORD ctrltype;
case CTRL_CLOSE_EVENT: case CTRL_CLOSE_EVENT:
case CTRL_LOGOFF_EVENT: case CTRL_LOGOFF_EVENT:
case CTRL_SHUTDOWN_EVENT: case CTRL_SHUTDOWN_EVENT:
set_output_mode(0); /* Allow processed output */
getreturn_disable = TRUE; getreturn_disable = TRUE;
#ifndef NOSAVEONHANGUP #ifndef NOSAVEONHANGUP
hangup(0); hangup(0);
@@ -293,10 +256,11 @@ nttty_open()
(origcsbi.dwCursorPosition.Y == 0)); (origcsbi.dwCursorPosition.Y == 0));
if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0)) if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0))
GUILaunched = 0; GUILaunched = 0;
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE); hConIn = GetStdHandle(STD_INPUT_HANDLE);
hConOut = GetStdHandle(STD_OUTPUT_HANDLE); hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
#if 0 #if 0
/* Obtain handles for the standard Console I/O devices */
hConIn = CreateFile("CONIN$", hConIn = CreateFile("CONIN$",
GENERIC_READ |GENERIC_WRITE, GENERIC_READ |GENERIC_WRITE,
FILE_SHARE_READ |FILE_SHARE_WRITE, FILE_SHARE_READ |FILE_SHARE_WRITE,
@@ -306,6 +270,7 @@ nttty_open()
FILE_SHARE_READ |FILE_SHARE_WRITE, FILE_SHARE_READ |FILE_SHARE_WRITE,
0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0); 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,0);
#endif #endif
GetConsoleMode(hConIn,&cmode); GetConsoleMode(hConIn,&cmode);
#ifdef NO_MOUSE_ALLOWED #ifdef NO_MOUSE_ALLOWED
mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | mask = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
@@ -320,8 +285,6 @@ nttty_open()
cmode |= ENABLE_MOUSE_INPUT; cmode |= ENABLE_MOUSE_INPUT;
#endif #endif
SetConsoleMode(hConIn,cmode); SetConsoleMode(hConIn,cmode);
set_output_mode(1); /* raw output mode; no tab expansion */
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE)) { if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, TRUE)) {
/* Unable to set control handler */ /* Unable to set control handler */
cmode = 0; /* just to have a statement to break on for debugger */ cmode = 0; /* just to have a statement to break on for debugger */
@@ -376,6 +339,7 @@ tgetch()
int mod; int mod;
coord cc; coord cc;
DWORD count; DWORD count;
nocmov(ttyDisplay->curx, ttyDisplay->cury);
return (program_state.done_hup) ? return (program_state.done_hup) ?
'\033' : '\033' :
pCheckInput(hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc); pCheckInput(hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
@@ -388,6 +352,7 @@ int *x, *y, *mod;
int ch; int ch;
coord cc; coord cc;
DWORD count; DWORD count;
nocmov(ttyDisplay->curx, ttyDisplay->cury);
ch = (program_state.done_hup) ? ch = (program_state.done_hup) ?
'\033' : '\033' :
pCheckInput(hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc); pCheckInput(hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc);
@@ -398,57 +363,51 @@ int *x, *y, *mod;
return ch; return ch;
} }
void
nocmov(x, y)
int x,y;
{
ntcoord.X = x;
ntcoord.Y = y;
SetConsoleCursorPosition(hConOut,ntcoord);
}
void void
cmov(x, y) cmov(x, y)
register int x, y; register int x, y;
{ {
ntcoord.X = x;
ntcoord.Y = y;
SetConsoleCursorPosition(hConOut,ntcoord);
ttyDisplay->cury = y;
ttyDisplay->curx = x; ttyDisplay->curx = x;
ttyDisplay->cury = y;
cursor.X = x;
cursor.Y = y;
SetConsoleCursorPosition(hConOut, cursor);
} }
void void
xputc(c) nocmov(x, y)
char c; int x,y;
{ {
DWORD count; cursor.Y = y;
cursor.X = x;
SetConsoleCursorPosition(hConOut, cursor);
}
switch(c) { void
xputc(ch)
char ch;
{
cursor.X = ttyDisplay->curx;
cursor.Y = ttyDisplay->cury;
switch(ch) {
case '\n': case '\n':
case '\r': case '\r':
cmov(ttyDisplay->curx, ttyDisplay->cury); cmov(ttyDisplay->curx, ttyDisplay->cury);
return; return;
} }
if (colorchange) { WriteConsoleOutputAttribute(hConOut,&attr,1,cursor,&acount);
SetConsoleTextAttribute(hConOut, WriteConsoleOutputCharacter(hConOut,&ch,1,cursor,&ccount);
(currentcolor | currenthilite | currentbackground));
colorchange = FALSE;
}
WriteConsole(hConOut,&c,1,&count,0);
} }
void void
xputs(s) xputs(s)
const char *s; const char *s;
{ {
DWORD count; int slen = strlen(s);
if (colorchange) { cursor.X = ttyDisplay->curx;
SetConsoleTextAttribute(hConOut, cursor.Y = ttyDisplay->cury;
(currentcolor | currenthilite | currentbackground)); FillConsoleOutputAttribute(hConOut,attr,slen,cursor,&acount);
colorchange = FALSE; WriteConsoleOutputCharacter(hConOut,s,slen,cursor,&ccount);
}
WriteConsole(hConOut,s,strlen(s),&count,0);
} }
/* /*
@@ -459,36 +418,32 @@ void
g_putch(in_ch) g_putch(in_ch)
int in_ch; int in_ch;
{ {
char ch = (char)in_ch; char ch = (char)in_ch;
DWORD count = 1; cursor.X = ttyDisplay->curx;
int tcolor; cursor.Y = ttyDisplay->cury;
int bckgnd = currentbackground; #if 0
switch(ch) {
if (colorchange) { case '\n':
tcolor = currentcolor | bckgnd | currenthilite; case '\r':
SetConsoleTextAttribute(hConOut, tcolor); cmov(cursor.X, cursor.Y);
} return;
WriteConsole(hConOut,&ch,1,&count,0); }
colorchange = TRUE; /* force next output back to current nethack values */ #endif
return; WriteConsoleOutputAttribute(hConOut,&attr,1,cursor,&acount);
WriteConsoleOutputCharacter(hConOut,&ch,1,cursor,&ccount);
} }
void void
cl_end() cl_end()
{ {
DWORD count; int cx;
cursor.X = ttyDisplay->curx;
ntcoord.X = ttyDisplay->curx; cursor.Y = ttyDisplay->cury;
ntcoord.Y = ttyDisplay->cury; cx = CO - cursor.X;
FillConsoleOutputAttribute(hConOut, DEFTEXTCOLOR, FillConsoleOutputAttribute(hConOut, DEFTEXTCOLOR, cx, cursor, &acount);
CO - ntcoord.X,ntcoord, &count); FillConsoleOutputCharacter(hConOut,' ', cx, cursor,&ccount);
ntcoord.X = ttyDisplay->curx; tty_curs(BASE_WINDOW, (int)ttyDisplay->curx+1,
ntcoord.Y = ttyDisplay->cury; (int)ttyDisplay->cury);
FillConsoleOutputCharacter(hConOut,' ',
CO - ntcoord.X,ntcoord,&count);
tty_curs(BASE_WINDOW, (int)ttyDisplay->curx+1,
(int)ttyDisplay->cury);
colorchange = TRUE;
} }
@@ -505,13 +460,10 @@ clear_screen()
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
csbi.dwSize.X * csbi.dwSize.Y, csbi.dwSize.X * csbi.dwSize.Y,
newcoord, &ccnt); newcoord, &ccnt);
newcoord.X = 0;
newcoord.Y = 0;
FillConsoleOutputCharacter(hConOut,' ', FillConsoleOutputCharacter(hConOut,' ',
csbi.dwSize.X * csbi.dwSize.Y, csbi.dwSize.X * csbi.dwSize.Y,
newcoord, &ccnt); newcoord, &ccnt);
} }
colorchange = TRUE;
home(); home();
} }
@@ -519,7 +471,7 @@ clear_screen()
void void
home() home()
{ {
tty_curs(BASE_WINDOW, 1, 0); cursor.X = cursor.Y = 0;
ttyDisplay->curx = ttyDisplay->cury = 0; ttyDisplay->curx = ttyDisplay->cury = 0;
} }
@@ -527,17 +479,34 @@ home()
void void
backsp() backsp()
{ {
GetConsoleScreenBufferInfo(hConOut,&csbi); GetConsoleScreenBufferInfo(hConOut,&csbi);
if (csbi.dwCursorPosition.X > 0) if (csbi.dwCursorPosition.X > 0)
ntcoord.X = csbi.dwCursorPosition.X-1; ntcoord.X = csbi.dwCursorPosition.X-1;
ntcoord.Y = csbi.dwCursorPosition.Y; ntcoord.Y = csbi.dwCursorPosition.Y;
SetConsoleCursorPosition(hConOut,ntcoord); SetConsoleCursorPosition(hConOut,ntcoord);
/* colorchange shouldn't ever happen here but.. */ }
if (colorchange) {
SetConsoleTextAttribute(hConOut, void
(currentcolor|currenthilite|currentbackground)); cl_eos()
colorchange = FALSE; {
register int cy = ttyDisplay->cury+1;
if (GetConsoleScreenBufferInfo(hConOut,&csbi)) {
DWORD ccnt;
COORD newcoord;
newcoord.X = 0;
newcoord.Y = ttyDisplay->cury;
FillConsoleOutputAttribute(hConOut,
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
csbi.dwSize.X * csbi.dwSize.Y - cy,
newcoord, &ccnt);
newcoord.X = 0;
newcoord.Y = ttyDisplay->cury;
FillConsoleOutputCharacter(hConOut,' ',
csbi.dwSize.X * csbi.dwSize.Y - cy,
newcoord, &ccnt);
} }
tty_curs(BASE_WINDOW, (int)ttyDisplay->curx+1, (int)ttyDisplay->cury);
} }
void void
@@ -562,41 +531,6 @@ tty_delay_output()
} }
} }
void
cl_eos()
{
register int cy = ttyDisplay->cury+1;
#if 0
while(cy <= LI-2) {
cl_end();
xputc('\n');
cy++;
}
cl_end();
#else
if (GetConsoleScreenBufferInfo(hConOut,&csbi)) {
DWORD ccnt;
COORD newcoord;
newcoord.X = 0;
newcoord.Y = ttyDisplay->cury;
FillConsoleOutputAttribute(hConOut,
FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
csbi.dwSize.X * csbi.dwSize.Y - cy,
newcoord, &ccnt);
newcoord.X = 0;
newcoord.Y = ttyDisplay->cury;
FillConsoleOutputCharacter(hConOut,' ',
csbi.dwSize.X * csbi.dwSize.Y - cy,
newcoord, &ccnt);
}
colorchange = TRUE;
#endif
tty_curs(BASE_WINDOW, (int)ttyDisplay->curx+1,
(int)ttyDisplay->cury);
}
# ifdef TEXTCOLOR # ifdef TEXTCOLOR
/* /*
* CLR_BLACK 0 * CLR_BLACK 0
@@ -661,111 +595,97 @@ has_color(int color)
} }
void void
term_start_attr(int attr) term_start_attr(int attrib)
{ {
switch(attr){ switch(attrib){
case ATR_INVERSE: case ATR_INVERSE:
if (iflags.wc_inverse) { if (iflags.wc_inverse) {
noninvertedcurrentcolor = currentcolor;
/* Suggestion by Lee Berger */ /* Suggestion by Lee Berger */
if ((currentcolor & (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED)) == if ((foreground & (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED)) ==
(FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED)) (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED))
currentcolor = 0; foreground &= ~(FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);
currentbackground = (BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN); background = (BACKGROUND_RED|BACKGROUND_BLUE|BACKGROUND_GREEN);
colorchange = TRUE;
break; break;
} /* else */ }
/*FALLTHRU*/ /*FALLTHRU*/
case ATR_ULINE: case ATR_ULINE:
case ATR_BOLD:
case ATR_BLINK: case ATR_BLINK:
standoutbeg(); case ATR_BOLD:
foreground |= FOREGROUND_INTENSITY;
break; break;
default: default:
#ifdef DEBUG foreground &= ~FOREGROUND_INTENSITY;
impossible("term_start_attr: strange attribute %d", attr);
#endif
standoutend();
if (currentcolor == 0)
currentcolor = FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED;
currentbackground = 0;
break; break;
} }
attr = (foreground | background);
} }
void void
term_end_attr(int attr) term_end_attr(int attrib)
{ {
switch(attr){ switch(attrib){
case ATR_INVERSE: case ATR_INVERSE:
if (iflags.wc_inverse) { if ((foreground & (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED)) == 0)
if (currentcolor == 0 && noninvertedcurrentcolor != 0) foreground |= (FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED);
currentcolor = noninvertedcurrentcolor; background = 0;
noninvertedcurrentcolor = 0; break;
currentbackground = 0;
colorchange = TRUE;
break;
} /* else */
/*FALLTHRU*/
case ATR_ULINE: case ATR_ULINE:
case ATR_BOLD:
case ATR_BLINK: case ATR_BLINK:
default: case ATR_BOLD:
standoutend(); foreground &= ~FOREGROUND_INTENSITY;
if (currentcolor == 0) break;
currentcolor = FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_RED;
currentbackground = 0;
break;
} }
attr = (foreground | background);
} }
void void
term_end_raw_bold(void) term_end_raw_bold(void)
{ {
standoutend(); term_end_attr(ATR_BOLD);
} }
void void
term_start_raw_bold(void) term_start_raw_bold(void)
{ {
standoutbeg(); term_start_attr(ATR_BOLD);
} }
void void
term_start_color(int color) term_start_color(int color)
{ {
# ifdef TEXTCOLOR #ifdef TEXTCOLOR
if (color >= 0 && color < CLR_MAX) { if (color >= 0 && color < CLR_MAX) {
currentcolor = ttycolors[color]; foreground = (background != 0 && (color == CLR_GRAY | color == CLR_WHITE)) ?
colorchange = TRUE; ttycolors[0] : ttycolors[color];
} }
# endif #else
foreground = DEFTEXTCOLOR;
#endif
attr = (foreground | background);
} }
void void
term_end_color(void) term_end_color(void)
{ {
# ifdef TEXTCOLOR #ifdef TEXTCOLOR
currentcolor = DEFTEXTCOLOR; foreground = DEFTEXTCOLOR;
colorchange = TRUE; #endif
# endif attr = (foreground | background);
} }
void void
standoutbeg() standoutbeg()
{ {
currenthilite = FOREGROUND_INTENSITY; term_start_attr(ATR_BOLD);
colorchange = TRUE;
} }
void void
standoutend() standoutend()
{ {
currenthilite = 0; term_end_attr(ATR_BOLD);
colorchange = TRUE;
} }
#ifndef NO_MOUSE_ALLOWED #ifndef NO_MOUSE_ALLOWED
@@ -803,6 +723,7 @@ win32con_debug_keystrokes()
int ch; int ch;
xputs("\n"); xputs("\n");
while (!valid || ch != 27) { while (!valid || ch != 27) {
nocmov(ttyDisplay->curx, ttyDisplay->cury);
ReadConsoleInput(hConIn,&ir,1,&count); ReadConsoleInput(hConIn,&ir,1,&count);
if ((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown) if ((ir.EventType == KEY_EVENT) && ir.Event.KeyEvent.bKeyDown)
ch = process_keystroke(&ir, &valid, iflags.num_pad, 1); ch = process_keystroke(&ir, &valid, iflags.num_pad, 1);
+8
View File
@@ -272,15 +272,23 @@ topl_putsym(c)
ttyDisplay->curx = 0; ttyDisplay->curx = 0;
ttyDisplay->cury++; ttyDisplay->cury++;
cw->cury = ttyDisplay->cury; cw->cury = ttyDisplay->cury;
#ifdef WIN32CON
(void) putchar(c);
#endif
break; break;
default: default:
if(ttyDisplay->curx == CO-1) if(ttyDisplay->curx == CO-1)
topl_putsym('\n'); /* 1 <= curx <= CO; avoid CO */ topl_putsym('\n'); /* 1 <= curx <= CO; avoid CO */
#ifdef WIN32CON
(void) putchar(c);
#endif
ttyDisplay->curx++; ttyDisplay->curx++;
} }
cw->curx = ttyDisplay->curx; cw->curx = ttyDisplay->curx;
if(cw->curx == 0) cl_end(); if(cw->curx == 0) cl_end();
#ifndef WIN32CON
(void) putchar(c); (void) putchar(c);
#endif
} }
void void
+16
View File
@@ -688,6 +688,9 @@ tty_askname()
if (c == '\b' || c == '\177') { if (c == '\b' || c == '\177') {
if(ct) { if(ct) {
ct--; ct--;
#ifdef WIN32CON
ttyDisplay->curx--;
#endif
#if defined(MICRO) || defined(WIN32CON) #if defined(MICRO) || defined(WIN32CON)
# if defined(WIN32CON) || defined(MSDOS) # if defined(WIN32CON) || defined(MSDOS)
backsp(); /* \b is visible on NT */ backsp(); /* \b is visible on NT */
@@ -720,6 +723,9 @@ tty_askname()
(void) putchar(c); (void) putchar(c);
#endif #endif
plname[ct++] = c; plname[ct++] = c;
#ifdef WIN32CON
ttyDisplay->curx++;
#endif
} }
} }
plname[ct] = 0; plname[ct] = 0;
@@ -1217,8 +1223,13 @@ struct WinDesc *cw;
*/ */
term_start_attr(curr->attr); term_start_attr(curr->attr);
for (n = 0, cp = curr->str; for (n = 0, cp = curr->str;
#ifndef WIN32CON
*cp && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols; *cp && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
cp++, n++) cp++, n++)
#else
*cp && (int) ttyDisplay->curx < (int) ttyDisplay->cols;
cp++, n++, ttyDisplay->curx++)
#endif
if (n == 2 && curr->identifier.a_void != 0 && if (n == 2 && curr->identifier.a_void != 0 &&
curr->selected) { curr->selected) {
if (curr->count == -1L) if (curr->count == -1L)
@@ -1453,8 +1464,13 @@ struct WinDesc *cw;
} }
term_start_attr(attr); term_start_attr(attr);
for (cp = &cw->data[i][1]; for (cp = &cw->data[i][1];
#ifndef WIN32CON
*cp && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols; *cp && (int) ++ttyDisplay->curx < (int) ttyDisplay->cols;
cp++) cp++)
#else
*cp && (int) ttyDisplay->curx < (int) ttyDisplay->cols;
cp++, ttyDisplay->curx++)
#endif
(void) putchar(*cp); (void) putchar(*cp);
term_end_attr(attr); term_end_attr(attr);
} }