2 , ,--. --.-. ,--. ---. , ,
3 | | | | | | |--' | | | |
4 ' `--' ' ' ' `--' ' ' `--` 2016-10-20
5 --------------------------------------------------------------------------------
6 Filter lines form stdin with an interactive menu
8 I will hopefully write this in ANSI C some day... At least I
9 really wish I will ever be able to!
11 The goal is to learn (ANSI) C, and mostly to be able to do
12 interfaces like those of vimperator.
16 --------------------------------------------------------------------------------
18 I described them all in the man page. I will provide a screencast if I
19 come with something nice.
23 --------------------------------------------------------------------------------
25 I like the lines order to be preserved while matching. This can
26 be convenient to pipe a file through filter, moreover.
28 Spaces are considered as a '*' wildchar or '.*' regular
29 expression. All other characters are consecutive characters
30 to match. This is hence not a fuzzy matching. There are fzf
31 and the very good fzy for that
33 While numbers are displayed (-n option), the number typed at
34 the beginning of input match in priority these displayed numbers.
38 --------------------------------------------------------------------------------
39 Differences and similarity with vimperator input.
41 In adition to vimperator behavior, a count would be displayed
42 in top right hand corner of the current input line, not used as
43 the completion may be rather small. I will need a way to manage
44 long line in input anyway, because the case with long lines and
45 small screen _will_ occur.
47 In vimperator, there is a grayed text after the input,
48 corresponding to the completion. This is a nice feature and I
49 plan to do this: \033[1;0m can output gray text even it TTY.
51 The matched string should be highlighted in candidates.
53 The current candidate should be highlighted with '\033[7m' prevent
54 the matched string to appear liht yellow on white background.
56 It could be nice if the candidates could be loaded dynamically,
57 to act like `fzf` does. Because it look good, and I would not
58 have to wait find on ~ to find a file to select it.
62 --------------------------------------------------------------------------------
63 Example that can replicate advanced vimperator completion features
65 In vimperator, while space is pressed, it prompts for the next
66 input to enter, and still keep the current input onscreen.
67 Backspace delete the input.
69 This can be performed with filter:
71 By setting '-k' to a space, at every word, the completion
74 Then a new prompt is generated using the previous word as a prompt
76 By checking for the return value, and if it is >0 (there was
77 an error, the user cancelled (Ctrl + C) or pressed backspace at
78 the beginning of the line), then reiterate the previous prompt.
80 This then permits to select from a first level input (like
81 commands), then according to the command, select second level
82 input different for each command (like flags or 'empty'), and
83 then, select a third level input (like filename)...
87 --------------------------------------------------------------------------------
88 Very useful while making this software
90 Thank you to the respective authors, that taught me C by writing
93 - https://github.com/martanne/vis/blob/master/vis-menu.c
94 - https://github.com/charles-l/pep/blob/master/pep.c
95 - http://git.suckless.org/sandy/tree/sandy.c