Commit b7741df0 authored by deuce's avatar deuce
Browse files

If GetConsoleScreenBufferInfo() succeeds, attemtp to set the initial mode

to the closest size as the cirrent window (This may only work on NT 'cause
it sure doesn't do anything on 9x)
parent 56c0d3a4
......@@ -188,7 +188,7 @@ int try_ansi_init(int mode)
int try_conio_init(int mode)
{
/* This should test for something or other */
if(win32_initciolib(C80)) {
if(win32_initciolib(mode)) {
cio_api.mode=CIOLIB_MODE_CONIO;
cio_api.mouse=1;
cio_api.puttext=win32_puttext;
......
......@@ -325,6 +325,7 @@ int win32_initciolib(long inmode)
{
DWORD conmode;
int i,j;
CONSOLE_SCREEN_BUFFER_INFO sbuff;
if(!isatty(fileno(stdin)))
return(0);
......@@ -342,7 +343,47 @@ int win32_initciolib(long inmode)
if(!SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), conmode))
return(0);
win32_textmode(inmode);
if(GetConsoleScreenBufferInfo(GetStdHandle(STD_INPUT_HANDLE), &sbuff)==0) {
win32_textmode(C80);
}
else {
/* Switch to closest mode to current screen size */
i=sbuff.srWindow.Right-sbuff.srWindow.Left+1;
j=sbuff.srWindow.Bottom-sbuff.srWindow.Top+1;
if(i>=80) {
if(j<21)
win32_textmode(C80X14);
else if(j<25)
win32_textmode(C80X21);
else if(j<28)
win32_textmode(C80);
else if(j<43)
win32_textmode(C80X28);
else if(j<50)
win32_textmode(C80X43);
else if(j<60)
win32_textmode(C80X50);
else
win32_textmode(C80X60);
}
else {
if(j<21)
win32_textmode(C40X14);
else if(j<25)
win32_textmode(C40X21);
else if(j<28)
win32_textmode(C40);
else if(j<43)
win32_textmode(C40X28);
else if(j<50)
win32_textmode(C40X43);
else if(j<60)
win32_textmode(C40X50);
else
win32_textmode(C40X60);
}
}
cio_api.mouse=1;
return(1);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment