File tree Expand file tree Collapse file tree 2 files changed +31
-5
lines changed
Expand file tree Collapse file tree 2 files changed +31
-5
lines changed Original file line number Diff line number Diff line change 11debug : card.h game.c game.h main.c main.h shuffle.c shuffle.h symbols.h terminal.c terminal.h
2- gcc -Og -g -std=c23 -Wall -Wextra -Werror game.c main.c shuffle.c terminal.c -o kb_solitaire.elf
2+ gcc -Og -g -std=c2x -Wall -Wextra -Werror game.c main.c shuffle.c terminal.c -o kb_solitaire.elf
33
4- clean : kb_solitaire.elf
5- rm kb_solitaire.elf
4+ clean :
5+ if [ -e kb_solitaire.elf ]; then\
6+ rm kb_solitaire.elf; \
7+ fi
8+ if [ -e kb_solitaire.exe ]; then\
9+ rm kb_solitaire.exe; \
10+ fi\
611
712run :
813 make debug
914 ./kb_solitaire.elf
1015
1116o3 : card.h game.c game.h main.c main.h shuffle.c shuffle.h symbols.h terminal.c terminal.h
12- gcc -O3 -std=c23 -Wall -Wextra -Werror game.c main.c shuffle.c terminal.c -o kb_solitaire.elf
17+ gcc -O3 -std=c2x -Wall -Wextra -Werror game.c main.c shuffle.c terminal.c -o kb_solitaire.elf
18+
19+ windows : card.h game.c game.h main.c main.h shuffle.c shuffle.h symbols.h terminal.c terminal.h
20+ x86_64-w64-mingw32-gcc -D MSWIN -O3 -std=c2x -Wall -Wextra -Werror game.c main.c shuffle.c terminal.c -o kb_solitaire.exe
Original file line number Diff line number Diff line change 44#include "symbols.h"
55#include <stdio.h>
66#include <stdlib.h>
7+
8+ #ifdef MSWIN
9+ #include <windows.h>
10+
11+ static DWORD outer_settings ;
12+ static UINT encoding ;
13+
14+ inline void init_terminal () {
15+ GetConsoleMode (GetStdHandle (STD_INPUT_HANDLE ), & outer_settings );
16+ encoding = GetConsoleOutputCP ();
17+ DWORD settings = outer_settings & ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT );
18+ SetConsoleMode (GetStdHandle (STD_INPUT_HANDLE ), settings );
19+ SetConsoleOutputCP (65001 );
20+ atexit (exit_terminal );
21+ }
22+ void exit_terminal () { SetConsoleMode (STDIN_FILENO , outer_settings ); }
23+ #else
724#include <termios.h>
825#include <unistd.h>
926
@@ -17,6 +34,7 @@ inline void init_terminal() {
1734 atexit (exit_terminal );
1835}
1936void exit_terminal () { tcsetattr (STDIN_FILENO , TCSAFLUSH , & outer_settings ); }
37+ #endif
2038
2139inline void clear_screen () { printf ("\e[2J\e[3J\e[;H" ); }
2240
@@ -191,7 +209,7 @@ void refresh_screen() {
191209 } else {
192210 printf (" " );
193211 }
194- } else {
212+ } else {
195213 printf (" " );
196214 }
197215 if (column < len (tableau )) {
You can’t perform that action at this time.
0 commit comments