File: mbsedit.h

package info (click to toggle)
util-linux 2.41.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 92,868 kB
  • sloc: ansic: 179,124; sh: 22,714; yacc: 1,284; makefile: 525; xml: 422; python: 316; lex: 89; ruby: 75; csh: 37; exp: 19; sed: 16; perl: 15; sql: 9
file content (38 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 */