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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/**
* @file interact.h
* @brief The interactive layer: prompts, line editing, history and
* completion.
*
* None of this is reached by a script. The only hook on the path that
* scripts share is one test in input_fill() ("is this input a terminal in
* an interactive shell?").
*/
#ifndef ZASH_INTERACT_H
#define ZASH_INTERACT_H
#include "parser.h"
/* ---- interact.c ------------------------------------------------------ */
void interact_init(void);
void interact_exit(void);
bool interact_read(input_src *in);
bool interact_refuse_eof(void);
/* ---- history.c ------------------------------------------------------- */
void hist_init(void);
void hist_add(const char *line, size_t len, bool append);
int hist_count(void);
const char *hist_entry(int index);
void hist_save(void);
/* ---- the line editor (edit_builtin.c or edit_libedit.c) -------------- */
/*
* Both editors define these two functions, where they are documented.
* edit_usable() says whether lines can be edited on this terminal;
* edit_readline() reads one line and returns it without its newline, in
* storage it owns, or NULL at end of input.
*/
bool edit_usable(void);
char *edit_readline(const char *prompt, size_t *len);
/*
* `bind`, in the notation of the BSD shells: edit_bind() records one
* "keys=action" word, reporting the problem itself and returning -1;
* edit_bind_list() prints the action names, one per line.
*/
int edit_bind(const char *spec);
void edit_bind_list(void);
/* ---- complete.c ------------------------------------------------------ */
/** @brief The result of asking what could complete a word. */
typedef struct completion {
char **list; /**< Candidate replacements for the word, sorted. */
int count; /**< Number of candidates. */
size_t start; /**< Offset in the line where the word begins. */
bool quoted; /**< The word began inside quotes: insert text as is. */
char quote; /**< That quote character, to close a final candidate. */
bool mvs; /**< Data set candidates: a final candidate is one that
does not end in `.` or `(`. */
} completion;
const char *expand_quietly(const char *raw, bool escapes);
void complete_line(const char *line, size_t cursor, completion *c);
void complete_free(completion *c);
#endif
|