summaryrefslogtreecommitdiffstats
path: root/include/mbsedit.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:10:49 +0000
commitcfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch)
treed0baf160cbee3195249d095f85e52d20c21acf02 /include/mbsedit.h
parentInitial commit. (diff)
downloadutil-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz
util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/mbsedit.h')
-rw-r--r--include/mbsedit.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/mbsedit.h b/include/mbsedit.h
new file mode 100644
index 0000000..ed7960f
--- /dev/null
+++ b/include/mbsedit.h
@@ -0,0 +1,38 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * This file may be distributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#ifndef UTIL_LINUX_MBSEDIT_H
+# define UTIL_LINUX_MBSEDIT_H
+
+#include "mbsalign.h"
+#include "widechar.h"
+
+struct mbs_editor {
+ char *buf; /* buffer */
+ size_t max_bytes; /* size of the buffer */
+ size_t max_cells; /* maximal allowed number of cells */
+ size_t cur_cells; /* number of cells to print the buffer */
+ size_t cur_bytes; /* number of chars in bytes */
+ size_t cursor; /* cursor position in bytes */
+ size_t cursor_cells; /* cursor position in cells */
+};
+
+enum {
+ MBS_EDIT_LEFT,
+ MBS_EDIT_RIGHT,
+ MBS_EDIT_END,
+ MBS_EDIT_HOME
+};
+
+struct mbs_editor *mbs_new_edit(char *buf, size_t bufsz, size_t ncells);
+char *mbs_free_edit(struct mbs_editor *edit);
+
+int mbs_edit_goto(struct mbs_editor *edit, int where);
+int mbs_edit_delete(struct mbs_editor *edit);
+int mbs_edit_backspace(struct mbs_editor *edit);
+int mbs_edit_insert(struct mbs_editor *edit, wint_t c);
+
+#endif /* UTIL_LINUX_MBSEDIT_H */