summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d508947)
raw | patch | inline | side by side (parent: d508947)
author | Max Kellermann <max.kellermann@gmail.com> | |
Mon, 20 Mar 2017 19:41:37 +0000 (20:41 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Mon, 20 Mar 2017 19:41:37 +0000 (20:41 +0100) |
src/screen.c | patch | blob | history | |
src/screen.h | patch | blob | history |
diff --git a/src/screen.c b/src/screen.c
index a8c80bcee3897f0603fe6f934444af06798cdc50..0d242de017fe6d1d34110a74250a664ef92183cc 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
#endif
/* minimum window size */
-static const int SCREEN_MIN_COLS = 14;
-static const int SCREEN_MIN_ROWS = 5;
+static const unsigned SCREEN_MIN_COLS = 14;
+static const unsigned SCREEN_MIN_ROWS = 5;
/* screens */
void
screen_resize(struct mpdclient *c)
{
- if (COLS<SCREEN_MIN_COLS || LINES<SCREEN_MIN_ROWS) {
+ const unsigned cols = COLS, rows = LINES;
+ if (cols < SCREEN_MIN_COLS || rows < SCREEN_MIN_ROWS) {
screen_exit();
fprintf(stderr, "%s\n", _("Error: Screen too small"));
exit(EXIT_FAILURE);
}
+
#ifdef PDCURSES
- resize_term(LINES, COLS);
+ resize_term(rows, cols);
#else
- resizeterm(LINES, COLS);
+ resizeterm(rows, cols);
#endif
- screen.cols = COLS;
- screen.rows = LINES;
-
- title_bar_resize(&screen.title_bar, screen.cols);
+ title_bar_resize(&screen.title_bar, cols);
/* main window */
- screen.main_window.cols = screen.cols;
- screen.main_window.rows = screen.rows-4;
- wresize(screen.main_window.w, screen.main_window.rows, screen.cols);
+ screen.main_window.cols = cols;
+ screen.main_window.rows = rows - 4;
+ wresize(screen.main_window.w, screen.main_window.rows, cols);
/* progress window */
- progress_bar_resize(&screen.progress_bar, screen.cols,
- screen.rows - 2, 0);
+ progress_bar_resize(&screen.progress_bar, cols, rows - 2, 0);
/* status window */
- status_bar_resize(&screen.status_bar, screen.cols, screen.rows - 1, 0);
+ status_bar_resize(&screen.status_bar, cols, rows - 1, 0);
- screen.buf_size = screen.cols;
+ screen.buf_size = cols;
g_free(screen.buf);
- screen.buf = g_malloc(screen.cols);
+ screen.buf = g_malloc(cols);
/* resize all screens */
screen_list_resize(screen.main_window.cols, screen.main_window.rows);
void
screen_init(struct mpdclient *c)
{
- if (COLS < SCREEN_MIN_COLS || LINES < SCREEN_MIN_ROWS) {
+ const unsigned cols = COLS, rows = LINES;
+ if (cols < SCREEN_MIN_COLS || rows < SCREEN_MIN_ROWS) {
fprintf(stderr, "%s\n", _("Error: Screen too small"));
exit(EXIT_FAILURE);
}
- screen.cols = COLS;
- screen.rows = LINES;
-
- screen.buf = g_malloc(screen.cols);
- screen.buf_size = screen.cols;
+ screen.buf = g_malloc(cols);
+ screen.buf_size = cols;
screen.findbuf = NULL;
#ifndef NCMPC_MINI
#endif
/* create top window */
- title_bar_init(&screen.title_bar, screen.cols, 0, 0);
+ title_bar_init(&screen.title_bar, cols, 0, 0);
/* create main window */
- window_init(&screen.main_window, screen.rows - 4, screen.cols, 2, 0);
+ window_init(&screen.main_window, rows - 4, cols, 2, 0);
if (!options.hardware_cursor)
leaveok(screen.main_window.w, TRUE);
keypad(screen.main_window.w, TRUE);
/* create progress window */
- progress_bar_init(&screen.progress_bar, screen.cols,
- screen.rows - 2, 0);
+ progress_bar_init(&screen.progress_bar, cols, rows - 2, 0);
/* create status window */
- status_bar_init(&screen.status_bar, screen.cols, screen.rows - 1, 0);
+ status_bar_init(&screen.status_bar, cols, rows - 1, 0);
#ifdef ENABLE_COLORS
if (options.enable_colors) {
diff --git a/src/screen.h b/src/screen.h
index 3b6f7247a0db467043e3f25d91e052f6ab68e5a2..c546e281b1b91183b3dde806a11e49e7bec6eafc 100644 (file)
--- a/src/screen.h
+++ b/src/screen.h
struct progress_bar progress_bar;
struct status_bar status_bar;
- unsigned cols, rows;
-
char *buf;
size_t buf_size;