From 938de29a3b8a85b3639abd8db5c6821b1d4f54f7 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 19 Feb 2011 12:37:33 +0000 Subject: added input.txt where we can plan how the new input system will work --- vim-mode/input.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 vim-mode/input.txt (limited to 'vim-mode/input.txt') diff --git a/vim-mode/input.txt b/vim-mode/input.txt new file mode 100644 index 0000000..cc32a3b --- /dev/null +++ b/vim-mode/input.txt @@ -0,0 +1,4 @@ +How the input system for vim_mode should work. +============================================= + + -- cgit v1.2.3 From ef943af836d4648d9bbb6aca7355db1de2812b6f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 19 Feb 2011 13:58:32 +0100 Subject: input.txt: Add some general ideas. --- vim-mode/input.txt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'vim-mode/input.txt') diff --git a/vim-mode/input.txt b/vim-mode/input.txt index cc32a3b..040fb44 100644 --- a/vim-mode/input.txt +++ b/vim-mode/input.txt @@ -1,4 +1,21 @@ How the input system for vim_mode should work. ============================================= - +- insert mode mappings +- normal mode mappings +- timeout for ambiguous mappings + - but support for no timeout for some mappings (like Ctrl-R in insert mode) +- maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') +- partial commands/mappings (like :map a :b a which inserts ex mode and + displays :b a there without running any command) +- support for mappings entering insert mode: :map gX itexthere (also + without esc!) +- . for all (most) commands +- more general command order: 3"ap doesn't work but "a3p does +- arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ + doesn't work) +- support to disable mappings temporarily (:set paste, 'pastetoggle') +- (better) support multiple bindings for the same action (especially and + ) +- unmapping of internal mappings (for example to as it's also used + for colors in irssi) -- cgit v1.2.3 From 43e4fff44a9b6293e5483b6739c17a42d3bb1346 Mon Sep 17 00:00:00 2001 From: Tom Feist Date: Sat, 19 Feb 2011 13:33:35 +0000 Subject: added some detail on FSM for input control, and how to detect sequences. --- vim-mode/input.txt | 73 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 18 deletions(-) (limited to 'vim-mode/input.txt') diff --git a/vim-mode/input.txt b/vim-mode/input.txt index 040fb44..790060a 100644 --- a/vim-mode/input.txt +++ b/vim-mode/input.txt @@ -1,21 +1,58 @@ How the input system for vim_mode should work. ============================================= -- insert mode mappings -- normal mode mappings -- timeout for ambiguous mappings - - but support for no timeout for some mappings (like Ctrl-R in insert mode) -- maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') -- partial commands/mappings (like :map a :b a which inserts ex mode and - displays :b a there without running any command) -- support for mappings entering insert mode: :map gX itexthere (also - without esc!) -- . for all (most) commands -- more general command order: 3"ap doesn't work but "a3p does -- arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ - doesn't work) -- support to disable mappings temporarily (:set paste, 'pastetoggle') -- (better) support multiple bindings for the same action (especially and - ) -- unmapping of internal mappings (for example to as it's also used - for colors in irssi) +* insert mode mappings +* normal (command) mode mappings +* timeout for ambiguous mappings +** but support for no timeout for some mappings (like Ctrl-R in insert mode) +* maybe 'timeout' and 'ttimeout' settings (and 'timeoutlen' and 'ttimeoutlen') +* partial commands/mappings (like :map a :b a which inserts ex mode and +* displays :b a there without running any command) +* support for mappings entering insert mode: :map gX itexthere (also without esc!) +** (.) (repeat) for all (most) commands +* more general command order: 3"ap doesn't work but "a3p does +* arbitrary mappings, like 3dwjjihi10G (at the moment even :map Y y$ doesn't work) +* support to disable mappings temporarily (:set paste, 'pastetoggle') +* (better) support multiple bindings for the same action (especially and ) +* unmapping of internal mappings (for example to as it's also used for colors in irssi) +* better approach to detecting single ESC push (compared to F-keys or meta-* keys) + +We base the input model on a simple state machine. +It can exist in any of 4 (5) states: + - insert mode + - insert escape mode + a transitional mode to distingush that we've received an escape char. + - command mode + - ex mode + - visual mode (can be mostly ignored for now, until I sort my overlays stuff + out) + +to swap between these modes, there are various bindings available. +The most challenging is going from insert -> command. Typically this is done +by a single push of the key, but C-c and are both alternatives that +people use. + +The single entrypoint we have into the input system is detecting keystrokes. +when a 'gui key pressed' signal is fired, we can receive, process and interrupt +it such that it never gets passed to irssi proper. + +in order to detect single presses from their meta comrades, we operate +as the following: + +if (key == 27) { + mode = insert_escape + add_timeout(short, check_escape_buffer) +} elsif (mode == insert_escape) { + insert(key, escape_buffer) +} else { + # do nothing +} + +sub check_escape_buffer { +# when the timeout fires, we can assume that only meta-keys would be fast enough +# to insert additional characters into the buffer. In which case, we replay +# them and clear the buffer. + mode = insert_mode; +# if the buffer is otherwise empty, we have received a single escape press. + mode = command_mode; +} -- cgit v1.2.3