X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui.c;h=5b44819c05afc074fadca3a5a7d5c1ece9fe8b8f;hp=e734b10c8e9e57438075a14a2cc1941f0c28a7b1;hb=1e012cf40238883621692051a22fb9c7cad5e944;hpb=01117585025befdce6edd8c67b3fad295d171623 diff --git a/gui.c b/gui.c index e734b10c..5b44819c 100644 --- a/gui.c +++ b/gui.c @@ -6,14 +6,16 @@ /** \file gui.c Curses-based interface for paraslash. */ +#include #include #include #include +#include + #include "gui.cmdline.h" #include "para.h" #include "gui.h" #include "string.h" -#include #include "ringbuffer.h" #include "fd.h" #include "error.h" @@ -43,7 +45,7 @@ struct rb_entry { size_t len; int color; }; -struct ringbuffer *bot_win_rb; +static struct ringbuffer *bot_win_rb; #define NUM_LINES(len) (1 + (len) / bot.cols) static unsigned scroll_position; @@ -89,8 +91,8 @@ struct stat_item { static struct gui_theme theme; -int _argc; -char **_argv; +static int _argc; +static char **_argv; static void com_help(void); static void com_reread_conf(void); @@ -108,7 +110,7 @@ static void com_scroll_down(void); static void com_page_up(void); static void com_page_down(void); -struct gui_command command_list[] = { +static struct gui_command command_list[] = { { .key = "?", .name = "help", @@ -307,7 +309,7 @@ static int align_str(WINDOW* win, char *str, unsigned int len, num = 0; } /* replace newlines by spaces */ - for (i = 0; i < len; i++) { + for (i = 0; i < len && str[i]; i++) { if (str[i] == '\n') str[i] = ' '; } @@ -677,8 +679,31 @@ static void print_stat_item(int i) static int update_item(int item_num, char *buf) { - free(stat_content[item_num]); - stat_content[item_num] = para_strdup(buf); + char **c = stat_content + item_num; + + free(*c); + if (buf && buf[0]) + goto dup; + switch (item_num) { + case SI_ARTIST: + *c = para_strdup("(artist tag not set)"); + goto print; + case SI_TITLE: + *c = para_strdup("(title tag not set)"); + goto print; + case SI_YEAR: + *c = para_strdup("????"); + goto print; + case SI_ALBUM: + *c = para_strdup("(album tag not set)"); + goto print; + case SI_COMMENT: + *c = para_strdup("(comment tag not set)"); + goto print; + } +dup: + *c = para_strdup(buf); +print: print_stat_item(item_num); return 1; }