Add VCS links
[debian-dgen.git] / sdl / prompt.h
blobefafcd40d7cd07a134f07b0ec1988c110ef2856b
1 #ifndef PROMPT_H_
2 #define PROMPT_H_
4 #include <stddef.h>
5 #include <stdint.h>
7 #ifdef __cplusplus
8 #define PROMPT_DECL_BEGIN__ extern "C" {
9 #define PROMPT_DECL_END__ }
10 #else
11 #define PROMPT_DECL_BEGIN__
12 #define PROMPT_DECL_END__
13 #endif
15 #define PROMPT_HIST_SIZE 64
16 #define PROMPT_LINE_SIZE 512
18 PROMPT_DECL_BEGIN__
20 struct prompt {
21 unsigned int cursor; /* cursor position for current line */
22 unsigned int current; /* current history[] entry */
23 unsigned int entries; /* number of entries in history[] */
24 struct prompt_history {
25 unsigned int length; /* line length */
26 uint8_t line[PROMPT_LINE_SIZE]; /* line data */
27 } history[PROMPT_HIST_SIZE];
30 struct prompt_parse {
31 unsigned int index; /* current index in argv */
32 unsigned int cursor; /* cursor position for current index or ~0u */
33 unsigned int argc; /* number of elements in argv */
34 uint8_t **argv; /* NULL-terminated array of pointers to each word */
35 unsigned int *args; /* size of each argv[] element */
36 struct prompt_parse_argo {
37 unsigned int pos;
38 unsigned int len;
39 } *argo; /* position and length of each element in original string */
42 extern void prompt_init(struct prompt *p);
43 extern void prompt_push(struct prompt *p);
44 extern void prompt_older(struct prompt *p);
45 extern void prompt_newer(struct prompt *p);
46 extern void prompt_left(struct prompt *p);
47 extern void prompt_right(struct prompt *p);
48 extern void prompt_begin(struct prompt *p);
49 extern void prompt_end(struct prompt *p);
50 extern void prompt_clear(struct prompt *p);
51 extern void prompt_put(struct prompt *p, uint8_t c);
52 extern void prompt_delete(struct prompt *p);
53 extern void prompt_backspace(struct prompt *p);
54 extern void prompt_replace(struct prompt *p, unsigned int pos,
55 unsigned int len, const uint8_t *with,
56 unsigned int with_len);
57 extern struct prompt_parse *prompt_parse(struct prompt *p,
58 struct prompt_parse *pp);
59 extern void prompt_parse_clean(struct prompt_parse *pp);
61 PROMPT_DECL_END__
63 #endif /* PROMPT_H_ */