31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wstrict-overflow"
45 if (i ==
pThis->begin)
135 int header =
pThis->begin;
136 while (
pThis->ring_buf [header] != 0) {
137 header +=
pThis->ring_buf [header] + 1;
144 if (cnt >=
pThis->cur) {
174 if (
pThis->cur > 0) {
237 pThis->print (
"\033[D \033[D");
246#ifndef _USE_LIBC_STDIO
259 for (
int j = 0;
j < i; ++
j)
272#ifdef _USE_LIBC_STDIO
296#ifdef _USE_LIBC_STDIO
314 pThis->print (
"\033[K");
317 for (
int i = pos; i <
pThis->cmdlen; i++) {
334 pThis->ring_hist.begin = 0;
335 pThis->ring_hist.end = 0;
336 pThis->ring_hist.cur = 0;
346 pThis->print = print;
347#ifdef _ENABLE_INIT_PROMPT
354 const char ** (*get_completion)(
int,
const char*
const*))
356 pThis->get_completion = get_completion;
362 pThis->execute = execute;
397 }
else if (
ch ==
'B') {
402 }
else if (
ch ==
'C') {
408 }
else if (
ch ==
'D') {
409 if (
pThis->cursor > 0) {
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++) {
453 if (
pThis->cmdline [
pThis->cursor + i] ==
' ') {
457 pThis->cursor += len;
458 pThis->cmdlen += len;
469 if (
pThis->cursor > 0) {
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'))
551 if (
pThis->cmdlen > 0)
557 pThis->print (
"ERROR:too many tokens");
567 pThis->ring_hist.cur = 0;
572#if (defined(_ENDL_CRLF) || defined(_ENDL_LFCR))
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");
692 if ((
ch ==
' ') && (
pThis->cmdlen == 0))
static const float offset[]
#define _COMMAND_TOKEN_NMB
#define _RING_HISTORY_LEN
#define _COMMAND_LINE_LEN
static void hist_save_line(ring_history_t *pThis, char *line, int len)
static int escape_process(microrl_t *pThis, char ch)
void new_line_handler(microrl_t *pThis)
static int hist_is_space_for_new(ring_history_t *pThis, int len)
static int split(microrl_t *pThis, int limit)
void microrl_set_complete_callback(microrl_t *pThis, const char **(*get_completion)(int, const char *const *))
void microrl_init(microrl_t *pThis, void(*print)(const char *))
static void print_prompt(microrl_t *pThis)
static void hist_erase_older(ring_history_t *pThis)
static void microrl_backspace(microrl_t *pThis)
static void terminal_backspace(microrl_t *pThis)
static void hist_search(microrl_t *pThis, int dir)
static int common_len(const char **arr)
static void terminal_reset_cursor(microrl_t *pThis)
static void microrl_get_complite(microrl_t *pThis)
static int hist_restore_line(ring_history_t *pThis, char *line, int dir)
static void terminal_print_line(microrl_t *pThis, int pos, int cursor)
void microrl_insert_char(microrl_t *pThis, int ch)
static void terminal_newline(microrl_t *pThis)
static int microrl_insert_text(microrl_t *pThis, const char *text, int len)
static void terminal_move_cursor(microrl_t *pThis, int offset)
void microrl_set_sigint_callback(microrl_t *pThis, void(*sigintf)(void))
void microrl_set_execute_callback(microrl_t *pThis, void(*execute)(int, const char *const *))
static void u16bit_to_str(unsigned int nmb, char *buf)
#define KEY_NAK
^U Negative acknowledge
#define KEY_DLE
^P Data link escape
#define KEY_SO
^N Shift Out, alternate character set
#define KEY_ENQ
^E Enquiry, goes with ACK; old HP flow control
#define KEY_ETX
^C End of text
#define KEY_VT
^K Vertical tab
#define KEY_BS
^H Backspace, works on HP terminals/computers
#define KEY_ESC
^[ Escape, next character is not echoed
#define KEY_STX
^B Start of text, maintenance mode on HP console
#define KEY_ACK
^F Acknowledge, clears ENQ logon hand
#define KEY_SOH
^A Start of heading, = console interrupt
#define KEY_CR
^M Carriage Return
#define KEY_DEL
Delete (not a real control character...)
#define KEY_HT
^I Horizontal tab, move to next tab stop
#define KEY_LF
^J Line Feed
Mini printf-like functionality.