]> Nishi Git Mirror - libw3.git/commitdiff
windows fix
authornishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Mon, 29 Jan 2024 03:25:51 +0000 (03:25 +0000)
committernishi <nishi@d27a3e52-49c5-7645-884c-6793ebffc270>
Mon, 29 Jan 2024 03:25:51 +0000 (03:25 +0000)
git-svn-id: file:///raid/svn-main/nishi-libw3/trunk@131 d27a3e52-49c5-7645-884c-6793ebffc270

Example/w3b/w3b.c

index b5cc32fe0af9038ab857cdacb7214c67b23b770c..0ed391f3c650f003acdfeab58b8d12592058305b 100644 (file)
@@ -44,8 +44,8 @@ void get_terminal_size(int* width, int* height) {
 #ifdef __MINGW32__
        CONSOLE_SCREEN_BUFFER_INFO csbi;
        GetConsoleScreenBufferInfo(winstdout, &csbi);
-       *width = csbi.dwSize.X;
-       *height = csbi.dwSize.Y;
+       *width = csbi.srWindow.Right - csbi.srWindow.Left + 1;
+       *height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
 #else
        struct winsize ws;
        ioctl(0, TIOCGWINSZ, &ws);
@@ -261,6 +261,7 @@ void render_site() {
                char* seq = malloc(1024);
                sprintf(seq, "\x1b[1;%dH", termw - strlen(titlebuf != NULL ? titlebuf : "No title") - 1);
 #ifdef __MINGW32__
+               DWORD written = 0;
                WriteConsole(winstdout, seq, strlen(seq), &written, NULL);
 #else
                printf("%s\x1b[7m %s \x1b[m", seq, titlebuf != NULL ? titlebuf : "No title");