add win32 (msvc) support
This commit is contained in:
54
term/sys/windows/print.c
Normal file
54
term/sys/windows/print.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <Windows.h>
|
||||
|
||||
int z__b_stream_is_tty(FILE *fp)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
HANDLE console = (HANDLE)_get_osfhandle(fileno(fp));
|
||||
BOOL status = GetConsoleScreenBufferInfo(console, &csbi);
|
||||
|
||||
return status == TRUE ? 1 : 0;
|
||||
}
|
||||
|
||||
int z__b_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
HANDLE console = (HANDLE)_get_osfhandle(fileno(fp));
|
||||
BOOL status = GetConsoleScreenBufferInfo(console, &csbi);
|
||||
|
||||
if (status == FALSE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (w) {
|
||||
*w = csbi.dwMaximumWindowSize.X;
|
||||
}
|
||||
|
||||
if (h) {
|
||||
*h = csbi.dwMaximumWindowSize.Y;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int z__b_stream_cursorpos(FILE *in, FILE *out, unsigned int *x, unsigned int *y)
|
||||
{
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
HANDLE console = (HANDLE)_get_osfhandle(fileno(in));
|
||||
BOOL status = GetConsoleScreenBufferInfo(console, &csbi);
|
||||
|
||||
if (status == FALSE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (x) {
|
||||
*x = csbi.dwCursorPosition.X;
|
||||
}
|
||||
|
||||
if (y) {
|
||||
*y = csbi.dwCursorPosition.Y;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user