X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=2dadb5df8b342a63d737c3021a92105eecb3820b;hb=c84d5d59dd658f46089a3877b0195f67e19d65cd;hp=918b7244de7ec9fe39b934211c8cf3c17afe13ed;hpb=98e35a0ee3998dd63fe0e8c08ef1bc9bace6c04d;p=selector.git diff --git a/selector.cc b/selector.cc index 918b724..2dadb5d 100644 --- a/selector.cc +++ b/selector.cc @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -331,16 +332,17 @@ int next_visible(int current_line, int nb_lines, char **lines, matcher_t *matche ////////////////////////////////////////////////////////////////////// // The value passed to this routine in current_focus_line is the index -// of the line to highlight if it matches the matcher. The line -// highlighted is the first one matching the matcher in that order: -// (1) current_focus_line after motion, (2) the first with a greater +// of the line we should have highlited if there was no motion and if +// it matched the matcher. So, the line actually highlighted is the +// first one matching the matcher in that order: (1) +// current_focus_line after motion, (2) the first with a greater // index, (3) the first with a lesser index. // The index of the line actually shown highlighted is written in // displayed_focus_line (it can be -1) // If there is a motion and a line is actually shown highlighted, its -// value is written in current_focus_line +// value is written in current_focus_line. void update_screen(int *current_focus_line, int *displayed_focus_line, int motion, @@ -356,8 +358,7 @@ void update_screen(int *current_focus_line, int *displayed_focus_line, int console_width = getmaxx(stdscr); int console_height = getmaxy(stdscr); - // First, we find a visible line. In priority: The current, or the - // first visible after it, or the first visible before it. + // First, we find a visible line. int nb_printed_lines = 0; @@ -790,7 +791,7 @@ int main(int argc, char **argv) { << " -z remove the zsh history line prefix" << endl << " -i invert the order of lines" << endl << " -e start in regexp mode" << endl - << " -a case sensitive" << endl + << " -a start in case sensitive mode" << endl << " -m monochrome mode" << endl << " -q make a flash instead of a beep on an edition error" << endl << " -- all following arguments are filenames" << endl @@ -889,8 +890,10 @@ int main(int argc, char **argv) { // Here we start to display with curse initscr(); - + cbreak(); noecho(); + // nonl(); + intrflush(stdscr, FALSE); // So that the arrow keys work keypad(stdscr, TRUE); @@ -1036,10 +1039,20 @@ int main(int argc, char **argv) { if((key == KEY_ENTER || key == '\n')) { - if(output_to_vt_buffer) { - if(displayed_focus_line >= 0 && displayed_focus_line < nb_lines) { - inject_into_tty_buffer(lines[displayed_focus_line]); + char *t; + + if(displayed_focus_line >= 0 && displayed_focus_line < nb_lines) { + t = lines[displayed_focus_line]; + if(label_separator) { + while(*t && *t != label_separator) t++; + if(*t) t++; } + } else { + t = 0; + } + + if(output_to_vt_buffer && t) { + inject_into_tty_buffer(t); } if(output_filename[0]) { @@ -1048,8 +1061,8 @@ int main(int argc, char **argv) { cerr << "Can not open " << output_filename << " for writing." << endl; exit(1); } else { - if(displayed_focus_line >= 0 && displayed_focus_line < nb_lines) { - out << lines[displayed_focus_line] << endl; + if(t) { + out << t << endl; } else { out << endl; }