# HG changeset patch # User Mikael Berthe # Date 1131989697 -3600 # Node ID 9480a76471b69b17bc178f1ce6ccdf72a86b6ded # Parent d8f4a0fc77d392fe4df52790ccf043934f16f080 Update Log_Win_Height when refreshing the screen It allows live modification of the 'log_win_height' option. The log window height is reduced when the screen height is reduced too much, too. diff -r d8f4a0fc77d3 -r 9480a76471b6 mcabber/src/main.c --- a/mcabber/src/main.c Mon Nov 14 18:17:47 2005 +0100 +++ b/mcabber/src/main.c Mon Nov 14 18:34:57 2005 +0100 @@ -234,8 +234,6 @@ /* Initialize N-Curses */ scr_LogPrint(LPRINT_DEBUG, "Initializing N-Curses..."); scr_InitCurses(); - - scr_LogPrint(LPRINT_DEBUG, "Drawing main window..."); scr_DrawMainWindow(TRUE); optval = (settings_opt_get_int("logging") > 0); diff -r d8f4a0fc77d3 -r 9480a76471b6 mcabber/src/screen.c --- a/mcabber/src/screen.c Mon Nov 14 18:17:47 2005 +0100 +++ b/mcabber/src/screen.c Mon Nov 14 18:34:57 2005 +0100 @@ -204,7 +204,6 @@ void scr_InitCurses(void) { - int requested_lwh; initscr(); raw(); noecho(); @@ -218,25 +217,9 @@ getmaxyx(stdscr, maxY, maxX); Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; + // Note scr_DrawMainWindow() should be called early after scr_InitCurses() + // to update Log_Win_Height and set max{X,Y} - requested_lwh = settings_opt_get_int("log_win_height"); - if (requested_lwh > 0) { - if (maxY > requested_lwh + 3) - Log_Win_Height = requested_lwh + 2; - else - Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3); - } else if (requested_lwh < 0) { - Log_Win_Height = 3; - } - - if (maxY < Log_Win_Height+2) { - if (maxY < 5) { - Log_Win_Height = 3; - maxY = Log_Win_Height+2; - } else { - Log_Win_Height = maxY - 2; - } - } inputLine[0] = 0; ptr_inputline = inputLine; @@ -571,6 +554,28 @@ // void scr_DrawMainWindow(unsigned int fullinit) { + int requested_lwh; + + Log_Win_Height = DEFAULT_LOG_WIN_HEIGHT; + requested_lwh = settings_opt_get_int("log_win_height"); + if (requested_lwh > 0) { + if (maxY > requested_lwh + 3) + Log_Win_Height = requested_lwh + 2; + else + Log_Win_Height = ((maxY > 5) ? (maxY - 2) : 3); + } else if (requested_lwh < 0) { + Log_Win_Height = 3; + } + + if (maxY < Log_Win_Height+2) { + if (maxY < 5) { + Log_Win_Height = 3; + maxY = Log_Win_Height+2; + } else { + Log_Win_Height = maxY - 2; + } + } + if (fullinit) { /* Create windows */ rosterWnd = newwin(CHAT_WIN_HEIGHT, ROSTER_WIDTH, 0, 0); @@ -653,8 +658,8 @@ // First, update the global variables getmaxyx(stdscr, maxY, maxX); - if (maxY < Log_Win_Height+2) - maxY = Log_Win_Height+2; + // scr_DrawMainWindow() will take care of maxY and Log_Win_Height + // Make sure the cursor stays inside the window check_offset(0);