add win32 (msvc) support
This commit is contained in:
@@ -30,14 +30,14 @@ typedef enum b_print_format {
|
||||
B_PRINT_ERR,
|
||||
} b_print_format;
|
||||
|
||||
extern b_status b_term_get_dimensions(FILE *fp, unsigned int *w, unsigned int *h);
|
||||
BLUE_API b_status b_term_get_dimensions(FILE *fp, unsigned int *w, unsigned int *h);
|
||||
|
||||
extern b_status b_print(b_print_format format, const char *str, ...);
|
||||
extern b_status b_print_paragraph(
|
||||
BLUE_API b_status b_print(b_print_format format, const char *str, ...);
|
||||
BLUE_API b_status b_print_paragraph(
|
||||
const char *str, FILE *fp, b_paragraph_format *format);
|
||||
|
||||
extern int b_fputs(const char *str, FILE *fp);
|
||||
extern int b_printf(const char *format, ...);
|
||||
extern int b_fprintf(FILE *fp, const char *format, ...);
|
||||
BLUE_API int b_fputs(const char *str, FILE *fp);
|
||||
BLUE_API int b_printf(const char *format, ...);
|
||||
BLUE_API int b_fprintf(FILE *fp, const char *format, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#ifndef _BLUELIB_PRINT_H_
|
||||
#define _BLUELIB_PRINT_H_
|
||||
|
||||
#include <blue/core/misc.h>
|
||||
#include <blue/term.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern int z__b_stream_is_tty(FILE *fp);
|
||||
extern int z__b_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h);
|
||||
extern int z__b_stream_cursorpos(
|
||||
BLUE_API int z__b_stream_is_tty(FILE *fp);
|
||||
BLUE_API int z__b_stream_dimensions(FILE *fp, unsigned int *w, unsigned int *h);
|
||||
BLUE_API int z__b_stream_cursorpos(
|
||||
FILE *in, FILE *out, unsigned int *x, unsigned int *y);
|
||||
|
||||
#endif
|
||||
|
||||
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