refactor print in the midle function

This commit is contained in:
2024-11-29 20:12:07 +01:00
parent e5c2ae6da5
commit 83c8f8a324
5 changed files with 43 additions and 47 deletions
-26
View File
@@ -13,8 +13,6 @@ char *choices[] = {
"login", "Grades", "shedule", "Komens",
"Homework", "Absence", "Exit", (char *)NULL,
};
void print_in_middle(WINDOW *win, int starty, int startx, int width,
char *string, chtype color);
void main_menu() {
ITEM **my_items;
@@ -104,27 +102,3 @@ void main_menu() {
free_item(my_items[i]);
endwin();
}
void print_in_middle(WINDOW *win, int starty, int startx, int width,
char *string, chtype color) {
int length, x, y;
float temp;
if (win == NULL)
win = stdscr;
getyx(win, y, x);
if (startx != 0)
x = startx;
if (starty != 0)
y = starty;
if (width == 0)
width = 80;
length = strlen(string);
temp = (width - length) / 2;
x = startx + (int)temp;
wattron(win, color);
mvwprintw(win, y, x, "%s", string);
wattroff(win, color);
refresh();
}