From: Francois Fleuret Date: Mon, 8 Jun 2009 07:28:32 +0000 (+0200) Subject: Errors messages are now in red. X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=selector.git;a=commitdiff_plain;h=500ce91131229a35000fb770f79a50ed994dd804 Errors messages are now in red. --- diff --git a/selector.cc b/selector.cc index 64f44c2..a62d352 100644 --- a/selector.cc +++ b/selector.cc @@ -62,6 +62,7 @@ int error_flash = 0; #define COLOR_MODELINE 1 #define COLOR_HIGHLIGHTED_LINE 2 +#define COLOR_ERROR 3 ////////////////////////////////////////////////////////////////////// @@ -124,6 +125,18 @@ void error_feedback() { } } +void print_error_message(const char *message, int width) { + if(with_colors) { + attron(COLOR_PAIR(COLOR_ERROR)); + addnstr(message, width); + attroff(COLOR_PAIR(COLOR_ERROR)); + } else { + attron(A_STANDOUT); + addnstr(message, width); + attroff(A_STANDOUT); + } +} + ////////////////////////////////////////////////////////////////////// // A quick and dirty hash table @@ -354,7 +367,7 @@ void update_screen(int *current_line, int *temporary_line, int motion, addstr("\n"); if(matcher.regexp_error) { - addstr("[regexp error]"); + print_error_message("[regexp error]", console_width); } else if(nb_lines > 0) { int new_line; if(match(lines[*current_line], &matcher)) { @@ -475,10 +488,10 @@ void update_screen(int *current_line, int *temporary_line, int motion, *temporary_line = new_line; if(nb_printed_lines == 0) { - addnstr("[no selection]\n", console_width); + print_error_message("[no selection]\n", console_width); } } else { - addnstr("[empty choice]\n", console_width); + print_error_message("[empty choice]\n", console_width); } clrtobot(); @@ -906,6 +919,7 @@ int main(int argc, char **argv) { init_pair(COLOR_MODELINE, color_fg_modeline, color_bg_modeline); init_pair(COLOR_HIGHLIGHTED_LINE, color_fg_highlight, color_bg_highlight); + init_pair(COLOR_ERROR, COLOR_WHITE, COLOR_RED); } else { with_colors = 0;