From 043a183d1465f578775e2a28bdc0a5c44afccd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 28 Jan 2017 14:03:57 +0100 Subject: vis: keep track of most recently processed keys of input queue Currently the key handling functions do not know through which mapping they were invoked. As an example the `count` handler exploits the implementation detail that the input queue is stored in contiguous memory, meaning `keys[-1]` gives access to the digit being pressed. This adds infrastructure to keep track of the two most recently processed keys of the input queue. The information is guaranteed to be accurate for the initial invocation of the key handler but will be overwritten in case new keys are pushed to the input queue (e.g. through vis_keys_feed). --- vis-core.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'vis-core.h') diff --git a/vis-core.h b/vis-core.h index debd994..cc8636d 100644 --- a/vis-core.h +++ b/vis-core.h @@ -174,7 +174,9 @@ struct Vis { Map *options; /* ":set"-options */ Map *keymap; /* key translation before any bindings are matched */ bool keymap_disabled; /* ignore key map for next key press, gets automatically re-enabled */ - char key[64]; /* last pressed key as reported from the UI */ + char key[VIS_KEY_LENGTH_MAX]; /* last pressed key as reported from the UI */ + char key_current[VIS_KEY_LENGTH_MAX];/* current key being processed by the input queue */ + char key_prev[VIS_KEY_LENGTH_MAX]; /* previous key which was processed by the input queue */ Buffer input_queue; /* holds pending input keys */ Buffer *keys; /* currently active keys buffer (either the input_queue or a macro) */ bool errorhandler; /* whether we are currently in an error handler, used to avoid recursion */ -- cgit v1.2.3