| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4f2de3e commit e0b4260
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -365,15 +365,16 @@ static void print_function_line(void) | |||
| 365 | 365 | int i; | |
| 366 | 366 | int offset = 1; | |
| 367 | 367 | const int skip = 1; | |
| 368 | + int lines = getmaxy(stdscr); | ||
| 368 | 369 | ||
| 369 | 370 | for (i = 0; i < function_keys_num; i++) { | |
| 370 | 371 | (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); | |
| 371 | - mvwprintw(main_window, LINES-3, offset, | ||
| 372 | + mvwprintw(main_window, lines-3, offset, | ||
| 372 | 373 | "%s", | |
| 373 | 374 | function_keys[i].key_str); | |
| 374 | 375 | (void) wattrset(main_window, attributes[FUNCTION_TEXT]); | |
| 375 | 376 | offset += strlen(function_keys[i].key_str); | |
| 376 | - mvwprintw(main_window, LINES-3, | ||
| 377 | + mvwprintw(main_window, lines-3, | ||
| 377 | 378 | offset, "%s", | |
| 378 | 379 | function_keys[i].func); | |
| 379 | 380 | offset += strlen(function_keys[i].func) + skip; | |
@@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions, | |||
| 954 | 955 | ||
| 955 | 956 | clear(); | |
| 956 | 957 | (void) wattrset(main_window, attributes[NORMAL]); | |
| 957 | - print_in_middle(stdscr, 1, 0, COLS, | ||
| 958 | + print_in_middle(stdscr, 1, 0, getmaxx(stdscr), | ||
| 958 | 959 | menu_backtitle, | |
| 959 | 960 | attributes[MAIN_HEADING]); | |
| 960 | 961 | ||
@@ -1455,21 +1456,26 @@ static void conf_save(void) | |||
| 1455 | 1456 | ||
| 1456 | 1457 | void setup_windows(void) | |
| 1457 | 1458 | { | |
| 1459 | + int lines, columns; | ||
| 1460 | + | ||
| 1461 | + getmaxyx(stdscr, lines, columns); | ||
| 1462 | + | ||
| 1458 | 1463 | if (main_window != NULL) | |
| 1459 | 1464 | delwin(main_window); | |
| 1460 | 1465 | ||
| 1461 | 1466 | /* set up the menu and menu window */ | |
| 1462 | - main_window = newwin(LINES-2, COLS-2, 2, 1); | ||
| 1467 | + main_window = newwin(lines-2, columns-2, 2, 1); | ||
| 1463 | 1468 | keypad(main_window, TRUE); | |
| 1464 | - mwin_max_lines = LINES-7; | ||
| 1465 | - mwin_max_cols = COLS-6; | ||
| 1469 | + mwin_max_lines = lines-7; | ||
| 1470 | + mwin_max_cols = columns-6; | ||
| 1466 | 1471 | ||
| 1467 | 1472 | /* panels order is from bottom to top */ | |
| 1468 | 1473 | new_panel(main_window); | |
| 1469 | 1474 | } | |
| 1470 | 1475 | ||
| 1471 | 1476 | int main(int ac, char **av) | |
| 1472 | 1477 | { | |
| 1478 | + int lines, columns; | ||
| 1473 | 1479 | char *mode; | |
| 1474 | 1480 | ||
| 1475 | 1481 | setlocale(LC_ALL, ""); | |
@@ -1495,7 +1501,8 @@ int main(int ac, char **av) | |||
| 1495 | 1501 | keypad(stdscr, TRUE); | |
| 1496 | 1502 | curs_set(0); | |
| 1497 | 1503 | ||
| 1498 | - if (COLS < 75 || LINES < 20) { | ||
| 1504 | + getmaxyx(stdscr, lines, columns); | ||
| 1505 | + if (columns < 75 || lines < 20) { | ||
| 1499 | 1506 | endwin(); | |
| 1500 | 1507 | printf("Your terminal should have at " | |
| 1501 | 1508 | "least 20 lines and 75 columns\n"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) | |||
| 276 | 276 | ||
| 277 | 277 | total_width = max(msg_width, btns_width); | |
| 278 | 278 | /* place dialog in middle of screen */ | |
| 279 | - y = (LINES-(msg_lines+4))/2; | ||
| 280 | - x = (COLS-(total_width+4))/2; | ||
| 279 | + y = (getmaxy(stdscr)-(msg_lines+4))/2; | ||
| 280 | + x = (getmaxx(stdscr)-(total_width+4))/2; | ||
| 281 | 281 | ||
| 282 | 282 | ||
| 283 | 283 | /* create the windows */ | |
@@ -387,8 +387,8 @@ int dialog_inputbox(WINDOW *main_window, | |||
| 387 | 387 | prompt_width = max(prompt_width, strlen(title)); | |
| 388 | 388 | ||
| 389 | 389 | /* place dialog in middle of screen */ | |
| 390 | - y = (LINES-(prompt_lines+4))/2; | ||
| 391 | - x = (COLS-(prompt_width+4))/2; | ||
| 390 | + y = (getmaxy(stdscr)-(prompt_lines+4))/2; | ||
| 391 | + x = (getmaxx(stdscr)-(prompt_width+4))/2; | ||
| 392 | 392 | ||
| 393 | 393 | strncpy(result, init, *result_len); | |
| 394 | 394 | ||
@@ -545,7 +545,7 @@ void show_scroll_win(WINDOW *main_window, | |||
| 545 | 545 | { | |
| 546 | 546 | int res; | |
| 547 | 547 | int total_lines = get_line_no(text); | |
| 548 | - int x, y; | ||
| 548 | + int x, y, lines, columns; | ||
| 549 | 549 | int start_x = 0, start_y = 0; | |
| 550 | 550 | int text_lines = 0, text_cols = 0; | |
| 551 | 551 | int total_cols = 0; | |
@@ -556,6 +556,8 @@ void show_scroll_win(WINDOW *main_window, | |||
| 556 | 556 | WINDOW *pad; | |
| 557 | 557 | PANEL *panel; | |
| 558 | 558 | ||
| 559 | + getmaxyx(stdscr, lines, columns); | ||
| 560 | + | ||
| 559 | 561 | /* find the widest line of msg: */ | |
| 560 | 562 | total_lines = get_line_no(text); | |
| 561 | 563 | for (i = 0; i < total_lines; i++) { | |
@@ -569,14 +571,14 @@ void show_scroll_win(WINDOW *main_window, | |||
| 569 | 571 | (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); | |
| 570 | 572 | fill_window(pad, text); | |
| 571 | 573 | ||
| 572 | - win_lines = min(total_lines+4, LINES-2); | ||
| 573 | - win_cols = min(total_cols+2, COLS-2); | ||
| 574 | + win_lines = min(total_lines+4, lines-2); | ||
| 575 | + win_cols = min(total_cols+2, columns-2); | ||
| 574 | 576 | text_lines = max(win_lines-4, 0); | |
| 575 | 577 | text_cols = max(win_cols-2, 0); | |
| 576 | 578 | ||
| 577 | 579 | /* place window in middle of screen */ | |
| 578 | - y = (LINES-win_lines)/2; | ||
| 579 | - x = (COLS-win_cols)/2; | ||
| 580 | + y = (lines-win_lines)/2; | ||
| 581 | + x = (columns-win_cols)/2; | ||
| 580 | 582 | ||
| 581 | 583 | win = newwin(win_lines, win_cols, y, x); | |
| 582 | 584 | keypad(win, TRUE); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments