brock terminal size

main
MuedeHydra 2024-12-10 16:07:51 +01:00
parent dc9fb47460
commit 9cea3342ed
1 changed files with 24 additions and 12 deletions

View File

@ -198,21 +198,30 @@ void print_help(){
// getchar(); // getchar();
} }
void get_terminal_size(int argc, char **argv, int *width, int *height){
do{
#ifdef __linux__
get_terminal_size_linux(argc, argv, width, height);
#elif _WIN32
get_terminal_size_windows(argc, argv, width, height);
#endif
if (*width < 100 || *height < 20){
clear_terminal();
printf("Terminal zu klein!");
// sleep_universal(1);
}
}while(*width < 100 || *height < 20);
}
int main(int argc, char **argv){ int main(int argc, char **argv){
int width = 0; int width = 0;
int height = 0; int height = 0;
int os = 0; // 0 == None, 1 = linux, 2 = windows
int line = 0; int line = 0;
bool run = true; bool run = true;
// Terminal grösse herauslesen // Terminal grösse herauslesen
#ifdef __linux__ get_terminal_size(argc, argv, &width, &height);
os = 1;
get_terminal_size_linux(argc, argv, &width, &height);
#elif _WIN32
os = 2;
get_terminal_size_windows(argc, argv, &width, &height);
#endif
// int x = test_gruppe_programmname(); // int x = test_gruppe_programmname();
@ -227,11 +236,14 @@ int main(int argc, char **argv){
#endif #endif
// print wellcome message // print wellcome message
// print_wellcome(width, height); print_wellcome(width, height);
// print_game_over(width, height); // print_game_over(width, height);
print_menu(width, height, line); // print_menu(width, height, line);
while(run){ while(run){
char key_input = (char)getch(); get_terminal_size(argc, argv, &width, &height);
print_menu(width, height, line);
// char key_input = (char)getch();
char key_input = (char)0;
switch (key_input) { switch (key_input) {
case 'k': line--; break; case 'k': line--; break;
@ -253,7 +265,7 @@ int main(int argc, char **argv){
} }
if(line < 0){line = 4;} if(line < 0){line = 4;}
if(line > 4){line = 0;} if(line > 4){line = 0;}
print_menu(width, height, line); // print_menu(width, height, line);
} }
// zürück zum alten terminal (nur linux) // zürück zum alten terminal (nur linux)
#ifdef __linux__ #ifdef __linux__