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