From 3d9df3244a04aaf5c0c216f2e475f5355cf9721b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 6 Jan 2014 02:45:28 +0000 Subject: [PATCH] gui: Use whline() for drawing the separator. This should be slightly more efficient. This patch also changes the type of struct gui_theme->sep_str from const char * to plain char and renames the field to sep_char. It must be a single-character string anyway. For the colorful blackness theme we now use the default character from curses.h rather than '-'. This looks nicer. Tested with ncurses on Linux and the curses implementation that ships with NetBSD. --- gui.c | 5 +---- gui.h | 2 +- gui_theme.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/gui.c b/gui.c index 284de0cb..a6bc54a7 100644 --- a/gui.c +++ b/gui.c @@ -593,8 +593,6 @@ __noreturn __printf_2_3 static void msg_n_exit(int ret, const char* fmt, ...) */ static void init_wins(int top_lines) { - int i; - top.lines = top_lines; top.cols = COLS; top.begy = 0; @@ -663,8 +661,7 @@ static void init_wins(int top_lines) keypad(in.win, 1); } wmove(sep.win, 0, 0); - for (i = 1; i <= COLS; i++) - waddstr(sep.win, theme.sep_str); + whline(sep.win, theme.sep_char, COLS); wclear(top.win); //wclear(bot.win); wnoutrefresh(top.win); diff --git a/gui.h b/gui.h index 6f7349bb..e6e4167f 100644 --- a/gui.h +++ b/gui.h @@ -21,7 +21,7 @@ struct gui_theme { int msg_fg, msg_bg; int err_msg_fg, err_msg_bg; int sep_fg, sep_bg; - const char *sep_str; + char sep_char; int default_fg, default_bg; int top_lines_default, top_lines_min; diff --git a/gui_theme.c b/gui_theme.c index 279ad914..5d3fac1c 100644 --- a/gui_theme.c +++ b/gui_theme.c @@ -30,7 +30,7 @@ static void init_theme_simple(struct gui_theme *t) t->sep_fg = COLOR_CYAN; t->default_fg = COLOR_WHITE; t->default_bg = COLOR_BLUE; - t->sep_str = "*"; + t->sep_char = '*'; d[SI_BASENAME].prefix = ""; d[SI_BASENAME].postfix = ""; @@ -85,7 +85,7 @@ static void init_theme_colorful_blackness(struct gui_theme *t) t->err_msg_fg = COLOR_WHITE; t->sep_bg = COLOR_BLACK; /* color of the separator */ t->sep_fg = COLOR_BLUE; - t->sep_str = "-"; + t->sep_char = 0; /* default (ACS_HLINE) */ t->default_bg = COLOR_BLACK; t->default_fg = COLOR_MAGENTA; -- 2.39.5