X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=a62d352c4ded91577cf44b53fa31176b53093c6a;hb=500ce91131229a35000fb770f79a50ed994dd804;hp=5480539459f29794e5d1e349872926a627459873;hpb=e5cac5f305479e8c1003117cc226d6dea9f9adde;p=selector.git diff --git a/selector.cc b/selector.cc index 5480539..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(); @@ -777,6 +790,7 @@ int main(int argc, char **argv) { << endl << " -h show this help" << endl << " -v inject the selected line in the tty" << endl + << " -w quote control characters with ^Qs when using -v" << endl << " -d remove duplicated lines" << endl << " -b remove the bash history line prefix" << endl << " -z remove the zsh history line prefix" << endl @@ -785,7 +799,7 @@ int main(int argc, char **argv) { << " -a case sensitive" << endl << " -m monochrome mode" << endl << " -q make a flash instead of a beep on an edition error" << endl - << " -- rest of the arguments are filenames" << endl + << " -- all following arguments are filenames" << endl << " -t " << endl << " add a title in the modeline" << endl << " -c <fg modeline> <bg modeline> <fg highlight> <bg highlight>" << endl @@ -905,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;