Bump to release 1.4.0
[smenu.git] / usage.c
blob06fa28b1eb82f40075dcfb889d12383bf7a83dfb
1 /* ################################################################### */
2 /* Copyright 2015, Pierre Gentile (p.gen.progs@gmail.com) */
3 /* */
4 /* This Source Code Form is subject to the terms of the Mozilla Public */
5 /* License, v. 2.0. If a copy of the MPL was not distributed with this */
6 /* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
7 /* ################################################################### */
9 /* **************** */
10 /* Usage functions. */
11 /* **************** */
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <unistd.h>
17 #include "usage.h"
18 #include "ctxopt.h"
20 static void
21 common_help(void);
23 /* ======================= */
24 /* Usage display and exit. */
25 /* ======================= */
26 static void
27 common_help(void)
29 printf("-h|-help\n");
30 printf(" displays this help.\n");
31 printf("-u|-usage\n");
32 printf(" displays the synopsis of the current context.\n");
33 printf("-i|-in|-inc|-incl|-include\n");
34 printf(" sets the regex input filter to match the selectable words.\n");
35 printf("-e|-ex|-exc|-excl|-exclude\n");
36 printf(" sets the regex input filter to match the non-selectable "
37 "words.\n");
38 printf("-m|-msg|-message|-title\n");
39 printf(" displays a one-line message/title above the window.\n");
40 printf("-!|-int|-int_string\n");
41 printf(" outputs an optional string when ^C is typed.\n");
42 printf("-a|-attr|-attributes\n");
43 printf(" sets the attributes for the various displayed elements.\n");
44 printf("-1|-l1|-level1,-2|-l2|-level2,...,-9|-l9|-level9\n");
45 printf(" gives specific colors to up to 9 classes of "
46 "selectable words.\n");
47 printf("-z|-zap|-zap_glyphs bytes\n");
48 printf(" defines a set of glyphs that should be ignored in the input "
49 "stream.\n");
50 printf("-n|-lines|-height\n");
51 printf(" sets the maximum number of lines in the selection window.\n");
52 printf(" This number is autodetected when no number is given.\n");
53 printf("-b|-blank\n");
54 printf(" displays non printable characters as space.\n");
55 printf("-.|-dot|-invalid\n");
56 printf(" defines the substitution character for a non-printable "
57 "character.\n");
58 printf("-M|-middle|-center\n");
59 printf(" centers the display if possible.\n");
60 printf("-d|-restore|-delete|-clean|-delete_window|-clean_window\n");
61 printf(" clears the lines used by the selection window on exit.\n");
62 printf("-k|-ks|-keep_spaces\n");
63 printf(" does not trim spaces surrounding the output string if any.\n");
64 printf("-W|-ws|-wd|-word_delimiters|-word_separators\n");
65 printf(" defines word separators in the input stream.\n");
66 printf("-L|-ls|-ld|-line-delimiters|-line_separators\n");
67 printf(" defines line separators in the input stream.\n");
68 printf("-q|-no_bar|-no_scroll_bar\n");
69 printf(" prevents the scroll bar from being displayed.\n");
70 printf("-q|-no_hbar|-no_hor_scroll_bar\n");
71 printf(" prevents the horizontal scroll bar from being displayed.\n");
72 printf("-S|-subst\n");
73 printf(" defines the post-substitution action to apply to all words.\n");
74 printf("-I|-si|-subst_included\n");
75 printf(" defines the post-substitution action to apply to selectable "
76 "words only.\n");
77 printf("-E|-se|-subst_excluded\n");
78 printf(" defines the post-substitution action to apply to non-selectable "
79 "words only.\n");
80 printf("-ES|-early_subst\n");
81 printf(" defines the early substitution action to apply to all words.\n");
82 printf("-/|-search_method\n");
83 printf(" changes the affectation of the / key (default: fuzzy search).\n");
84 printf("-s|-sp|-start|-start_pattern\n");
85 printf(" sets the initial cursor position (refer to the manual for "
86 "more details).\n");
87 printf("-x|-tmout|-timeout/-X|-htmout|-hidden_timeout\n");
88 printf(" defines a timeout and specifies what to do when it expires.\n");
89 printf("-r|-auto_validate\n");
90 printf(" enables ENTER to validate the selection even in search mode.\n");
91 printf("-is|-incremental_search\n");
92 printf(" prevents the search buffer from being reset when starting a new "
93 "search\n");
94 printf(" session.\n");
95 printf("-v|-vb|-visual_bell\n");
96 printf(" makes the bell visual (fuzzy search with error).\n");
97 printf("-Q|-ignore_quotes\n");
98 printf(" treats single and double quotes as normal characters.\n");
99 printf("-lim|-limits\n");
100 printf(" overload the words number/max. word length/max columns limits.\n");
101 printf("-al|-align\n");
102 printf(" sets alignments for words selected by regular expressions.\n");
103 printf("-f|-forgotten_timeout|-global_timeout\n");
104 printf(" defines a global inactivity timeout, defaults to 15 min.\n");
105 printf("-nm|-no_mouse\n");
106 printf(" disable a possibly auto-detected mouse tracking support.\n");
107 printf("-br|-buttons|-button_remapping\n");
108 printf(" Remaps the left and right mouse buttons, default is 1 and 3.\n");
109 printf("-dc|-dcd|-double_click|-double_click_delay\n");
110 printf(" Change the mouse double-click delay which is 150 ms by default.\n");
111 printf("-sb|-sbw|-show_blank_words\n");
112 printf(" Make blank words visible and usable even in non column mode.\n");
115 void
116 main_help(void)
118 ctxopt_ctx_disp_usage("Main", continue_after);
120 printf("\n----------------------------------------");
121 printf("----------------------------------------\n");
123 printf("\nThis is a filter that gets words from stdin or from a file and ");
124 printf("outputs\n");
125 printf("the selected words (or nothing) on stdout in a nice selection ");
126 printf("window\n\n");
127 printf("The selection window appears on /dev/tty ");
128 printf("just below the current line\n");
129 printf("(no clear screen!).\n\n");
131 printf("Short description of allowed parameters:\n\n");
132 common_help();
134 printf("-V|-version\n");
135 printf(" displays the current version and quits.\n");
136 printf("-H|-long_help\n");
137 printf(" displays a full help and the options available in all "
138 "contexts.\n");
139 printf("-N|-number/-U|-unnumber\n");
140 printf(" creates or deletes direct access entries for words matching "
141 "(or not) a\n");
142 printf(" specific regex.\n");
143 printf("-F|-en|-embedded_number\n");
144 printf(" creates direct access entries by extracting the numbers from the "
145 "input words.\n");
146 printf("-c|-col|-col_mode|-column\n");
147 printf(" is like -tab without argument but respects end of lines.\n");
148 printf("-l|-line|-line_mode\n");
149 printf(" is like -col without column alignments.\n");
150 printf("-t|-tab|-tab_mode|-tabulate_mode\n");
151 printf(" tabulates the items. The number of columns can be limited "
152 "with\n");
153 printf(" an optional number.\n");
154 printf("-T|-tm|-tag|-tag_mode/-P|-pm|-pin|-pin_mode\n");
155 printf(" enables the tagging mode (multi-selections). ");
156 printf("An optional parameter\n");
157 printf(" defines the separator string between the selected words ");
158 printf("on the output.\n");
159 printf(" A single space is the default separator.\n");
161 printf("\nNavigation keys are:\n");
162 printf(" - Left/Down/Up/Right arrows or h/j/k/l, H/J/K/L.\n");
163 printf(" - Home/End, SHIFT|CTRL+Home/End CTRK+J/CTRL+K.\n");
164 printf(" - Numbers if some words are numbered (-N/-U/-F).\n");
165 printf(" - SPACE to search for the next match of a previously\n");
166 printf(" entered search prefix if any, see below.\n\n");
167 printf("Other useful keys are:\n");
168 printf(" - Help key (temporary display of a short help line): "
169 "?\n");
170 printf(" - Exit key without output (do nothing) : "
171 "q\n");
172 printf(" - Tagging keys: Select/Deselect/Toggle : "
173 "INS/DEL/t\n");
174 printf(" - Selection key : "
175 "ENTER\n");
176 printf(" - Cancel key : "
177 "ESC\n");
178 printf(" - Search key : "
179 "/ or CTRL-F\n\n");
180 printf("The search key activates a timed search mode in which\n");
181 printf("you can enter the first letters of the searched word.\n");
182 printf("When entering this mode you have 10s to start typing\n");
183 printf("and each entered letter restarts this timer.\n");
184 printf("After this time, the normal navigation mode is restored.\n\n");
185 printf("Notes:\n");
186 printf("- the search timer can be cancelled by pressing ESC.\n");
187 printf("- a bad search letter can be removed with ");
188 printf("CTRL-H or Backspace.\n\n");
189 printf("(C) Pierre Gentile.\n\n");
191 exit(EXIT_FAILURE);
194 void
195 columns_help(void)
197 ctxopt_ctx_disp_usage("Columns", continue_after);
199 printf("\n----------------------------------------");
200 printf("----------------------------------------\n");
202 printf("Short description of allowed parameters:\n\n");
203 common_help();
205 printf("-C|-cs|-cols|-cols_select\n");
206 printf(" sets alignments and columns restrictions for selections.\n");
207 printf("-R|-rs|-rows|-rows_select\n");
208 printf(" sets rows restrictions for selections.\n");
209 printf("-w|-wide|-wide_mode\n");
210 printf(" uses all the terminal width for the columns if their numbers "
211 "is given.\n");
212 printf("-g|-gutter\n");
213 printf(" separates columns with a character in column or tabulate "
214 "mode.\n");
215 printf("-N|-number/-U|-unnumber\n");
216 printf(" numbers/un-numbers and provides a direct access to words "
217 "matching\n");
218 printf(" (or not) a specific regex.\n");
219 printf("-F|-en|-embedded_number\n");
220 printf(" numbers and provides a direct access to words by extracting the "
221 "number\n");
222 printf("-T|-tm|-tag|-tag_mode/-P|-pm|-pin|-pin_mode\n");
223 printf(" enables the tagging (multi-selections) mode. ");
224 printf("An optional parameter\n");
225 printf(" sets the separator string between the selected words ");
226 printf("on the output.\n");
227 printf(" A single space is the default separator.\n");
228 printf("-A|-fc|-first_column\n");
229 printf(" forces the specified word pattern to start a line.\n");
230 printf("-Z|-lc|-last_column\n");
231 printf(" forces the specified word pattern to end a line.\n");
234 void
235 lines_help(void)
237 ctxopt_ctx_disp_usage("Lines", continue_after);
239 printf("\n----------------------------------------");
240 printf("----------------------------------------\n");
242 printf("Short description of allowed parameters:\n\n");
243 common_help();
245 printf("-R|-rs|-rows|-row_select\n");
246 printf(" sets alignments and rows restrictions for selections.\n");
247 printf("-N|-number/-U|-unnumber\n");
248 printf(" numbers/un-numbers and provides a direct access to words "
249 "matching\n");
250 printf(" (or not) a specific regex.\n");
251 printf("-F|-en|-embedded_number\n");
252 printf(" numbers and provides a direct access to words by extracting the "
253 "number\n");
254 printf("-T|-tm|-tag|-tag_mode/-P|-pm|-pin|-pin_mode\n");
255 printf(" enables the tagging (multi-selections) mode. ");
256 printf("An optional parameter\n");
257 printf(" sets the separator string between the selected words ");
258 printf("on the output.\n");
259 printf(" A single space is the default separator.\n");
260 printf("-A|-fc|-first_column\n");
261 printf(" forces the specified word pattern to start a line.\n");
262 printf("-Z|-lc|-last_column\n");
263 printf(" forces the specified word pattern to end a line.\n");
266 void
267 tabulations_help(void)
269 ctxopt_ctx_disp_usage("Tabulations", continue_after);
271 printf("\n----------------------------------------");
272 printf("----------------------------------------\n");
274 printf("Short description of allowed parameters:\n\n");
275 common_help();
277 printf("-w|-wide|-wide_mode\n");
278 printf(" uses all the terminal width for the columns if their numbers "
279 "is given.\n");
280 printf("-g|-gutter\n");
281 printf(" separates columns with a character in column or tabulate "
282 "mode.\n");
283 printf("-N|-number/-U|-unnumber\n");
284 printf(" numbers/un-numbers and provides a direct access to words "
285 "matching\n");
286 printf(" (or not) a specific regex.\n");
287 printf("-F|-en|-embedded_number\n");
288 printf(" numbers and provides a direct access to words by extracting the "
289 "number\n");
290 printf("-T|-tm|-tag|-tag_mode/-P|-pm|-pin|-pin_mode\n");
291 printf(" enables the tagging (multi-selections) mode. ");
292 printf("An optional parameter\n");
293 printf(" sets the separator string between the selected words ");
294 printf("on the output.\n");
295 printf(" A single space is the default separator.\n");
296 printf("-A|-fc|-first_column\n");
297 printf(" forces the specified word pattern to start a line.\n");
298 printf("-Z|-lc|-last_column\n");
299 printf(" forces the specified word pattern to end a line.\n");
302 void
303 tagging_help(void)
305 ctxopt_ctx_disp_usage("Tagging", continue_after);
307 printf("\n----------------------------------------");
308 printf("----------------------------------------\n");
310 printf("The following parameters are available in this context:\n\n");
311 common_help();
313 printf("-p|-at|-auto_tag\n");
314 printf(" activates the auto-tagging.\n");
315 printf("-0|-noat|-no_auto_tag\n");
316 printf(" do not auto-tag the word under the cursor when in tagged mode\n");
317 printf(" and no other word is selected.\n");
319 exit(EXIT_FAILURE);