for the integer valued arguments.
or matching the regexp.
The ^R key switches between the standard multi-substring mode and the
or matching the regexp.
The ^R key switches between the standard multi-substring mode and the
+regexp mode, and ^I between the case-sensitive and case-insensitive
+modes.
The main usage of selector is as an efficient search in the shell
command history. With the correct option, it will inject the selected
The main usage of selector is as an efficient search in the shell
command history. With the correct option, it will inject the selected
+int string_to_positive_integer(char *string) {
+ int error = 0;
+ int result = 0;
+
+ if(*string) {
+ for(char *s = string; *s; s++) {
+ if(*s >= '0' && *s <= '9') {
+ result = result * 10 + int(*s - '0');
+ } else error = 1;
+ }
+ } else error = 1;
+
+ if(error) {
+ cerr << "Value `" << string << "' is not a positive integer." << endl;
+ exit(1);
+ }
+
+ return result;
+}
+
//////////////////////////////////////////////////////////////////////
// A quick and dirty hash table
//////////////////////////////////////////////////////////////////////
// A quick and dirty hash table
+ if(case_sensitive) {
+ addstr(" [case]");
+ }
+
move(0, cursor_x);
if(with_colors) {
move(0, cursor_x);
if(with_colors) {
else if(strcmp(argv[i], "-l") == 0) {
check_opt(argc, argv, i, 1, "<maximum number of lines>");
else if(strcmp(argv[i], "-l") == 0) {
check_opt(argc, argv, i, 1, "<maximum number of lines>");
- nb_lines_max = atoi(argv[i+1]);
+ nb_lines_max = string_to_positive_integer(argv[i+1]);
i += 2;
}
else if(strcmp(argv[i], "-c") == 0) {
check_opt(argc, argv, i, 4, "<fg modeline> <bg modeline> <fg highlight> <bg highlight>");
i += 2;
}
else if(strcmp(argv[i], "-c") == 0) {
check_opt(argc, argv, i, 4, "<fg modeline> <bg modeline> <fg highlight> <bg highlight>");
- 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]);
+ color_fg_modeline = string_to_positive_integer(argv[i + 1]);
+ color_bg_modeline = string_to_positive_integer(argv[i + 2]);
+ color_fg_highlight = string_to_positive_integer(argv[i + 3]);
+ color_bg_highlight = string_to_positive_integer(argv[i + 4]);
use_regexp = !use_regexp;
}
use_regexp = !use_regexp;
}
+ else if(key == '\011') { // ^R
+ case_sensitive = !case_sensitive;
+ }
+
else if(key == '\025') { // ^U
kill_before_cursor(pattern, &cursor_position);
}
else if(key == '\025') { // ^U
kill_before_cursor(pattern, &cursor_position);
}
+ } else {
+ cout << "Aborted." << endl;
}
for(int l = 0; l < nb_lines; l++) {
}
for(int l = 0; l < nb_lines; l++) {