| tBegin implementing command mode - ve - a minimal text editor (work in progress) | |
| git clone git://src.adamsgaard.dk/ve | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit a15a5661b1eb2ccdf076c8a0eb43c5eb8c0560e6 | |
| parent 5a9f61927211165c1e0da5706c60d333fff846a2 | |
| Author: Anders Damsgaard <[email protected]> | |
| Date: Fri, 16 Aug 2019 10:03:51 +0200 | |
| Begin implementing command mode | |
| Diffstat: | |
| M TODO | 4 +--- | |
| M config.def.h | 3 +++ | |
| M ve.c | 27 +++++++++++++++++++++++++-- | |
| 3 files changed, 29 insertions(+), 5 deletions(-) | |
| --- | |
| diff --git a/TODO b/TODO | |
| t@@ -1,8 +1,6 @@ | |
| Core functionality: | |
| - Set keypress timeout before redraw | |
| - - Proper handling of command-line arguments | |
| - - Implement procedural keybinds | |
| - - Implementing most Vi binds | |
| + - Implement most Vi binds | |
| - Implement command mode | |
| - Allow call of commands with keybinds | |
| - Implement visual mode | |
| diff --git a/config.def.h b/config.def.h | |
| t@@ -13,6 +13,9 @@ static int status_message_timeout = 3; | |
| /* static unsigned int cursorshape_normal = 2; */ | |
| /* static unsigned int cursorshape_insert = 6; */ | |
| +/* leader key for bind sequences */ | |
| +#define LEADER ' ' | |
| + | |
| /* | |
| * color settings for syntax highglighting | |
| */ | |
| diff --git a/ve.c b/ve.c | |
| t@@ -910,6 +910,26 @@ editor_move_cursor(char key) | |
| } | |
| void | |
| +editor_read_command() | |
| +{ | |
| + char* query; | |
| + query = editor_prompt(":%s"); | |
| + | |
| + editor_set_status_message("you typed: '%s'", query); | |
| + free(query); | |
| +} | |
| + | |
| +/* first word in query is the command, the remaining are interpreted as args */ | |
| +void | |
| +editor_command(char *query) | |
| +{ | |
| + switch(query) { | |
| + | |
| + } | |
| +} | |
| + | |
| + | |
| +void | |
| editor_process_keypress() | |
| { | |
| char c; | |
| t@@ -934,7 +954,11 @@ editor_process_keypress() | |
| editor_move_cursor(c); | |
| break; | |
| - case ' ': | |
| + case ':': | |
| + editor_read_command(); | |
| + break; | |
| + | |
| + case LEADER: | |
| c = editor_read_key(); | |
| switch (c) { | |
| case 'w': | |
| t@@ -1155,4 +1179,3 @@ main(int argc, char *argv[]) | |
| } | |
| return 0; | |
| } | |
| - |