commit 19b4d99293ad470c98406b94935565750339b716
Author:     Tom Schwindl <[email protected]>
AuthorDate: Thu Dec 29 13:02:59 2022 +0100
Commit:     Jan Klemkow <[email protected]>
CommitDate: Mon Jan 2 19:48:17 2023 +0100

    Refactor headers
    
    slackline_internals.h:
    contains common operations for the `slackline` struct not meant to be used
    outside of slackline.
    
    slackline.h:
    contains the API for slackline. The `slackline` struct may become opaque
    in the future.

diff --git a/slackline.h b/slackline.h
index b9ef729..5039704 100644
--- a/slackline.h
+++ b/slackline.h
@@ -1,9 +1,8 @@
 #ifndef SLACKLIINE_H
 #define SLACKLIINE_H
 
-#include <stdbool.h>
-
 enum esc_seq {ESC_NONE, ESC, ESC_BRACKET, ESC_BRACKET_NUM};
+enum mode {SL_DEFAULT, SL_EMACS, SL_VI};
 
 struct slackline {
        /* buffer */
@@ -26,11 +25,14 @@ struct slackline {
        /* UTF-8 handling */
        char ubuf[6];   /* UTF-8 buffer */
        size_t ubuf_len;
+
+       enum mode mode;
 };
 
 struct slackline *sl_init(void);
 void sl_free(struct slackline *sl);
 void sl_reset(struct slackline *sl);
 int sl_keystroke(struct slackline *sl, int key);
+void sl_mode(struct slackline *sl, enum mode mode);
 
 #endif
diff --git a/slackline_internals.h b/slackline_internals.h
new file mode 100644
index 0000000..aa22a4e
--- /dev/null
+++ b/slackline_internals.h
@@ -0,0 +1,14 @@
+#ifndef SLACKLINE_INTERNALS_H
+#define SLACKLINE_INTERNALS_H
+
+#include "slackline.h"
+
+enum direction {LEFT, RIGHT, HOME, END};
+
+size_t sl_postobyte(struct slackline *sl, size_t pos);
+char *sl_postoptr(struct slackline *sl, size_t pos);
+void sl_backspace(struct slackline *sl);
+void sl_move(struct slackline *sl, enum direction dir);
+void sl_emacs(struct slackline *sl, int key);
+
+#endif

Reply via email to