comparison mcabber/src/screen.c @ 851:da03534e46c7

Add startup log messages to the status buffer With this patch, status history buffer can be written to even before ncurses are initialized.
author Mikael Berthe <mikael@lilotux.net>
date Mon, 08 May 2006 23:47:26 +0200
parents d0781ca2dd08
children ef35a2bb40d7
comparison
equal deleted inserted replaced
850:d0781ca2dd08 851:da03534e46c7
70 static PANEL *mainstatusPanel, *chatstatusPanel; 70 static PANEL *mainstatusPanel, *chatstatusPanel;
71 static PANEL *logPanel; 71 static PANEL *logPanel;
72 static int maxY, maxX; 72 static int maxY, maxX;
73 static winbuf *statusWindow; 73 static winbuf *statusWindow;
74 static winbuf *currentWindow; 74 static winbuf *currentWindow;
75 static GList *statushbuf;
75 76
76 static int roster_hidden; 77 static int roster_hidden;
77 static int chatmode; 78 static int chatmode;
78 static int multimode; 79 static int multimode;
79 static char *multiline, *multimode_subj; 80 static char *multiline, *multimode_subj;
353 vsnprintf(b2, 5120, fmt, ap); 354 vsnprintf(b2, 5120, fmt, ap);
354 va_end(ap); 355 va_end(ap);
355 356
356 if (flag & LPRINT_NORMAL) { 357 if (flag & LPRINT_NORMAL) {
357 char *buffer_locale; 358 char *buffer_locale;
359 char *buf_specialwindow;
360
361 // Convert buffer to current locale for wprintw()
358 if (!(flag & LPRINT_NOTUTF8)) 362 if (!(flag & LPRINT_NOTUTF8))
359 buffer_locale = from_utf8(buffer); 363 buffer_locale = from_utf8(buffer);
360 else 364 else
361 buffer_locale = buffer; 365 buffer_locale = buffer;
366
367 // For the special status buffer, we need utf-8, but without the timestamp
368 if (flag & LPRINT_NOTUTF8)
369 buf_specialwindow = to_utf8(b2);
370 else
371 buf_specialwindow = b2;
372
362 if (Curses) { 373 if (Curses) {
363 char *buf_specialwindow;
364 wprintw(logWnd, "\n%s", buffer_locale); 374 wprintw(logWnd, "\n%s", buffer_locale);
365 update_panels(); 375 update_panels();
366 doupdate(); 376 doupdate();
367 if (flag & LPRINT_NOTUTF8)
368 buf_specialwindow = to_utf8(b2);
369 else
370 buf_specialwindow = b2;
371 scr_WriteInWindow(NULL, buf_specialwindow, timestamp, 377 scr_WriteInWindow(NULL, buf_specialwindow, timestamp,
372 HBB_PREFIX_SPECIAL, FALSE); 378 HBB_PREFIX_SPECIAL, FALSE);
373 if (buf_specialwindow != b2)
374 g_free(buf_specialwindow);
375 } else { 379 } else {
376 printf("%s\n", buffer_locale); 380 printf("%s\n", buffer_locale);
377 } 381 // ncurses are not initialized yet, so we call directly hbuf routine
382 hbuf_add_line(&statushbuf, buf_specialwindow, timestamp,
383 HBB_PREFIX_SPECIAL, 0);
384 }
385
386 if (buf_specialwindow != b2)
387 g_free(buf_specialwindow);
378 if (!(flag & LPRINT_NOTUTF8)) 388 if (!(flag & LPRINT_NOTUTF8))
379 g_free(buffer_locale); 389 g_free(buffer_locale);
380 } 390 }
381 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) { 391 if (flag & (LPRINT_LOG|LPRINT_DEBUG)) {
382 char *buffer2 = g_new(char, 5184); 392 char *buffer2 = g_new(char, 5184);
568 578
569 if (!win_entry) { 579 if (!win_entry) {
570 if (special) { 580 if (special) {
571 if (!statusWindow) { 581 if (!statusWindow) {
572 statusWindow = scr_CreateBuddyPanel(NULL, FALSE); 582 statusWindow = scr_CreateBuddyPanel(NULL, FALSE);
573 // We could set statusWindow->name here... 583 statusWindow->hbuf = statushbuf;
584 statusWindow->name = g_strdup(winId);
574 } 585 }
575 win_entry = statusWindow; 586 win_entry = statusWindow;
576 } else { 587 } else {
577 win_entry = scr_CreateBuddyPanel(winId, FALSE); 588 win_entry = scr_CreateBuddyPanel(winId, FALSE);
578 } 589 }
648 // If the window entry doesn't exist yet, let's create it. 659 // If the window entry doesn't exist yet, let's create it.
649 if (!win_entry) { 660 if (!win_entry) {
650 if (special) { 661 if (special) {
651 if (!statusWindow) { 662 if (!statusWindow) {
652 statusWindow = scr_CreateBuddyPanel(NULL, dont_show); 663 statusWindow = scr_CreateBuddyPanel(NULL, dont_show);
653 // We could set statusWindow->name here... 664 statusWindow->hbuf = statushbuf;
665 //statusWindow->name = g_strdup(winId); // (winId NULL)
654 } 666 }
655 win_entry = statusWindow; 667 win_entry = statusWindow;
656 } else { 668 } else {
657 win_entry = scr_CreateBuddyPanel(winId, dont_show); 669 win_entry = scr_CreateBuddyPanel(winId, dont_show);
658 } 670 }
819 inputPanel = new_panel(inputWnd); 831 inputPanel = new_panel(inputWnd);
820 832
821 // Build the buddylist at least once, to make sure the special buffer 833 // Build the buddylist at least once, to make sure the special buffer
822 // is added 834 // is added
823 buddylist_build(); 835 buddylist_build();
836 // Wrap existing status buffer lines
837 hbuf_rebuild(&statushbuf, maxX - Roster_Width - PREFIX_WIDTH);
824 838
825 if (utf8_mode) 839 if (utf8_mode)
826 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!"); 840 scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!");
827 } else { 841 } else {
828 // Update panels 842 // Update panels