projects
/
selector.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added the short help for -w.
[selector.git]
/
selector.cc
diff --git
a/selector.cc
b/selector.cc
index
a6d3d7e
..
cd60eea
100644
(file)
--- a/
selector.cc
+++ b/
selector.cc
@@
-23,7
+23,7
@@
*/
// To use it as a super-history-search for bash:
*/
// 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>
#include <fstream>
#include <iostream>
@@
-51,7
+51,8
@@
char label_separator = '\0';
int output_to_vt_buffer = 0;
int add_control_qs = 0;
int with_colors = 1;
int output_to_vt_buffer = 0;
int add_control_qs = 0;
int with_colors = 1;
-int zsh_history = 0, bash_history = 0;
+int zsh_history = 0;
+int bash_history = 0;
int inverse_order = 0;
int remove_duplicates = 0;
int use_regexp = 0;
int inverse_order = 0;
int remove_duplicates = 0;
int use_regexp = 0;
@@
-73,7
+74,7
@@
void inject_into_tty_buffer(char *string) {
const char control_q = '\021';
// Put the selected string in the tty input buffer
for(const char *k = string; *k; k++) {
const char control_q = '\021';
// Put the selected string in the tty input buffer
for(const char *k = string; *k; k++) {
- if(add_control_qs) {
+ if(add_control_qs
&& !(*k >= ' ' && *k <= '~')
) {
// Add ^Q to quote control characters
ioctl(STDIN_FILENO, TIOCSTI, &control_q);
}
// Add ^Q to quote control characters
ioctl(STDIN_FILENO, TIOCSTI, &control_q);
}
@@
-349,7
+350,6
@@
void update_screen(int *current_line, int *temporary_line, int motion,
int nb_printed_lines = 0;
int nb_printed_lines = 0;
- clear();
use_default_colors();
addstr("\n");
use_default_colors();
addstr("\n");
@@
-445,6
+445,8
@@
void update_screen(int *current_line, int *temporary_line, int motion,
buffer[k++] = '\n';
buffer[k++] = '\0';
buffer[k++] = '\n';
buffer[k++] = '\0';
+ clrtoeol();
+
// Highlight the highlighted line ...
if(l == new_line) {
// Highlight the highlighted line ...
if(l == new_line) {
@@
-479,6
+481,8
@@
void update_screen(int *current_line, int *temporary_line, int motion,
addnstr("[empty choice]\n", console_width);
}
addnstr("[empty choice]\n", console_width);
}
+ clrtobot();
+
// Draw the modeline
move(0, 0);
// Draw the modeline
move(0, 0);
@@
-773,6
+777,7
@@
int main(int argc, char **argv) {
<< endl
<< " -h show this help" << endl
<< " -v inject the selected line in the tty" << endl
<< endl
<< " -h show this help" << endl
<< " -v inject the selected line in the tty" << endl
+ << " -w quotes control characters with ^Qs" << endl
<< " -d remove duplicated lines" << endl
<< " -b remove the bash history line prefix" << endl
<< " -z remove the zsh history line prefix" << endl
<< " -d remove duplicated lines" << endl
<< " -b remove the bash history line prefix" << endl
<< " -z remove the zsh history line prefix" << endl
@@
-996,6
+1001,11
@@
int main(int argc, char **argv) {
kill_after_cursor(pattern, &cursor_position);
}
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);
update_screen(¤t_line, &temporary_line, motion,
nb_lines, labels, cursor_position, pattern);