cemu
载入中...
搜索中...
未找到
linenoise.h
浏览该文件的文档.
1
50#ifndef __LINENOISE_H
51#define __LINENOISE_H
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57#include <stddef.h> /* For size_t. */
58
59extern char *linenoiseEditMore;
60
61/* The linenoiseState structure represents the state during line editing.
62 * We pass this state to functions implementing specific editing
63 * functionalities. */
65 int in_completion; /* The user pressed TAB and we are now in completion
66 * mode, so input is handled by completeLine(). */
67 size_t completion_idx; /* Index of next completion to propose. */
68 int ifd; /* Terminal stdin file descriptor. */
69 int ofd; /* Terminal stdout file descriptor. */
70 char *buf; /* Edited line buffer. */
71 size_t buflen; /* Edited line buffer size. */
72 const char *prompt; /* Prompt to display. */
73 size_t plen; /* Prompt length. */
74 size_t pos; /* Current cursor position. */
75 size_t oldpos; /* Previous refresh cursor position. */
76 size_t len; /* Current edited line length. */
77 size_t cols; /* Number of columns in terminal. */
78 size_t oldrows; /* Rows used by last refrehsed line (multiline mode) */
79 int history_index; /* The history index we are currently editing. */
80};
81
82typedef struct linenoiseCompletions {
83 size_t len;
84 char **cvec;
86
87/* Non blocking API. */
88int linenoiseEditStart(struct linenoiseState *l, int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt);
89char *linenoiseEditFeed(struct linenoiseState *l);
90void linenoiseEditStop(struct linenoiseState *l);
91void linenoiseHide(struct linenoiseState *l);
92void linenoiseShow(struct linenoiseState *l);
93
94/* Blocking API. */
95char *linenoise(const char *prompt);
96void linenoiseFree(void *ptr);
97
98/* Completion API. */
99typedef void(linenoiseCompletionCallback)(const char *, linenoiseCompletions *);
100typedef char*(linenoiseHintsCallback)(const char *, int *color, int *bold);
101typedef void(linenoiseFreeHintsCallback)(void *);
102void linenoiseSetCompletionCallback(linenoiseCompletionCallback *);
103void linenoiseSetHintsCallback(linenoiseHintsCallback *);
104void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
105void linenoiseAddCompletion(linenoiseCompletions *, const char *);
106
107/* History API. */
108int linenoiseHistoryAdd(const char *line);
109int linenoiseHistorySetMaxLen(int len);
110int linenoiseHistorySave(const char *filename);
111int linenoiseHistoryLoad(const char *filename);
112
113/* Other utilities. */
114void linenoiseClearScreen(void);
115void linenoiseSetMultiLine(int ml);
116void linenoisePrintKeyCodes(void);
117void linenoiseMaskModeEnable(void);
118void linenoiseMaskModeDisable(void);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* __LINENOISE_H */
Definition linenoise.h:82
Definition linenoise.h:64