X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=selector.cc;h=51333b45e7e064fde21cde9b9a006ea4ebde082c;hb=69c82940856baeaeeb3d7fc73e0ea1e193773758;hp=cfb583e1fb5b408e502032b47227e11bb3feb89c;hpb=951d423cb3aa421a271c287d45702fb0072d4681;p=selector.git diff --git a/selector.cc b/selector.cc index cfb583e..51333b4 100644 --- a/selector.cc +++ b/selector.cc @@ -390,11 +390,11 @@ void update_screen(int *current_line, int *temporary_line, int motion, int main(int argc, char **argv) { if(!ttyname(STDIN_FILENO)) { - cerr << "Error: the standard input is not a tty." << endl; + cerr << "The standard input is not a tty." << endl; exit(1); } - char buffer[buffer_size]; + char buffer[buffer_size], raw_line[buffer_size];; int color_fg_modeline, color_bg_modeline; int color_fg_highlight, color_bg_highlight; @@ -500,20 +500,24 @@ int main(int argc, char **argv) { << "Written by Francois Fleuret ." << endl << endl - << argv[0] - << " [-h]" - << " [-v]" - << " [-m]" - << " [-d]" - << " [-e]" - << " [-b]" - << " [-z]" - << " [-i]" - << " [-c ]" - << " [-o ]" - << " [-s ]" - << " [-l ]" - << " -f " + << "Usage: " << argv[0] << " [options] -f " << endl + << endl + << " -h show this help" << endl + << " -v inject the selection in the tty" << endl + << " -m monochrome mode" << endl + << " -d remove duplicated lines" << endl + << " -e regexp mode when starting" << endl + << " -b remove the bash history line prefix" << endl + << " -z remove the zsh history line prefix" << endl + << " -i invert the line order" << endl + << " -c " << endl + << " set the display colors" << endl + << " -o " << endl + << " set a file to write the selected line to" << endl + << " -s " << endl + << " set the symbol to separate substrings in the pattern" << endl + << " -l " << endl + << " set the maximum number of lines to take into account" << endl << endl; exit(error); @@ -543,9 +547,23 @@ int main(int argc, char **argv) { } while(nb_lines < nb_lines_max && !file.eof()) { - file.getline(buffer, buffer_size); - if(strcmp(buffer, "") != 0) { - char *s = buffer; + + file.getline(raw_line, buffer_size); + + if(strcmp(raw_line, "") != 0) { + + char *s, *t; + const char *u; + + s = buffer; + t = raw_line; + while(*t) { + u = unctrl(*t++); + while(*u) { *s++ = *u++; } + } + *s = '\0'; + + s = buffer; if(zsh_history && *s == ':') { while(*s && *s != ';') s++;