back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/readline.h
diff options
context:
space:
mode:
authorscratko <m@scratko.xyz>2024-06-20 18:38:11 +0300
committerscratko <m@scratko.xyz>2024-11-23 20:59:45 +0300
commit54679d85b1f2c1349bcbbc76b10d57a1e5137f23 (patch)
tree030bb7951a9a16dcdb8b1f47d1a5ff09dba8276c /readline.h
parentff38bddd4253b5adf08a84df34bfae32c8ae988d (diff)
downloadshell-54679d85b1f2c1349bcbbc76b10d57a1e5137f23.tar.gz
shell-54679d85b1f2c1349bcbbc76b10d57a1e5137f23.tar.bz2
shell-54679d85b1f2c1349bcbbc76b10d57a1e5137f23.zip
Shell-edit releaseshell-edit
Autocomplete program and file names (tab). Moving the cursor to edit commands (left and right arrows). Deleting a character in a command (backspace).
Diffstat (limited to 'readline.h')
-rw-r--r--readline.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/readline.h b/readline.h
new file mode 100644
index 0000000..b626cae
--- /dev/null
+++ b/readline.h
@@ -0,0 +1,37 @@
+#ifndef READLINE_H_SENTRY
+#define READLINE_H_SENTRY
+
+#include "readline.h"
+
+/*
+ * ends with these codes in escape sequence
+ * for the arrows
+ */
+enum keys{
+ left_arrow = 'D',
+ right_arrow = 'C',
+ up_arrow = 'A',
+ down_arrow = 'B',
+ none = 0,
+ unknown_key = -1,
+ backspace = 127
+};
+
+struct readline_type {
+ char *arr;
+ int cursor_pos;
+ int considered_index;
+ int last_element_index;
+ int allocation_size;
+};
+
+void readline_create_array(struct readline_type *readline);
+void readline_add_char(struct readline_type *readline, int ch);
+void readline_reset_array(struct readline_type *readline);
+void readline_clear(struct readline_type *readline);
+void readline_print(struct readline_type *readline_type);
+enum keys readline_detect_arrow_keys(int ch);
+void readline_move_along(struct readline_type *readline, enum keys found_key);
+void readline_character_deletion(struct readline_type *readline);
+
+#endif