tBegin implementing command mode - ve - a minimal text editor (work in progress)
(HTM) git clone git://src.adamsgaard.dk/ve
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit a15a5661b1eb2ccdf076c8a0eb43c5eb8c0560e6
(DIR) parent 5a9f61927211165c1e0da5706c60d333fff846a2
(HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
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(-)
---
(DIR) 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
(DIR) 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
*/
(DIR) 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;
}
-