dot

packages and services management
Log | Files | Refs | README

commit 1d920d2c818d64a0140765af6df656f1db1b25d0
parent 374131d791289242a45dd171840930317628ba80
Author: Josuah Demangeonā  ā µ <jd@ssh.bio>
Date:   Thu, 15 Sep 2016 14:58:39 +0200

Added a draft for a future project

Diffstat:
Abin/filter | 143+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 143 insertions(+), 0 deletions(-)

diff --git a/bin/filter b/bin/filter @@ -0,0 +1,143 @@ + ____ __ /\ /\ + .' ___\ \/ / // /_ ___ _____ + / .'_ /\ / // ___\.'__ \ / ____\ + / ___/ / // // / / ____// / + \/ \/ \/ \/ \___\ \/ 2016-09-15 +================================================================================ +Filter lines form stdin to print to stdout using user keyboard input + + I will hopefully write this in ANSI C some day... At least I + really wish I will ever be able to! + + The goal is to learn (ANSI) C, and mostly to be able to do + interfaces like those of vimperator. + + Spaces are considered as a '*' wildchar or '.*' regular + expression. All other characters are interpreted. + + The order should be preserved, so that filter to + + Lower case switches for interface, uppercase switches for + input/output. + + +OPTIONS / FEATURES 2016-09-18 +-------------------------------------------------------------------------------- +Description of the features I will possibly implement. + + -p PROMPT + Aditionnal part of the prompt to add before the '> '. + + -n + Display line number before the match. + + -N + Only return the line number. + + -k VALIDATEKEY + Aditionnal key to use to return current selection. + This can a space for use as a word completion engine + (Ctrl + N in vim). + + -s SEPARATOR + Separator for the output: The selected candidate will be + printed up to this separator, rather than being printed + completely. The separator will be aligned according + to 2 rules: 1. The biggest part before separator; 2. Do + not outreach the half of the screen horizontally. + + The right part will also be grayed, and not printed in + the prompt. + + This is why this needs to be dynamic and be coded in + the source rather than in the integration tools (do ONE + THING and do it well...). + + -c COMMENT + Comment char: Every line starting with this character + will be treated as a header. Header are always visible + and bold (\033[1m), even when not matched. This is + convenient to prompt the user items from multiple + categories at the same time. + + -l LINES + Number of lines to display at once. Default is 10. + + -b + Display (and update) the prompt to be at the bottom of + the candidates, and at the bottom of the screen. + + -t + Display (and update) the prompt to be at the top of the + candidates, and at the bottom of the screen. + + -d DEFAULT + Set the input a DEFAULT string before to start. + + +KEYBINDINGS 2016-09-18 +-------------------------------------------------------------------------------- + + Ctrl + I + Tab + Switch between candidates, and finally come back to the + original input without completion. + + Ctrl + H + Backspace + Delete one char backward, but if there is no char + backward, it should return an error code of 1. + + Ctrl + C + Cancel, and make filter return the error code of 1. + + Ctrl + V KEY + Insert the next KEY pressed literally. + + Ctrl + U + Deletes the entire input. + + +INTERFACE 2016-09-18 +-------------------------------------------------------------------------------- +Differences and similarity with vimperator input. + + In adition to vimperator behavior, a count would be displayed + in top right hand corner of the current input line, not used as + the completion may be rather small. I will need a way to manage + long line in input anyway, because the case with long lines and + small screen _will_ occur. + + In vimperator, there is a grayed text after the input, + corresponding to the completion. This is a nice feature and I + plan to do this: \033[1;0m can output gray text even it TTY. + + The matched string should be highlighted in candidates. + + The current candidate should be highlighted with '\033[7m' prevent the + matched string to appear liht yellow on white background. + + +USAGE 2016-09-18 +-------------------------------------------------------------------------------- +Example that can replicate advanced vimperator completion features + + In vimperator, while space is pressed, it prompts for the next + input to enter, and still keep the current input onscreen. + Backspace delete the input. + + This can be performed with filter: + + By setting '-k' to a space, at every word, the completion + is stored. + + Then a new prompt is generated using the previous word as a prompt + + By checking for the return value, and if it is >0 (there was + an error, the user cancelled (Ctrl + C) or pressed backspace at + the beginning of the line), then reiterate the previous prompt. + + This then permits to select from a first level input (like + commands), then according to the command, select second level + input different for each command (like flags or 'empty'), and + then, select a third level input (like filename)...