changeset 518:9480a76471b6

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.
author Mikael Berthe <mikael@lilotux.net>
date Mon, 14 Nov 2005 18:34:57 +0100
parents d8f4a0fc77d3
children 5c338d31de56
files mcabber/src/main.c mcabber/src/screen.c
diffstat 2 files changed, 26 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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);