Skip to contentSkip to conversation

edit: Add basic support for input line editing

RFC Superseded Marcel Holtmann 1 participant 1 message Dec 14, 2023 Kbuild

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

RFC v2 1/1 edit: Add basic support for input line editing

This allows for simple line editing with history capabilities. On purpose this has no concept of terminal input or terminal output and just allows manipulation of an internal wide character string.

The debug option is something that might need to be removed or at least changed a little bit, but right now it is nice to see the internal states.

Following features are missing:

1) Work with words (delete, move etc.)
2) Tab completion
3) Hints system

Following features are left to the user:

1) Showing the prompt
2) Switching to masked input

---
 Makefile.am |   2 +
 ell/edit.c  | 785 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ell/edit.h  |  59 ++++
 ell/ell.h   |   1 +
 ell/ell.sym |  25 ++
 5 files changed, 872 insertions(+)
 create mode 100644 ell/edit.c
 create mode 100644 ell/edit.h
Makefile.am +2 -0
index b77db391be56..eab450f71618 100644
@@ -55,6 +55,7 @@ pkginclude_HEADERS = ell/ell.h \
 			ell/ecc.h \
 			ell/ecdh.h \
 			ell/time.h \
+			ell/edit.h \
 			ell/gpio.h \
 			ell/path.h \
 			ell/icmp6.h \
@@ -145,6 +146,7 @@ ell_libell_la_SOURCES = $(linux_headers) \
 			ell/ecdh.c \
 			ell/time.c \
 			ell/time-private.h \
+			ell/edit.c \
 			ell/gpio.c \
 			ell/path.c \
 			ell/icmp6.c \
ell/edit.c new file +785 -0

785 lines not on this page · raw message

ell/edit.h new file +59 -0

59 lines not on this page · raw message

ell/ell.h +1 -0
index f67339105e8f..875bbb2cd43f 100644
@@ -46,6 +46,7 @@
 #include <ell/ecc.h>
 #include <ell/ecdh.h>
 #include <ell/time.h>
+#include <ell/edit.h>
 #include <ell/gpio.h>
 #include <ell/path.h>
 #include <ell/acd.h>
ell/ell.sym +25 -0
index a887b2b09520..eaf699a43d34 100644
@@ -617,6 +617,31 @@ global:
 	l_ecdh_generate_shared_secret;
 	/* time */
 	l_time_now;
+	/* edit */
+	l_edit_new;
+	l_edit_free;
+	l_edit_set_debug_handler;
+	l_edit_set_display_handler;
+	l_edit_set_max_display_length;
+	l_edit_set_max_input_length;
+	l_edit_set_history_size;
+	l_edit_refresh;
+	l_edit_is_empty;
+	l_edit_enter;
+	l_edit_reset;
+	l_edit_insert;
+	l_edit_delete;
+	l_edit_delete_all;
+	l_edit_truncate;
+	l_edit_backspace;
+	l_edit_move_left;
+	l_edit_move_right;
+	l_edit_move_home;
+	l_edit_move_end;
+	l_edit_history_backward;
+	l_edit_history_forward;
+	l_edit_history_load;
+	l_edit_history_save;
 	/* gpio */
 	l_gpio_chips_with_line_label;
 	l_gpio_chip_new;
Signature · 1 line
2.43.0