From 5a0317eaf3db5a3ce2b80c74d30248c87c4a7df4 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sat, 4 Dec 2010 22:15:20 +0100 Subject: [PATCH] check at startup if terminal window is big enough to display UI properly --- src/ncmpcpp.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 0657eaeb..8f4b1a18 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -97,6 +97,16 @@ namespace bool order_resize = 0; size_t header_height, footer_start_y, footer_height; + void check_screen_min_size() + { + if (COLS < 20 || MainHeight < 3) + { + DestroyScreen(); + std::cout << "Screen is too small!\n"; + exit(1); + } + } + void resize_screen() { order_resize = 0; @@ -122,12 +132,7 @@ namespace RedrawHeader = 1; MainHeight = LINES-(Config.new_design ? 7 : 4); - if (COLS < 20 || MainHeight < 3) - { - DestroyScreen(); - std::cout << "Screen is too small!\n"; - exit(1); - } + check_screen_min_size(); if (!Config.header_visibility) MainHeight += 2; @@ -272,6 +277,7 @@ int main(int argc, char *argv[]) Config.statusbar_visibility = 0; SetWindowsDimensions(header_height, footer_start_y, footer_height); + check_screen_min_size(); wHeader = new Window(0, 0, COLS, header_height, "", Config.header_color, brNone); if (Config.header_visibility || Config.new_design)