X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=a22329c6e00fcdf4f91a4ea1005f939ed2f4306f;hb=7320103ce09081bd91399522a4eb003c58289679;hp=cd60eea2c9d22ae413ffcac66411def6edc7fcd4;hpb=45fd07db2a2574d9d1e24a842ea0dc546fd27776;p=selector.git diff --git a/selector.cc b/selector.cc index cd60eea..a22329c 100644 --- a/selector.cc +++ b/selector.cc @@ -62,6 +62,9 @@ int error_flash = 0; #define COLOR_MODELINE 1 #define COLOR_HIGHLIGHTED_LINE 2 +#define COLOR_ERROR 3 + +int attr_modeline, attr_highlighted_line, attr_error; ////////////////////////////////////////////////////////////////////// @@ -354,7 +357,9 @@ void update_screen(int *current_line, int *temporary_line, int motion, addstr("\n"); if(matcher.regexp_error) { - addstr("[regexp error]"); + attron(attr_error); + addnstr("[regexp error]", console_width); + attroff(attr_error); } else if(nb_lines > 0) { int new_line; if(match(lines[*current_line], &matcher)) { @@ -450,15 +455,9 @@ void update_screen(int *current_line, int *temporary_line, int motion, // Highlight the highlighted line ... if(l == new_line) { - if(with_colors) { - attron(COLOR_PAIR(COLOR_HIGHLIGHTED_LINE)); - addnstr(buffer, console_width); - attroff(COLOR_PAIR(COLOR_HIGHLIGHTED_LINE)); - } else { - attron(A_STANDOUT); - addnstr(buffer, console_width); - attroff(A_STANDOUT); - } + attron(attr_highlighted_line); + addnstr(buffer, console_width); + attroff(attr_highlighted_line); } else { addnstr(buffer, console_width); } @@ -475,10 +474,14 @@ 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); + attron(attr_error); + addnstr("[no selection]", console_width); + attroff(attr_error); } } else { - addnstr("[empty choice]\n", console_width); + attron(attr_error); + addnstr("[empty choice]", console_width); + attroff(attr_error); } clrtobot(); @@ -487,11 +490,7 @@ void update_screen(int *current_line, int *temporary_line, int motion, move(0, 0); - if(with_colors) { - attron(COLOR_PAIR(COLOR_MODELINE)); - } else { - attron(A_REVERSE); - } + attron(attr_modeline); for(int k = 0; k < console_width; k++) buffer[k] = ' '; buffer[console_width] = '\0'; @@ -540,11 +539,7 @@ void update_screen(int *current_line, int *temporary_line, int motion, move(0, cursor_x); - if(with_colors) { - attroff(COLOR_PAIR(COLOR_MODELINE)); - } else { - attroff(A_REVERSE); - } + attroff(attr_modeline); // We are done @@ -777,7 +772,7 @@ int main(int argc, char **argv) { << endl << " -h show this help" << endl << " -v inject the selected line in the tty" << endl - << " -w quotes control characters with ^Qs" << 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 @@ -786,7 +781,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