Libecoli 0.4.0
Extensible COmmand LIne library
 
Loading...
Searching...
No Matches
ecoli_editline.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright 2018, Olivier MATZ <zer0@droids-corp.org>
3 */
4
16
17#ifndef ECOLI_EDITLINE_
18#define ECOLI_EDITLINE_
19
20#include <stdbool.h>
21
22#include <histedit.h>
23
24struct ec_editline;
25struct ec_node;
26struct ec_pnode;
27struct ec_comp;
28
33 char *desc;
34 char *help;
35};
36
40#define EC_EDITLINE_HISTORY_SIZE 128
41
60#define EC_EDITLINE_DISABLE_SIGNALS 0x01
61
67#define EC_EDITLINE_DISABLE_HISTORY 0x02
68
80#define EC_EDITLINE_DISABLE_COMPLETION 0x04
81
87#define EC_EDITLINE_DEFAULT_SIGHANDLER 0x08
88
89typedef int (*ec_editline_cmpl_t)(struct ec_editline *editline, int c);
90
98struct ec_editline *
99ec_editline(const char *name, FILE *f_in, FILE *f_out, FILE *f_err,
100 unsigned int flags);
101
105void ec_editline_free(struct ec_editline *editline);
106
110EditLine *ec_editline_get_el(struct ec_editline *editline);
111
112// XXX public?
113const struct ec_node *ec_editline_get_node(struct ec_editline *editline);
114void ec_editline_set_node(struct ec_editline *editline,
115 const struct ec_node *node);
116
117//XXX get history, get_...
118
135int ec_editline_set_history(struct ec_editline *editline,
136 size_t hist_size, const char *hist_file);
137
138int
139ec_editline_print_cols(struct ec_editline *editline,
140 char const * const *matches, size_t n);
141
142void ec_editline_free_completions(char **matches, size_t len);
143ssize_t
144ec_editline_get_completions(const struct ec_comp *cmpl, char ***matches_out);
145char *
146ec_editline_append_chars(const struct ec_comp *cmpl);
147
148ssize_t
149ec_editline_get_helps(const struct ec_editline *editline, const char *line,
150 const char *full_line, struct ec_editline_help **helps_out);
151int
152ec_editline_print_helps(struct ec_editline *editline,
153 const struct ec_editline_help *helps, size_t n);
154void
155ec_editline_free_helps(struct ec_editline_help *helps, size_t len);
156
157ssize_t
158ec_editline_get_suggestions(const struct ec_editline *editline,
159 struct ec_editline_help **suggestions,
160 char **full_line, int *pos);
161
162int
163ec_editline_set_prompt(struct ec_editline *editline, const char *prompt);
164
165int
166ec_editline_set_prompt_esc(struct ec_editline *editline, const char *prompt,
167 char delim);
168
169char *ec_editline_curline(const struct ec_editline *editline,
170 bool trim_after_cursor);
171
177char *ec_editline_gets(struct ec_editline *editline);
178
183struct ec_pnode *
184ec_editline_parse(struct ec_editline *editline, const struct ec_node *node);
185
186int
187ec_editline_complete(EditLine *el, int c);
188
189#endif
struct ec_node * ec_node(const char *typename, const char *id)
struct ec_pnode * ec_pnode(const struct ec_node *node)