# HG changeset patch # User Mikael Berthe # Date 1147124846 -7200 # Node ID da03534e46c704bb3f3d50bca02a938e18e5a030 # Parent d0781ca2dd08209d9d72608e14a33f39fb95dd28 Add startup log messages to the status buffer With this patch, status history buffer can be written to even before ncurses are initialized. diff -r d0781ca2dd08 -r da03534e46c7 mcabber/src/main.c --- a/mcabber/src/main.c Mon May 08 23:46:42 2006 +0200 +++ b/mcabber/src/main.c Mon May 08 23:47:26 2006 +0200 @@ -213,7 +213,9 @@ static void credits(void) { char *v = mcabber_version(); - printf("MCabber %s -- Email: mcabber [at] lilotux [dot] net\n", v); + const char *v_fmt = "MCabber %s -- Email: mcabber [at] lilotux [dot] net\n"; + printf(v_fmt, v); + scr_LogPrint(LPRINT_LOGNORM|LPRINT_NOTUTF8, v_fmt, v); g_free(v); } diff -r d0781ca2dd08 -r da03534e46c7 mcabber/src/screen.c --- a/mcabber/src/screen.c Mon May 08 23:46:42 2006 +0200 +++ b/mcabber/src/screen.c Mon May 08 23:47:26 2006 +0200 @@ -72,6 +72,7 @@ static int maxY, maxX; static winbuf *statusWindow; static winbuf *currentWindow; +static GList *statushbuf; static int roster_hidden; static int chatmode; @@ -355,26 +356,35 @@ if (flag & LPRINT_NORMAL) { char *buffer_locale; + char *buf_specialwindow; + + // Convert buffer to current locale for wprintw() if (!(flag & LPRINT_NOTUTF8)) buffer_locale = from_utf8(buffer); else buffer_locale = buffer; + + // For the special status buffer, we need utf-8, but without the timestamp + if (flag & LPRINT_NOTUTF8) + buf_specialwindow = to_utf8(b2); + else + buf_specialwindow = b2; + if (Curses) { - char *buf_specialwindow; wprintw(logWnd, "\n%s", buffer_locale); update_panels(); doupdate(); - if (flag & LPRINT_NOTUTF8) - buf_specialwindow = to_utf8(b2); - else - buf_specialwindow = b2; scr_WriteInWindow(NULL, buf_specialwindow, timestamp, HBB_PREFIX_SPECIAL, FALSE); - if (buf_specialwindow != b2) - g_free(buf_specialwindow); } else { printf("%s\n", buffer_locale); + // ncurses are not initialized yet, so we call directly hbuf routine + hbuf_add_line(&statushbuf, buf_specialwindow, timestamp, + HBB_PREFIX_SPECIAL, 0); } + + if (buf_specialwindow != b2) + g_free(buf_specialwindow); if (!(flag & LPRINT_NOTUTF8)) g_free(buffer_locale); } @@ -570,7 +580,8 @@ if (special) { if (!statusWindow) { statusWindow = scr_CreateBuddyPanel(NULL, FALSE); - // We could set statusWindow->name here... + statusWindow->hbuf = statushbuf; + statusWindow->name = g_strdup(winId); } win_entry = statusWindow; } else { @@ -650,7 +661,8 @@ if (special) { if (!statusWindow) { statusWindow = scr_CreateBuddyPanel(NULL, dont_show); - // We could set statusWindow->name here... + statusWindow->hbuf = statushbuf; + //statusWindow->name = g_strdup(winId); // (winId NULL) } win_entry = statusWindow; } else { @@ -821,6 +833,8 @@ // Build the buddylist at least once, to make sure the special buffer // is added buddylist_build(); + // Wrap existing status buffer lines + hbuf_rebuild(&statushbuf, maxX - Roster_Width - PREFIX_WIDTH); if (utf8_mode) scr_LogPrint(LPRINT_NORMAL, "WARNING: UTF-8 not yet supported!");