summaryrefslogtreecommitdiffstats
path: root/usage.c
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2019-10-03 00:12:27 +0200
committerpgen <p.gen.progs@gmail.com>2019-10-05 18:27:26 +0200
commit0f41afe27e8009efcd31597f8828df6ae9ac75e0 (patch)
tree01ad1997033027c1638d1f106d77fd7bc39a967b /usage.c
parent24037bdfe6aaf3ba6fa3453869466b6fd7b2579d (diff)
Add long options in the manual + work on contexts
Diffstat (limited to 'usage.c')
-rw-r--r--usage.c309
1 files changed, 226 insertions, 83 deletions
diff --git a/usage.c b/usage.c
index 3858c8d..adfe97f 100644
--- a/usage.c
+++ b/usage.c
@@ -9,66 +9,44 @@
#include "usage.h"
#include "ctxopt.h"
+static void
+common_help(void);
+
/* ====================== */
/* Usage display and exit */
/* ====================== */
-void
-main_usage(void)
+static void
+common_help(void)
{
- ctxopt_disp_usage(continue_after);
-
- printf("\n----------\n");
- printf("\nThis is a filter that gets words from stdin or from a file and ");
- printf("outputs\n");
- printf("the selected words (or nothing) on stdout in a nice selection ");
- printf("window\n\n");
- printf("The selection window appears on /dev/tty ");
- printf("just below the current line\n");
- printf("(no clear screen!).\n\n");
- printf("The following options are available:\n\n");
printf("-h|-help\n");
printf(" displays this help.\n");
- printf("-f|-cfg|-config_file\n");
- printf(" selects an alternative configuration file.\n");
- printf("-n|-lines|-height\n");
- printf(" sets the number of lines in the selection window.\n");
- printf("-t|-tab_mode|-tabulate_mode\n");
- printf(" tabulates the items. The number of columns can be limited with\n");
- printf(" an optional number.\n");
- printf("-k|-ks|-keep_spaces\n");
- printf(" does not trim spaces surrounding the output string if any.\n");
- printf("-v|-vb|-visual_bell\n");
- printf(" makes the bell visual (fuzzy search with error).\n");
- printf("-s|-sp|-start|-start_pattern\n");
- printf(" sets the initial cursor position (read the manual for "
- "more details).\n");
- printf("-m|-msg|-message|-title\n");
- printf(" displays a one-line message above the window.\n");
- printf("-w|-wt|-wide_tab_mode\n");
- printf(" uses all the terminal width for the columns if their numbers "
- "is given.\n");
- printf("-d|-delete_window|-clean_window\n");
- printf(" deletes the selection window on exit.\n");
- printf("-M|-middle|-center\n");
- printf(" centers the display if possible.\n");
- printf("-c|-col|-col_mode|-column\n");
- printf(" is like|-t without argument but respects end of lines.\n");
- printf("-l|-line|-line_mode\n");
- printf(" is like|-c without column alignments.\n");
- printf("-r|-auto_validate\n");
- printf(" enables ENTER to validate the selection even in search mode.\n");
- printf("-b|-blank\n");
- printf(" displays non printable characters as space.\n");
- printf("-a|-attributes\n");
- printf(" sets the attributes for the various displayed elements.\n");
+ printf("-u|-usage\n");
+ printf(" displays the synopsis of the current context.\n");
printf("-i|-include\n");
printf(" sets the regex input filter to match the selectable words.\n");
printf("-e|-exclude\n");
printf(" sets the regex input filter to match the non-selectable words.\n");
- printf("-C|-cs|-col_select\n");
- printf(" sets columns restrictions for selections.\n");
- printf("-R|-rs|-row_select\n");
- printf(" sets rows restrictions for selections.\n");
+ printf("-m|-msg|-message|-title\n");
+ printf(" displays a one-line message above the window.\n");
+ printf("-a|-attributes\n");
+ printf(" sets the attributes for the various displayed elements.\n");
+ printf("-1|-l1|-level1,-2|-l2|-level2,...,-5|-l5|-level5\n");
+ printf(" gives specific colors to up to 5 classes of "
+ "selectable words.\n");
+ printf("-n|-lines|-height\n");
+ printf(" sets the number of lines in the selection window.\n");
+ printf("-b|-blank\n");
+ printf(" displays non printable characters as space.\n");
+ printf("-M|-middle|-center\n");
+ printf(" centers the display if possible.\n");
+ printf("-k|-ks|-keep_spaces\n");
+ printf(" does not trim spaces surrounding the output string if any.\n");
+ printf("-W|-ws|-wd|-word_delimiters|-word_separators\n");
+ printf(" sets the input words separators.\n");
+ printf("-L|-ls|-ld|-line-delimiters|-line_separators\n");
+ printf(" sets the input lines separators.\n");
+ printf("-q|-no_bar|-no-scroll_bar\n");
+ printf(" prevents the display of the scroll bar.\n");
printf("-S|-subst\n");
printf(" sets the post-processing action to apply to all words.\n");
printf("-I|-si|-subst_included\n");
@@ -77,12 +55,44 @@ main_usage(void)
printf("-E|-se|-subst_excluded\n");
printf(" sets the post-processing action to apply to non-selectable "
"words only.\n");
- printf("-A|-fc|-first_column\n");
- printf(" forces a class of words to be the first of the line they "
- "appear in.\n");
- printf("-Z|-lc|-last_column\n");
- printf(" forces a class of words to be the latest of the line they "
- "appear in.\n");
+ printf("-/|-search_method\n");
+ printf(" changes the affectation of the / key (default fuzzy search).\n");
+ printf("-s|-sp|-start|-start_pattern\n");
+ printf(" sets the initial cursor position (read the manual for "
+ "more details).\n");
+ printf("-x|-timeout/-X|-hidden_timeout\n");
+ printf(" sets a timeout and specifies what to do when it expires.\n");
+ printf("-r|-auto_validate\n");
+ printf(" enables ENTER to validate the selection even in search mode.\n");
+ printf("-v|-vb|-visual_bell\n");
+ printf(" makes the bell visual (fuzzy search with error).\n");
+}
+
+void
+main_help(void)
+{
+ ctxopt_ctx_disp_usage("Main", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("\nThis is a filter that gets words from stdin or from a file and ");
+ printf("outputs\n");
+ printf("the selected words (or nothing) on stdout in a nice selection ");
+ printf("window\n\n");
+ printf("The selection window appears on /dev/tty ");
+ printf("just below the current line\n");
+ printf("(no clear screen!).\n\n");
+
+ printf("Short description of allowed parameters:\n\n");
+ common_help();
+
+ printf("-V|-version\n");
+ printf(" displays the current version and quits.\n");
+ printf("-H|-long_help\n");
+ printf(" displays a full help and the options available in all contexts.\n");
+ printf("-f|-cfg|-config_file\n");
+ printf(" selects an alternative configuration file.\n");
printf("-N|-number/-U|-unnumber\n");
printf(" numbers/un-numbers and provides a direct access to words "
"matching\n");
@@ -90,33 +100,20 @@ main_usage(void)
printf("-F|-en|-embedded_number\n");
printf(" numbers and provides a direct access to words by extracting the "
"number\n");
- printf(" from the words.\n");
- printf("-1|-l1|-level1,-2|-l2|-level2,...,-5|-l5|-level5\n");
- printf(" gives specific colors to up to 5 classes of "
- "selectable words.\n");
- printf("-g|-gutter\n");
- printf(" separates columns with a character in column or tabulate "
- "mode.\n");
- printf("-q|-no_bar|-no-scroll_bar\n");
- printf(" prevents the display of the scroll bar.\n");
- printf("-W|-ws|-wd|-word_delimiters|-word_separators\n");
- printf(" sets the input words separators.\n");
- printf("-L|-ls|-ld|-line-delimiters|-line_separators\n");
- printf(" sets the input lines separators.\n");
+ printf("-c|-col|-col_mode|-column\n");
+ printf(" is like|-t without argument but respects end of lines.\n");
+ printf("-l|-line|-line_mode\n");
+ printf(" is like|-c without column alignments.\n");
+ printf("-t|-tab_mode|-tabulate_mode\n");
+ printf(" tabulates the items. The number of columns can be limited with\n");
+ printf(" an optional number.\n");
printf("-T|-tm|-tag_mode/-P|-pm|-pin_mode\n");
printf(" enables the tagging (multi-selections) mode. ");
printf("An optional parameter\n");
printf(" sets the separator string between the selected words ");
printf("on the output.\n");
printf(" A single space is the default separator.\n");
- printf("-p|-at|-auto_tag\n");
- printf(" activates the auto-tagging when using -T or -P.\n");
- printf("-V|-version\n");
- printf(" displays the current version and quits.\n");
- printf("-x|-timeout/-X|-hidden_timeout\n");
- printf(" sets a timeout and specifies what to do when it expires.\n");
- printf("-/|-search_method\n");
- printf(" changes the affectation of the / key (default fuzzy search).\n");
+
printf("\nNavigation keys are:\n");
printf(" - Left/Down/Up/Right arrows or h/j/k/l, H/J/K/L.\n");
printf(" - Home/End, SHIFT|CTRL+Home/End CTRK+J/CTRL+K.\n");
@@ -151,17 +148,163 @@ main_usage(void)
}
void
-da_ctx_usage(void)
+columns_help(void)
{
- ctxopt_disp_usage(continue_after);
+ ctxopt_ctx_disp_usage("Columns", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("Short description of allowed parameters:\n\n");
+ common_help();
+
+ printf("-C|-cs|-col_select\n");
+ printf(" sets columns restrictions for selections.\n");
+ printf("-R|-rs|-row_select\n");
+ printf(" sets rows restrictions for selections.\n");
+ printf("-g|-gutter\n");
+ printf(" separates columns with a character in column or tabulate "
+ "mode.\n");
+ printf("-N|-number/-U|-unnumber\n");
+ printf(" numbers/un-numbers and provides a direct access to words "
+ "matching\n");
+ printf(" (or not) a specific regex.\n");
+ printf("-F|-en|-embedded_number\n");
+ printf(" numbers and provides a direct access to words by extracting the "
+ "number\n");
+ printf("-T|-tm|-tag_mode/-P|-pm|-pin_mode\n");
+ printf(" enables the tagging (multi-selections) mode. ");
+ printf("An optional parameter\n");
+ printf(" sets the separator string between the selected words ");
+ printf("on the output.\n");
+ printf(" A single space is the default separator.\n");
+ printf("-A|-fc|-first_column\n");
+ printf(" forces a class of words to be the first of the line they "
+ "appear in.\n");
+ printf("-Z|-lc|-last_column\n");
+ printf(" forces a class of words to be the latest of the line they "
+ "appear in.\n");
+ printf(" from the words.\n");
+}
+
+void
+lines_help(void)
+{
+ ctxopt_ctx_disp_usage("Lines", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("Short description of allowed parameters:\n\n");
+ common_help();
+
+ printf("-R|-rs|-row_select\n");
+ printf(" sets rows restrictions for selections.\n");
+ printf("-N|-number/-U|-unnumber\n");
+ printf(" numbers/un-numbers and provides a direct access to words "
+ "matching\n");
+ printf(" (or not) a specific regex.\n");
+ printf("-F|-en|-embedded_number\n");
+ printf(" numbers and provides a direct access to words by extracting the "
+ "number\n");
+ printf("-T|-tm|-tag_mode/-P|-pm|-pin_mode\n");
+ printf(" enables the tagging (multi-selections) mode. ");
+ printf("An optional parameter\n");
+ printf(" sets the separator string between the selected words ");
+ printf("on the output.\n");
+ printf(" A single space is the default separator.\n");
+ printf("-A|-fc|-first_column\n");
+ printf(" forces a class of words to be the first of the line they "
+ "appear in.\n");
+ printf("-Z|-lc|-last_column\n");
+ printf(" forces a class of words to be the latest of the line they "
+ "appear in.\n");
+ printf(" from the words.\n");
+}
+
+void
+tabulations_help(void)
+{
+ ctxopt_ctx_disp_usage("Tabulations", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("Short description of allowed parameters:\n\n");
+ common_help();
+
+ printf("-w|-wt|-wide_tab_mode\n");
+ printf(" uses all the terminal width for the columns if their numbers "
+ "is given.\n");
+ printf("-g|-gutter\n");
+ printf(" separates columns with a character in column or tabulate "
+ "mode.\n");
+ printf("-N|-number/-U|-unnumber\n");
+ printf(" numbers/un-numbers and provides a direct access to words "
+ "matching\n");
+ printf(" (or not) a specific regex.\n");
+ printf("-F|-en|-embedded_number\n");
+ printf(" numbers and provides a direct access to words by extracting the "
+ "number\n");
+ printf("-T|-tm|-tag_mode/-P|-pm|-pin_mode\n");
+ printf(" enables the tagging (multi-selections) mode. ");
+ printf("An optional parameter\n");
+ printf(" sets the separator string between the selected words ");
+ printf("on the output.\n");
+ printf(" A single space is the default separator.\n");
+ printf("-A|-fc|-first_column\n");
+ printf(" forces a class of words to be the first of the line they "
+ "appear in.\n");
+ printf("-Z|-lc|-last_column\n");
+ printf(" forces a class of words to be the latest of the line they "
+ "appear in.\n");
+ printf(" from the words.\n");
+}
+
+void
+direct_access_help(void)
+{
+ ctxopt_ctx_disp_usage("Direct_access", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("Short description of allowed parameters:\n\n");
+ common_help();
- printf("\nDirect access specific help.\n\n");
- printf("The following parameters are available in this context:\n\n");
- printf("-h|-help\n");
- printf(" displays this help.\n");
printf("-D|-data|-options:\n");
printf(" sets sub-options to modify the behaviour of -N|-number,\n");
printf(" -U|-unnumber and -F|-en|-embedded_number.\n");
+ printf("-c|-col|-col_mode|-column\n");
+ printf(" is like|-t without argument but respects end of lines.\n");
+ printf("-l|-line|-line_mode\n");
+ printf(" is like|-c without column alignments.\n");
+ printf("-t|-tab_mode|-tabulate_mode\n");
+ printf(" tabulates the items. The number of columns can be limited with\n");
+ printf(" an optional number.\n");
+ printf("-T|-tm|-tag_mode/-P|-pm|-pin_mode\n");
+ printf(" enables the tagging (multi-selections) mode. ");
+ printf("An optional parameter\n");
+ printf(" sets the separator string between the selected words ");
+ printf("on the output.\n");
+ printf(" A single space is the default separator.\n");
+
+ exit(EXIT_FAILURE);
+}
+
+void
+tagging_help(void)
+{
+ ctxopt_ctx_disp_usage("Tagging", continue_after);
+
+ printf("\n----------------------------------------");
+ printf("----------------------------------------\n");
+
+ printf("The following parameters are available in this context:\n\n");
+ common_help();
+
+ printf("-p|-at|-auto_tag\n");
+ printf(" activates the auto-tagging.\n");
exit(EXIT_FAILURE);
}