|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
12 #ifdef _USE_LIBC_STDIO
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wstrict-overflow"
45 if (i == pThis->
begin)
76 pThis->
begin = new_pos;
89 if (pThis->
begin - pThis->
end - 1> len)
109 if (len < _RING_HISTORY_LEN-pThis->end-1)
110 memmove (pThis->
ring_buf + pThis->
end + 1, line, len);
113 memmove (pThis->
ring_buf + pThis->
end + 1, line, part_len);
114 memmove (pThis->
ring_buf, line + part_len, len - part_len);
117 pThis->
end = pThis->
end + len + 1;
122 #ifdef _HISTORY_DEBUG
135 int header = pThis->
begin;
136 while (pThis->
ring_buf [header] != 0) {
137 header += pThis->
ring_buf [header] + 1;
144 if (cnt >= pThis->
cur) {
145 int lheader = pThis->
begin;
148 while ((pThis->
ring_buf [lheader] != 0) && (cnt - j -1 != pThis->
cur)) {
149 lheader += pThis->
ring_buf [lheader] + 1;
167 memmove (line, pThis->
ring_buf + lheader + 1, part0);
174 if (pThis->
cur > 0) {
176 int lheader = pThis->
begin;
179 while ((pThis->
ring_buf [lheader] != 0) && (cnt - j != pThis->
cur)) {
180 lheader += pThis->
ring_buf [lheader] + 1;
189 memmove (line, pThis->
ring_buf + lheader + 1, part0);
210 while ((pThis->
cmdline [ind] ==
'\0') && (ind < limit)) {
213 if (!(ind < limit))
return i;
219 while ((pThis->
cmdline [ind] !=
'\0') && (ind < limit)) {
222 if (!(ind < limit))
return i;
237 pThis->
print (
"\033[D \033[D");
246 #ifndef _USE_LIBC_STDIO
252 char tmp_str [6] = {0,};
256 tmp_str[i++] = (nmb % 10) +
'0';
259 for (
int j = 0; j < i; ++j)
260 *(buf++) = tmp_str [i-j-1];
272 #ifdef _USE_LIBC_STDIO
274 snprintf (str, 16,
"\033[%dC",
offset);
276 snprintf (str, 16,
"\033[%dD", -(
offset));
279 strcpy (str,
"\033[");
296 #ifdef _USE_LIBC_STDIO
297 snprintf (str, 16,
"\033[%dD\033[%dC", \
301 strcpy (str,
"\033[");
303 strcat (str,
"D\033[");
314 pThis->
print (
"\033[K");
317 for (
int i = pos; i < pThis->
cmdlen; i++) {
346 pThis->
print = print;
347 #ifdef _ENABLE_INIT_PROMPT
354 const char ** (*get_completion)(
int,
const char*
const*))
397 }
else if (ch ==
'B') {
402 }
else if (ch ==
'C') {
408 }
else if (ch ==
'D') {
414 }
else if (ch ==
'7') {
417 }
else if (ch ==
'8') {
421 }
else if (ch ==
'~') {
441 #pragma GCC diagnostic push
442 #pragma GCC diagnostic ignored "-Wstrict-overflow"
444 #pragma GCC diagnostic pop
451 for (
int i = 0; i < len; i++) {
491 while (arr[i]!=NULL) {
492 if ((arr[i][len] != arr[i-1][len]) ||
493 (arr[i][len] ==
'\0') ||
494 (arr[i-1][len]==
'\0'))
506 const char ** compl_token;
515 if (compl_token[0] != NULL) {
519 if (compl_token[1] == NULL) {
520 len = strlen (compl_token[0]);
524 while (compl_token [i] != NULL) {
525 pThis->
print (compl_token[i]);
536 if (compl_token[1] == NULL)
557 pThis->
print (
"ERROR:too many tokens");
572 #if (defined(_ENDL_CRLF) || defined(_ENDL_LFCR))
573 static int tmpch = 0;
580 static int escape =
false;
595 #elif defined(_ENDL_CRLF)
603 #elif defined(_ENDL_LFCR)
632 while (pThis->
cursor > 0) {
639 pThis->
print (
"\033[K");
686 if (pThis->
sigint != NULL)
692 if ((ch ==
' ') && (pThis->
cmdlen == 0))
#define KEY_NAK
^U Negative acknowledge
#define KEY_LF
^J Line Feed
static int split(microrl_t *pThis, int limit)
static void terminal_print_line(microrl_t *pThis, int pos, int cursor)
void new_line_handler(microrl_t *pThis)
static void microrl_get_complite(microrl_t *pThis)
static void terminal_backspace(microrl_t *pThis)
static void microrl_backspace(microrl_t *pThis)
#define KEY_ETX
^C End of text
const char * tkn_arr[_COMMAND_TOKEN_NMB]
#define KEY_SOH
^A Start of heading, = console interrupt
void(* execute)(int argc, const char *const *argv)
static int hist_restore_line(ring_history_t *pThis, char *line, int dir)
#define KEY_BS
^H Backspace, works on HP terminals/computers
#define KEY_DEL
Delete (not a real control character...)
static void hist_save_line(ring_history_t *pThis, char *line, int len)
static int microrl_insert_text(microrl_t *pThis, const char *text, int len)
static void terminal_move_cursor(microrl_t *pThis, int offset)
#define _COMMAND_TOKEN_NMB
#define _RING_HISTORY_LEN
#define KEY_ACK
^F Acknowledge, clears ENQ logon hand
#define KEY_CR
^M Carriage Return
static void terminal_newline(microrl_t *pThis)
Mini printf-like functionality.
static void hist_search(microrl_t *pThis, int dir)
#define KEY_DLE
^P Data link escape
void microrl_set_complete_callback(microrl_t *pThis, const char **(*get_completion)(int, const char *const *))
#define KEY_ENQ
^E Enquiry, goes with ACK; old HP flow control
char cmdline[_COMMAND_LINE_LEN]
static int hist_is_space_for_new(ring_history_t *pThis, int len)
#define _COMMAND_LINE_LEN
static void print_prompt(microrl_t *pThis)
static void terminal_reset_cursor(microrl_t *pThis)
#define KEY_VT
^K Vertical tab
void microrl_init(microrl_t *pThis, void(*print)(const char *))
static const float offset[]
char ring_buf[_RING_HISTORY_LEN]
#define KEY_HT
^I Horizontal tab, move to next tab stop
#define KEY_SO
^N Shift Out, alternate character set
static int escape_process(microrl_t *pThis, char ch)
void microrl_set_execute_callback(microrl_t *pThis, void(*execute)(int, const char *const *))
#define KEY_STX
^B Start of text, maintenance mode on HP console
static void u16bit_to_str(unsigned int nmb, char *buf)
const char **(* get_completion)(int argc, const char *const *argv)
#define KEY_ESC
^[ Escape, next character is not echoed
void microrl_insert_char(microrl_t *pThis, int ch)
static int common_len(const char **arr)
void microrl_set_sigint_callback(microrl_t *pThis, void(*sigintf)(void))
void(* print)(const char *)
static void hist_erase_older(ring_history_t *pThis)