Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
microrl.h
Go to the documentation of this file.
1#ifndef _MICRORL_H_
2#define _MICRORL_H_
3
4#include "microrlConfig.h"
5
6#define true 1
7#define false 0
8
9 /* define the Key codes */
10#define KEY_NUL 0
11#define KEY_SOH 1
12#define KEY_STX 2
13#define KEY_ETX 3
14#define KEY_EOT 4
15#define KEY_ENQ 5
16#define KEY_ACK 6
17#define KEY_BEL 7
18#define KEY_BS 8
19#define KEY_HT 9
20#define KEY_LF 10
21#define KEY_VT 11
22#define KEY_FF 12
23#define KEY_CR 13
24#define KEY_SO 14
25#define KEY_SI 15
26#define KEY_DLE 16
27#define KEY_DC1 17
28#define KEY_DC2 18
29#define KEY_DC3 19
30#define KEY_DC4 20
31#define KEY_NAK 21
32#define KEY_SYN 22
33#define KEY_ETB 23
34#define KEY_CAN 24
35#define KEY_EM 25
36#define KEY_SUB 26
37#define KEY_ESC 27
38#define KEY_FS 28
39#define KEY_GS 29
40#define KEY_RS 30
41#define KEY_US 31
43#define KEY_DEL 127
45// direction of history navigation
46#define _HIST_UP 0
47#define _HIST_DOWN 1
48// esc seq internal codes
49#define _ESC_BRACKET 1
50#define _ESC_HOME 2
51#define _ESC_END 3
52
53#ifdef _USE_HISTORY
54// history struct, contain internal variable
55// history store in static ring buffer for memory saving
56typedef struct {
57 char ring_buf [_RING_HISTORY_LEN];
58 int begin;
59 int end;
60 int cur;
62#endif
63
64// microrl struct, contain internal library data
65typedef struct {
66#ifdef _USE_HISTORY
67 ring_history_t ring_hist; // history object
68#endif
69 char * prompt_str; // pointer to prompt string
70 char cmdline [_COMMAND_LINE_LEN]; // cmdline buffer
71 int cmdlen; // last position in command line
72 int cursor; // input cursor
73 char const * tkn_arr [_COMMAND_TOKEN_NMB]; // array of token for call 'execute' callback
74 void (*execute) (int argc, const char * const * argv ); // ptr to 'execute' callback
75 const char ** (*get_completion) (int argc, const char * const * argv ); // ptr to 'completion' callback
76 void (*print) (const char *); // ptr to 'print' callback
77#ifdef _USE_CTLR_C
78 void (*sigint) (void);
79#endif
80} microrl_t;
81
82// init internal data, calls once at start up
83void microrl_init (microrl_t * pThis, void (*print)(const char*));
84
85// set echo mode (true/false), using for disabling echo for password input
86// echo mode will enabled after user press Enter.
88
89// set pointer to callback complition func, that called when user press 'Tab'
90// callback func description:
91// param: argc - argument count, argv - pointer array to token string
92// must return NULL-terminated string, contain complite variant splitted by 'Whitespace'
93// If complite token found, it's must contain only one token to be complitted
94// Empty string if complite not found, and multiple string if there are some token
96 const char ** (*get_completion)(int, const char* const*));
97
98// pointer to callback func, that called when user press 'Enter'
99// execute func param: argc - argument count, argv - pointer array to token string
100void microrl_set_execute_callback (microrl_t * pThis, void (*execute)(int, const char* const*));
101
102// set callback for Ctrl+C terminal signal
103#ifdef _USE_CTLR_C
104void microrl_set_sigint_callback (microrl_t * pThis, void (*sigintf)(void));
105#endif
106
107// insert char to cmdline (for example call in usart RX interrupt)
109
110#endif
uint16_t foo
Definition main_demo5.c:58
#define _COMMAND_TOKEN_NMB
#define _RING_HISTORY_LEN
#define _COMMAND_LINE_LEN
void microrl_set_complete_callback(microrl_t *pThis, const char **(*get_completion)(int, const char *const *))
Definition microrl.c:353
void microrl_init(microrl_t *pThis, void(*print)(const char *))
Definition microrl.c:329
void microrl_insert_char(microrl_t *pThis, int ch)
Definition microrl.c:576
void microrl_set_echo(int)
void microrl_set_sigint_callback(microrl_t *pThis, void(*sigintf)(void))
Definition microrl.c:366
void microrl_set_execute_callback(microrl_t *pThis, void(*execute)(int, const char *const *))
Definition microrl.c:360
char * prompt_str
Definition microrl.h:69
ring_history_t ring_hist
Definition microrl.h:67
int cursor
Definition microrl.h:72
int cmdlen
Definition microrl.h:71