*/
// To use it as a super-history-search for bash:
-// alias h='selector -d -i -b -v -f <(history)'
+// selector -q -b -i -d -v -w -l 10000 <(history)
#include <fstream>
#include <iostream>
memset(&newtio, 0, sizeof(newtio));
// Set input mode (non-canonical, *no echo*,...)
tcsetattr(STDIN_FILENO, TCSANOW, &newtio);
- char control_q = '\021';
+ const char control_q = '\021';
// Put the selected string in the tty input buffer
- for(char *k = string; *k; k++) {
- if(add_control_qs) {
+ for(const char *k = string; *k; k++) {
+ if(add_control_qs && !(*k >= ' ' && *k <= '~')) {
// Add ^Q to quote control characters
ioctl(STDIN_FILENO, TIOCSTI, &control_q);
}
int nb_printed_lines = 0;
- clear();
use_default_colors();
addstr("\n");
buffer[k++] = '\n';
buffer[k++] = '\0';
+ clrtoeol();
+
// Highlight the highlighted line ...
if(l == new_line) {
addnstr("[empty choice]\n", console_width);
}
+ clrtobot();
+
// Draw the modeline
move(0, 0);
char pattern[buffer_size];
pattern[0] = '\0';
+
int cursor_position;
cursor_position = 0;
int key;
int current_line = 0, temporary_line = 0;
- update_screen(¤t_line, &temporary_line, 0, nb_lines, labels, cursor_position, pattern);
+ update_screen(¤t_line, &temporary_line, 0,
+ nb_lines, labels, cursor_position, pattern);
do {
kill_after_cursor(pattern, &cursor_position);
}
+ else if(key == '\014') { // ^L
+ // I suspect that we may sometime mess up the display
+ clear();
+ }
+
update_screen(¤t_line, &temporary_line, motion,
nb_lines, labels, cursor_position, pattern);