From: Francois Fleuret Date: Wed, 1 Apr 2009 17:11:32 +0000 (+0200) Subject: Added an option to put a title in the modeline. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=3ea52eb74365a5388c8b37c716e5281263a4ae85;p=selector.git Added an option to put a title in the modeline. --- diff --git a/selector.1 b/selector.1 index 8ecbc32..f4c7edf 100644 --- a/selector.1 +++ b/selector.1 @@ -48,6 +48,8 @@ remove duplicated lines start with the regexp mode activated .IP "\fB-a\fP" 10 make the matching case sensitive +.IP "\fB-t \fP" 10 +add a title in the modeline .IP "\fB-c <fg modeline> <bg modeline> <fg highlight> <bg highlight>\fP" 10 select the modeline and highlight color numbers .IP "\fB-v\fP" 10 diff --git a/selector.cc b/selector.cc index 0bb2d3f..71768e7 100644 --- a/selector.cc +++ b/selector.cc @@ -54,6 +54,7 @@ int inverse_order = 0; int remove_duplicates = 0; int use_regexp = 0; int case_sensitive = 0; +char *title = 0; ////////////////////////////////////////////////////////////////////// @@ -363,11 +364,20 @@ void update_screen(int *current_line, int *temporary_line, int motion, // Draw the modeline - sprintf(buffer, "%d/%d pattern: %s%s", - nb_printed_lines, - nb_lines, - pattern, - use_regexp ? " [regexp]" : ""); + if(title) { + sprintf(buffer, "%s %d/%d pattern: %s%s", + title, + nb_printed_lines, + nb_lines, + pattern, + use_regexp ? " [regexp]" : ""); + } else { + sprintf(buffer, "%d/%d pattern: %s%s", + nb_printed_lines, + nb_lines, + pattern, + use_regexp ? " [regexp]" : ""); + } for(int k = strlen(buffer); k < console_width; k++) buffer[k] = ' '; buffer[console_width] = '\0'; @@ -477,6 +487,14 @@ int main(int argc, char **argv) { i++; } + else if(strcmp(argv[i], "-t") == 0) { + check_opt(argc, argv, i, 1, "<title>"); + delete[] title; + title = new char[strlen(argv[i+1]) + 1]; + strcpy(title, argv[i+1]); + i += 2; + } + else if(strcmp(argv[i], "-l") == 0) { check_opt(argc, argv, i, 1, "<maximum number of lines>"); nb_lines_max = atoi(argv[i+1]); @@ -520,6 +538,8 @@ int main(int argc, char **argv) { << " -e start in regexp mode" << endl << " -a case sensitive" << endl << " -m monochrome mode" << endl + << " -t <title>" << endl + << " add a title in the modeline" << endl << " -c <fg modeline> <bg modeline> <fg highlight> <bg highlight>" << endl << " set the display colors" << endl << " -o <output filename>" << endl @@ -769,6 +789,7 @@ int main(int argc, char **argv) { } delete[] lines; + delete[] title; exit(0); }