#include #include #ifdef __linux__ #include #include #elif _WIN32 #include #include #endif // import sub programme #include "test_prog.h" /* Photonics helper main programm Das main programm startet die sub programme der verschienene gruppen Autor: Noah Balsinger, Thomas Zwicker Version: 0.1 Datum: 04.12.2024 Änderungen: 0.1 04.12.2024 Dokument erstellt 0.2 09.12.2024 Willkommensnachricht */ #ifdef __linux__ void get_terminal_size_linux(int argc, char **argv, int *width, int *height){ struct winsize w; ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); *height = w.ws_row; *width = w.ws_col; } #elif _WIN32 void get_terminal_size_windows(int argc, char **argv, int *width, int *height){ CONSOLE_SCREEN_BUFFER_INFO csbi; int columns, rows; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi); *width = csbi.srWindow.Right - csbi.srWindow.Left + 1; *height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1; } #endif void print_wellcome_line(char line[100], int spaces){ for(int i = 0; i < spaces; i++){ printf(" "); } printf("%s\n", line); } void clear_terminal(){ #ifdef __linux__ printf("\e[1;1H\e[2J"); #elif _WIN32 system("cls"); #endif } void sleep_universal(int t){ #ifdef __linux__ sleep(t); #elif _WIN32 Sleep(t * 1000); #endif } void print_wellcome(int terminal_width, int terminal_height){ clear_terminal(); for(int i = 0; i < (terminal_height - 10) / 2; i++){ printf("\n"); } int spaces = (terminal_width - 83) / 2; print_wellcome_line("__ ___ _ _ _ ", spaces); print_wellcome_line("\\ \\ / (_) | | | _____ _ __ ___ _ __ ___ ___ _ __ _____ _ _ __ ___ ", spaces); print_wellcome_line(" \\ \\ /\\ / /| | | | |/ / _ \\| '_ ` _ \\| '_ ` _ \\ / _ \\ '_ \\ |_ / | | | '_ ` _ \\", spaces); print_wellcome_line(" \\ V V / | | | | < (_) | | | | | | | | | | | __/ | | | / /| |_| | | | | | | ", spaces); print_wellcome_line(" \\_/\\_/ |_|_|_|_|\\_\\___/|_| |_| |_|_| |_| |_|\\___|_| |_| /___|\\__,_|_| |_| |_| ", spaces); print_wellcome_line(" ", spaces); print_wellcome_line(" ____ _ _ _ _ _ _ _ __ ", spaces); print_wellcome_line("| _ \\| |__ ___ | |_| |__ ___ _ __ (_) ___ ___ | | | | ___| |/ _| ___ _ __ ", spaces); print_wellcome_line("| |_) | '_ \\ / _ \\| __| '_ \\ / _ \\| '_ \\| |/ __/ __| | |_| |/ _ \\ | |_ / _ \\ '__| ", spaces); print_wellcome_line("| __/| | | | (_) | |_| | | | (_) | | | | | (__\\__ \\ | _ | __/ | _| __/ | ", spaces); print_wellcome_line("|_| |_| |_|\\___/ \\__|_| |_|\\___/|_| |_|_|\\___|___/ |_| |_|\\___|_|_| \\___|_| ", spaces); sleep_universal(3); /* printf("__ ___ _ _ _ "); printf("\ \ / (_) | | | _____ _ __ ___ _ __ ___ ___ _ __ _____ _ _ __ ___ "); printf(" \ \ /\ / /| | | | |/ / _ \| '_ ` _ \| '_ ` _ \ / _ \ '_ \ |_ / | | | '_ ` _ \ "); printf(" \ V V / | | | | < (_) | | | | | | | | | | | __/ | | | / /| |_| | | | | | |"); printf(" \_/\_/ |_|_|_|_|\_\___/|_| |_| |_|_| |_| |_|\___|_| |_| /___|\__,_|_| |_| |_|"); printf(" "); printf(" ____ _ _ _ _ _ _ _ __ "); printf("| _ \| |__ ___ | |_| |__ ___ _ __ (_) ___ ___ | | | | ___| |/ _| ___ _ __ "); printf("| |_) | '_ \ / _ \| __| '_ \ / _ \| '_ \| |/ __/ __| | |_| |/ _ \ | |_ / _ \ '__|"); printf("| __/| | | | (_) | |_| | | | (_) | | | | | (__\__ \ | _ | __/ | _| __/ | "); printf("|_| |_| |_|\___/ \__|_| |_|\___/|_| |_|_|\___|___/ |_| |_|\___|_|_| \___|_| "); */ } int main(int argc, char **argv){ int width = 0; int height = 0; int os = 0; // 0 == None, 1 = linux, 2 = windows // Terminal grösse herauslesen #ifdef __linux__ 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(); printf ("lines %d\n", height); printf ("columns %d\n", width); // neues terminal öffnen (nur linux) system("tput smcup"); // print wellcome message print_wellcome(width, height); // zürück zum alten terminal (nur linux) system("tput rmcup"); return 0; }