1 /* Yash: yet another shell */
2 /* input.h: functions for input of command line */
3 /* (C) 2007-2018 magicant */
5 /* This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 wchar_t *main, *right, *styler, *predict;
30 #define PROMPT_RESET L"\\fD"
32 extern struct promptset_T get_prompt(int type);
33 static inline void free_prompt(struct promptset_T prompt);
34 extern void print_prompt(const wchar_t *s)
35 __attribute__((nonnull));
36 extern _Bool unset_nonblocking(int fd);
39 /* Frees the specified prompt set. */
40 void free_prompt(struct promptset_T prompt)
49 /* The result type of `inputfunc_T'. */
50 typedef enum inputresult_T {
51 INPUT_OK, /* A line was read successfully. */
52 INPUT_EOF, /* The end of file was reached. */
53 INPUT_INTERRUPTED, /* SIGINT was received (interactive shell only) */
54 INPUT_ERROR, /* Other error was encountered. */
58 struct input_file_info_T;
59 extern inputresult_T read_input(
60 struct xwcsbuf_T *buf, struct input_file_info_T *info, _Bool trap)
61 __attribute__((nonnull));
63 /* The type of input functions.
64 * An input function reads input and appends it to buffer `buf'.
65 * Input is done line-wise: the buffer contents are always terminated by a
66 * newline character (L'\n') except when the end of file is reached and the last
67 * line does not have a newline.
68 * An input function should not read more than one line at a time, as commands
69 * (which may contain alias definitions) should be executed as soon as possible,
70 * before the next line is parsed.
71 * The result is indicated by a value of the `inputresult_T' type. If the return
72 * value is other than INPUT_OK, the buffer is unchanged.
73 * The input function may be called even after it returned a value other than
75 typedef inputresult_T inputfunc_T(struct xwcsbuf_T *buf, void *inputinfo);
78 extern inputresult_T input_wcs(struct xwcsbuf_T *buf, void *inputinfo)
79 __attribute__((nonnull));
80 extern inputresult_T input_file(struct xwcsbuf_T *buf, void *inputinfo)
81 __attribute__((nonnull));
82 extern inputresult_T input_interactive(struct xwcsbuf_T *buf, void *inputinfo)
83 __attribute__((nonnull));
85 /* to be used as `inputinfo' for `input_wcs' */
86 struct input_wcs_info_T {
87 const wchar_t *src; /* the input source code */
90 /* to be used as `inputinfo' for `input_file' */
91 struct input_file_info_T {
94 size_t bufpos, bufmax, bufsize;
97 /* `bufsize' is the size of `buf', which must be at least one byte. */
99 /* to be used as `inputinfo' for `input_interactive' */
100 struct input_interactive_info_T {
101 struct input_file_info_T *fileinfo;
106 #endif /* YASH_INPUT_H */
109 /* vim: set ts=8 sts=4 sw=4 noet tw=80: */