Revision 697dba3c core/inc/aos_shell.h
core/inc/aos_shell.h | ||
---|---|---|
50 | 50 |
/** |
51 | 51 |
* @brief Shell event flag that is emitted when a command is executed. |
52 | 52 |
*/ |
53 |
#define AOS_SHELL_EVTFLAG_EXEC ((eventflags_t)(1 << 1))
|
|
53 |
#define AOS_SHELL_EVTFLAG_EXECUTE ((eventflags_t)(1 << 1))
|
|
54 | 54 |
|
55 | 55 |
/** |
56 | 56 |
* @brief Shell event flag that is emitted when a command execution finished. |
... | ... | |
239 | 239 |
} aos_shellexecstatus_t; |
240 | 240 |
|
241 | 241 |
/** |
242 |
* @brief Enumerator to encode shell actions. |
|
243 |
*/ |
|
244 |
typedef enum aos_shellaction { |
|
245 |
AOS_SHELL_ACTION_NONE, |
|
246 |
AOS_SHELL_ACTION_READCHAR, |
|
247 |
AOS_SHELL_ACTION_AUTOFILL, |
|
248 |
AOS_SHELL_ACTION_SUGGEST, |
|
249 |
AOS_SHELL_ACTION_INSERTTOGGLE, |
|
250 |
AOS_SHELL_ACTION_DELETEFORWARD, |
|
251 |
AOS_SHELL_ACTION_DELETEBACKWARD, |
|
252 |
AOS_SHELL_ACTION_RECALLLAST, |
|
253 |
AOS_SHELL_ACTION_CLEAR, |
|
254 |
AOS_SHELL_ACTION_CURSOR2START, |
|
255 |
AOS_SHELL_ACTION_CURSOR2END, |
|
256 |
AOS_SHELL_ACTION_CURSORLEFT, |
|
257 |
AOS_SHELL_ACTION_CURSORRIGHT, |
|
258 |
AOS_SHELL_ACTION_CURSORWORDLEFT, |
|
259 |
AOS_SHELL_ACTION_CURSORWORDRIGHT, |
|
260 |
AOS_SHELL_ACTION_EXECUTE, |
|
261 |
AOS_SHELL_ACTION_ESCSTART, |
|
262 |
AOS_SHELL_ACTION_PRINTUNKNOWNSEQUENCE, |
|
263 |
} aos_shellaction_t; |
|
264 |
|
|
265 |
/** |
|
266 | 242 |
* @brief Shell structure. |
267 | 243 |
*/ |
268 | 244 |
typedef struct aos_shell { |
... | ... | |
277 | 253 |
event_source_t eventSource; |
278 | 254 |
|
279 | 255 |
/** |
280 |
* @brief Struct for OS related events
|
|
256 |
* @brief Listener for OS related events.
|
|
281 | 257 |
*/ |
282 |
struct { |
|
283 |
/** |
|
284 |
* @brief Pointer to the OS' event source. |
|
285 |
*/ |
|
286 |
event_source_t* eventSource; |
|
287 |
|
|
288 |
/** |
|
289 |
* @brief Listener for OS related events. |
|
290 |
*/ |
|
291 |
event_listener_t eventListener; |
|
292 |
} os; |
|
258 |
event_listener_t osEventListener; |
|
293 | 259 |
|
294 | 260 |
/** |
295 | 261 |
* @brief Pointer to the first I/O channel. |
... | ... | |
318 | 284 |
struct { |
319 | 285 |
/** |
320 | 286 |
* @brief Input buffer. |
287 |
* @details This buffer is interpreted as two dimensional array. |
|
288 |
* It contains @p nentries elements of @p linewidth size each. |
|
321 | 289 |
*/ |
322 |
char* line; |
|
323 |
|
|
324 |
/** |
|
325 |
* @brief Size of the input buffer. |
|
326 |
*/ |
|
327 |
size_t length; |
|
328 |
|
|
329 |
/** |
|
330 |
* @brief Size of the argument buffer. |
|
331 |
*/ |
|
332 |
size_t nargs; |
|
333 |
} input; |
|
334 |
|
|
335 |
/** |
|
336 |
* @brief Structure containing data for internal input parsing. |
|
337 |
*/ |
|
338 |
struct { |
|
339 |
/** |
|
340 |
* @brief The last action executed by the shell. |
|
341 |
*/ |
|
342 |
aos_shellaction_t lastaction; |
|
290 |
char* buffer; |
|
343 | 291 |
|
344 | 292 |
/** |
345 |
* @brief Buffer to store an escape sequence. |
|
293 |
* @brief Number of entries in the buffer. |
|
294 |
* @note Must be >0. |
|
346 | 295 |
*/ |
347 |
char escseq[AOS_SHELL_ESCSEQUENCE_LENGTH];
|
|
296 |
size_t nentries;
|
|
348 | 297 |
|
349 | 298 |
/** |
350 |
* @brief Current curso position. |
|
299 |
* @brief Width of each input line. |
|
300 |
* @brief Must be >0. |
|
351 | 301 |
*/ |
352 |
size_t cursorpos;
|
|
302 |
size_t linewidth;
|
|
353 | 303 |
|
354 | 304 |
/** |
355 |
* @brief Current line width. |
|
356 |
*/ |
|
357 |
size_t lineend; |
|
358 |
|
|
359 |
/** |
|
360 |
* @brief Flag whether there was input since the prompt was printed the last time. |
|
305 |
* @brief Size of the argument buffer. |
|
306 |
* @note Must be >0. |
|
361 | 307 |
*/ |
362 |
bool noinput; |
|
363 |
} inputdata; |
|
364 |
|
|
365 |
|
|
308 |
size_t nargs; |
|
309 |
} input; |
|
366 | 310 |
|
367 | 311 |
/** |
368 | 312 |
* @brief Configuration flags. |
... | ... | |
394 | 338 |
#if defined(__cplusplus) |
395 | 339 |
extern "C" { |
396 | 340 |
#endif /* defined(__cplusplus) */ |
397 |
void aosShellInit(aos_shell_t* shell, event_source_t* oseventsource, const char* prompt, char* line, size_t linesize, size_t numargs);
|
|
341 |
void aosShellInit(aos_shell_t* shell, const char* prompt, char inbuf[], size_t entries, size_t linewidth, size_t numargs);
|
|
398 | 342 |
void aosShellStreamInit(AosShellStream* stream); |
399 | 343 |
void aosShellChannelInit(AosShellChannel* channel, BaseAsynchronousChannel* asyncchannel); |
400 | 344 |
aos_status_t aosShellAddCommand(aos_shell_t* shell, aos_shellcommand_t* cmd); |
Also available in: Unified diff