From 2a22ec9266abcb83b7ed7a282486d63bb6b7d7a2 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 20 Apr 2012 01:14:07 +0100 Subject: [PATCH] Store current title for titlebar --- title_bar.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/title_bar.c b/title_bar.c index ee6aa575..f6db121e 100644 --- a/title_bar.c +++ b/title_bar.c @@ -20,10 +20,13 @@ * */ +#include +#include #include #include "windows.h" static WINDOW *title_bar; +static char *current_title = NULL; static int dirty; void create_title_bar(void) @@ -91,11 +94,16 @@ void title_bar_refresh(void) void title_bar_show(const char * const title) { + if (current_title != NULL) + free(current_title); + + current_title = (char *) malloc((strlen(title) + 1) * sizeof(char)); + strcpy(current_title, title); wmove(title_bar, 0, 0); int i; for (i = 0; i < 45; i++) waddch(title_bar, ' '); - mvwprintw(title_bar, 0, 0, " %s", title); + mvwprintw(title_bar, 0, 0, " %s", current_title); dirty = TRUE; }