]>
Commit | Line | Data |
---|---|---|
faeb1b64 KZ |
1 | /* |
2 | * SPDX-License-Identifier: LGPL-2.1-or-later | |
3 | * | |
4 | * This file may be distributed under the terms of the | |
5 | * GNU Lesser General Public License. | |
6 | */ | |
299ef2c4 KZ |
7 | #ifndef UTIL_LINUX_MBSEDIT_H |
8 | # define UTIL_LINUX_MBSEDIT_H | |
9 | ||
10 | #include "mbsalign.h" | |
11 | #include "widechar.h" | |
12 | ||
13 | struct mbs_editor { | |
14 | char *buf; /* buffer */ | |
15 | size_t max_bytes; /* size of the buffer */ | |
16 | size_t max_cells; /* maximal allowed number of cells */ | |
17 | size_t cur_cells; /* number of cells to print the buffer */ | |
18 | size_t cur_bytes; /* number of chars in bytes */ | |
19 | size_t cursor; /* cursor position in bytes */ | |
20 | size_t cursor_cells; /* cursor position in cells */ | |
21 | }; | |
22 | ||
23 | enum { | |
24 | MBS_EDIT_LEFT, | |
25 | MBS_EDIT_RIGHT, | |
26 | MBS_EDIT_END, | |
27 | MBS_EDIT_HOME | |
28 | }; | |
29 | ||
30 | struct mbs_editor *mbs_new_edit(char *buf, size_t bufsz, size_t ncells); | |
31 | char *mbs_free_edit(struct mbs_editor *edit); | |
32 | ||
33 | int mbs_edit_goto(struct mbs_editor *edit, int where); | |
34 | int mbs_edit_delete(struct mbs_editor *edit); | |
35 | int mbs_edit_backspace(struct mbs_editor *edit); | |
36 | int mbs_edit_insert(struct mbs_editor *edit, wint_t c); | |
37 | ||
38 | #endif /* UTIL_LINUX_MBSEDIT_H */ |