diff --git a/src/main.c b/src/main.c index 4cfc5b8..fab8232 100644 --- a/src/main.c +++ b/src/main.c @@ -9,7 +9,7 @@ #elif _WIN32 #include #include - #include + system("chcp 65001 >null"); #endif // import sub programme @@ -25,6 +25,7 @@ Datum: 04.12.2024 Änderungen: 0.1 04.12.2024 Dokument erstellt 0.2 09.12.2024 Willkommensnachricht +0.3 10.12.2024 Meun hinzugefügt */ #ifdef __linux__ @@ -154,32 +155,17 @@ void print_menu(int terminal_width, int terminal_height, int line){ print_blank_lines((terminal_height - 11) / 2); int spaces = (terminal_width - 41) / 2; - #ifdef __linux__ print_line("┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓", spaces, (0 <= line && line < 1) ? ";31": ";37"); print_line("┃ Programm 1 ┃", spaces, (0 <= line && line < 1) ? ";31": ";37"); print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (0 <= line && line < 2) ? ";31": ";37"); - print_line("┃ Programm 1 ┃", spaces, (1 <= line && line < 2) ? ";31": ";37"); + print_line("┃ Programm 2 ┃", spaces, (1 <= line && line < 2) ? ";31": ";37"); print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (1 <= line && line < 3) ? ";31": ";37"); - print_line("┃ Programm 1 ┃", spaces, (2 <= line && line < 3) ? ";31": ";37"); + print_line("┃ Programm 3 ┃", spaces, (2 <= line && line < 3) ? ";31": ";37"); print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (2 <= line && line < 4) ? ";31": ";37"); - print_line("┃ Programm 1 ┃", spaces, (3 <= line && line < 4) ? ";31": ";37"); + print_line("┃ Programm 4 ┃", spaces, (3 <= line && line < 4) ? ";31": ";37"); print_line("┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫", spaces, (3 <= line && line < 5) ? ";31": ";37"); print_line("┃ ┃", spaces, (4 <= line && line < 5) ? ";31": ";37"); print_line("┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛", spaces, (4 <= line && line < 5) ? ";31": ";37"); - #elif _WIN32 - print_line("+---------------------------------------+", spaces, (0 <= line && line < 1) ? ";31": ";37"); - print_line("| Programm 1 |", spaces, (0 <= line && line < 1) ? ";31": ";37"); - print_line("+---------------------------------------+", spaces, (0 <= line && line < 2) ? ";31": ";37"); - print_line("| Programm 1 |", spaces, (1 <= line && line < 2) ? ";31": ";37"); - print_line("+---------------------------------------+", spaces, (1 <= line && line < 3) ? ";31": ";37"); - print_line("| Programm 1 |", spaces, (2 <= line && line < 3) ? ";31": ";37"); - print_line("+---------------------------------------+", spaces, (2 <= line && line < 4) ? ";31": ";37"); - print_line("| Programm 1 |", spaces, (3 <= line && line < 4) ? ";31": ";37"); - print_line("+---------------------------------------+", spaces, (3 <= line && line < 5) ? ";31": ";37"); - print_line("| |", spaces, (4 <= line && line < 5) ? ";31": ";37"); - print_line("+---------------------------------------+", spaces, (4 <= line && line < 5) ? ";31": ";37"); - #endif - } @@ -199,19 +185,25 @@ void print_help(){ } 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); +} + +void get_terminal_size_init(int argc, char **argv, int *width, int *height){ + get_terminal_size(argc, argv, width, height); + if (*width < 100 || *height < 30){ + clear_terminal(); + printf("Terminal zu klein!\n"); + + while(*width < 100 || *height < 30){ + get_terminal_size(argc, argv, width, height); + sleep_universal(1); } - }while(*width < 100 || *height < 20); + } } int main(int argc, char **argv){ @@ -220,30 +212,31 @@ int main(int argc, char **argv){ int line = 0; bool run = true; - // Terminal grösse herauslesen - get_terminal_size(argc, argv, &width, &height); + // neues terminal öffnen (nur linux) + #ifdef __linux__ + system("tput smcup"); + #endif + + // Terminal grösse herauslesen + // get_terminal_size(argc, argv, &width, &height); + get_terminal_size_init(argc, argv, &width, &height); + - // int x = test_gruppe_programmname(); printf ("lines %d\n", height); printf ("columns %d\n", width); - // neues terminal öffnen (nur linux) - #ifdef __linux__ - system("tput smcup"); - #endif // print wellcome message print_wellcome(width, height); // print_game_over(width, height); // print_menu(width, height, line); while(run){ - get_terminal_size(argc, argv, &width, &height); + get_terminal_size_init(argc, argv, &width, &height); print_menu(width, height, line); - // char key_input = (char)getch(); - char key_input = (char)0; + char key_input = (char)getch(); switch (key_input) { case 'k': line--; break;