X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=inline;f=selector.cc;h=f1e60c01ceb0e07c3169193a3be45f8f589894b8;hb=08270e13387994e72b20e123fed9e8b913fc6a0c;hp=8616f1ceff005c5ea27e026afa65852f38cc1159;hpb=b8f22b5a434a67c2e64b831b0ef9236ec32e611a;p=selector.git
diff --git a/selector.cc b/selector.cc
index 8616f1c..f1e60c0 100644
--- a/selector.cc
+++ b/selector.cc
@@ -49,7 +49,37 @@ int buffer_size = 1024;
int nb_lines_max = 10000;
char pattern_separator = ';';
int output_to_vt_buffer = 0;
-int with_colors = 0;
+int with_colors = 1;
+
+//////////////////////////////////////////////////////////////////////
+
+// This looks severly Linux-only ...
+
+void inject_into_tty_buffer(char *line) {
+ char *tty = ttyname(STDIN_FILENO);
+ int fd = open(tty, O_WRONLY);
+
+ struct termios oldtio, newtio;
+
+ if (fd >= 0) {
+ // Save current port settings
+ tcgetattr(fd,&oldtio);
+ memset(&newtio, 0, sizeof(newtio));
+ // Set input mode (non-canonical, *no echo*,...)
+ tcflush(fd, TCIFLUSH);
+ tcsetattr(fd,TCSANOW, &newtio);
+ // Put the selected line in the tty input buffer
+ for(char *k = line; *k; k++) {
+ ioctl(fd, TIOCSTI, k);
+ }
+ // Restore the old settings
+ tcsetattr(fd,TCSANOW, &oldtio);
+ close(fd);
+ } else {
+ cerr << "Can not open " << tty << "." << endl;
+ exit(1);
+ }
+}
//////////////////////////////////////////////////////////////////////
@@ -304,7 +334,13 @@ int main(int argc, char **argv) {
char buffer[buffer_size];
char *lines[nb_lines_max];
int no_blink = 0;
- int theme = 0;
+
+ int color_fg_modeline = COLOR_WHITE;
+ int color_bg_modeline = COLOR_BLACK;
+ int color_fg_highlight = COLOR_BLACK;
+ int color_bg_highlight = COLOR_YELLOW;
+
+ setlocale(LC_ALL, "");
char input_filename[buffer_size], output_filename[buffer_size];
strcpy(input_filename, "");
@@ -329,6 +365,11 @@ int main(int argc, char **argv) {
i++;
}
+ else if(strcmp(argv[i], "-m") == 0) {
+ with_colors = 0;
+ i++;
+ }
+
else if(strcmp(argv[i], "-f") == 0) {
check_opt(argc, argv, i, 1, "");
strncpy(input_filename, argv[i+1], buffer_size);
@@ -347,9 +388,12 @@ int main(int argc, char **argv) {
}
else if(strcmp(argv[i], "-t") == 0) {
- check_opt(argc, argv, i, 1, "");
- theme = atoi(argv[i+1]);
- i += 2;
+ check_opt(argc, argv, i, 4, " ");
+ color_fg_modeline = atoi(argv[i+1]);
+ color_bg_modeline = atoi(argv[i+2]);
+ color_fg_highlight = atoi(argv[i+3]);
+ color_bg_highlight = atoi(argv[i+4]);
+ i += 5;
}
else {
@@ -361,7 +405,8 @@ int main(int argc, char **argv) {
<< " [-h]"
<< " [-b]"
<< " [-v]"
- << " [-t ]"
+ << " [-m]"
+ << " [-t ]"
<< " [-o