changeset 332:a1901741890e

scr_LogPrint() can be called before ncurses initialization
author Mikael Berthe <mikael@lilotux.net>
date Mon, 18 Jul 2005 18:57:50 +0100
parents 1510dda4ad71
children db5bebe96c89
files mcabber/src/screen.c
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/screen.c	Sun Jul 17 22:21:51 2005 +0100
+++ b/mcabber/src/screen.c	Mon Jul 18 18:57:50 2005 +0100
@@ -70,6 +70,7 @@
 int update_roster;
 int utf8_mode = 0;
 static bool Autoaway;
+static bool Curses;
 
 static char       inputLine[INPUTLINE_LENGTH+1];
 static char      *ptr_inputline;
@@ -469,6 +470,7 @@
   halfdelay(5);
   start_color();
   use_default_colors();
+  Curses = TRUE;
 
   ParseColors();
 
@@ -489,6 +491,7 @@
   clear();
   refresh();
   endwin();
+  Curses = FALSE;
   return;
 }
 
@@ -1105,17 +1108,23 @@
 
   timestamp = time(NULL);
   strftime(buffer, 64, "[%H:%M:%S] ", localtime(&timestamp));
-  wprintw(logWnd, "\n%s", buffer);
+  if (Curses)
+    wprintw(logWnd, "\n%s", buffer);
+  else
+    printf("%s", buffer);
 
   va_start(ap, fmt);
   vsnprintf(buffer, 1024, fmt, ap);
   va_end(ap);
 
-  wprintw(logWnd, "%s", buffer);
+  if (Curses) {
+    wprintw(logWnd, "%s", buffer);
+    update_panels();
+    doupdate();
+  } else {
+    printf("%s\n", buffer);
+  }
   free(buffer);
-
-  update_panels();
-  doupdate();
 }
 
 //  scr_set_chatmode()