#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include <aversive/pgmspace.h>
#include <cirbuf.h>
#include "rdline.h"
Go to the source code of this file.
Functions | |
void | rdline_init (struct rdline *rdl, rdline_write_char_t *write_char, rdline_validate_t *validate, rdline_complete_t *complete) |
void | rdline_newline (struct rdline *rdl, const char *prompt) |
void | rdline_stop (struct rdline *rdl) |
void | rdline_restart (struct rdline *rdl) |
const char * | rdline_get_buffer (struct rdline *rdl) |
void | rdline_redisplay (struct rdline *rdl) |
int8_t | rdline_char_in (struct rdline *rdl, char c) |
int8_t | rdline_add_history (struct rdline *rdl, const char *buf) |
void | rdline_clear_history (struct rdline *rdl) |
char * | rdline_get_history_item (struct rdline *rdl, uint8_t i) |
int8_t rdline_add_history | ( | struct rdline * | rdl, | |
const char * | buf | |||
) |
Add the buffer to history. return < 0 on error.
rdl | A pointer to a struct rdline | |
buf | A buffer that is terminated by '' |
Definition at line 535 of file rdline.c.
Referenced by rdline_char_in().
int8_t rdline_char_in | ( | struct rdline * | rdl, | |
char | c | |||
) |
append a char to the readline buffer. Return 1 when the line has been validated. Return 2 when the user asked to complete the buffer. Return -1 if it is not running. Return -2 if EOF (ctrl-d on an empty line). Else return 0. XXX error case when the buffer is full ?
rdl | A pointer to a struct rdline | |
c | The character to append |
Definition at line 142 of file rdline.c.
References cirbuf_add_buf_tail(), cirbuf_add_head(), cirbuf_add_tail(), cirbuf_add_tail_safe(), cirbuf_align_left(), cirbuf_del_buf_head(), cirbuf_del_head(), cirbuf_del_head_safe(), cirbuf_del_tail(), cirbuf_del_tail_safe(), cirbuf_get_buf_head(), cirbuf_get_head(), CIRBUF_GET_LEN, cirbuf_get_tail(), cirbuf_init(), CIRBUF_IS_EMPTY, rdline::complete, KEY_BKSPACE, KEY_CTRL_A, KEY_CTRL_B, KEY_CTRL_C, KEY_CTRL_D, KEY_CTRL_E, KEY_CTRL_F, KEY_CTRL_K, KEY_CTRL_L, KEY_CTRL_Y, KEY_DOWN_ARR, KEY_HELP, KEY_LEFT_ARR, KEY_META_BKSPACE, KEY_RETURN, KEY_RETURN2, KEY_RIGHT_ARR, KEY_SUPPR, KEY_TAB, KEY_UP_ARR, KEY_WLEFT, KEY_WRIGHT, rdline::left, rdline::left_buf, rdline::prompt, rdline_add_history(), RDLINE_BUF_SIZE, rdline_get_buffer(), rdline_get_history_item(), RDLINE_INIT, rdline_newline(), rdline_redisplay(), RDLINE_RUNNING, rdline::right, rdline::right_buf, rdline::status, rdline::validate, rdline::vt100, vt100_bs, vt100_clear_right, vt100_init(), vt100_left_arr, vt100_multi_left, vt100_multi_right, vt100_parser(), vt100_right_arr, and rdline::write_char.
void rdline_clear_history | ( | struct rdline * | rdl | ) |
const char* rdline_get_buffer | ( | struct rdline * | rdl | ) |
Return the current buffer, terminated by ''.
rdl | A pointer to a struct rdline |
Definition at line 96 of file rdline.c.
References cirbuf_align_left(), CIRBUF_GET_LEN, rdline::left, rdline::left_buf, rdline::right, and rdline::right_buf.
Referenced by rdline_char_in().
char* rdline_get_history_item | ( | struct rdline * | rdl, | |
uint8_t | i | |||
) |
void rdline_init | ( | struct rdline * | rdl, | |
rdline_write_char_t * | write_char, | |||
rdline_validate_t * | validate, | |||
rdline_complete_t * | complete | |||
) |
Init fields for a struct rdline. Call this only once at the beginning of your program.
rdl | A pointer to an uninitialized struct rdline | |
write_char | The function used by the function to write a character | |
validate | A pointer to the function to execute when the user validates the buffer. | |
complete | A pointer to the function to execute when the user completes the buffer. |
Definition at line 46 of file rdline.c.
References cirbuf_init(), rdline::complete, RDLINE_HISTORY_BUF_SIZE, RDLINE_INIT, rdline::status, rdline::validate, and rdline::write_char.
void rdline_newline | ( | struct rdline * | rdl, | |
const char * | prompt | |||
) |
Init the current buffer, and display a prompt.
rdl | A pointer to a struct rdline | |
prompt | A string containing the prompt |
Definition at line 62 of file rdline.c.
References cirbuf_init(), i, rdline::left, rdline::left_buf, rdline::prompt, rdline::prompt_size, RDLINE_BUF_SIZE, RDLINE_RUNNING, rdline::right, rdline::right_buf, rdline::status, rdline::vt100, vt100_init(), and rdline::write_char.
Referenced by rdline_char_in().
void rdline_redisplay | ( | struct rdline * | rdl | ) |
Redisplay the current buffer
rdl | A pointer to a struct rdline |
Definition at line 127 of file rdline.c.
References CIRBUF_FOREACH, rdline::left, rdline::prompt, rdline::prompt_size, vt100_home, and rdline::write_char.
Referenced by rdline_char_in().
void rdline_restart | ( | struct rdline * | rdl | ) |
Restart after a call to rdline_stop()
rdl | A pointer to a struct rdline |
Definition at line 90 of file rdline.c.
References RDLINE_RUNNING, and rdline::status.
void rdline_stop | ( | struct rdline * | rdl | ) |
Call it and all received chars will be ignored.
rdl | A pointer to a struct rdline |
Definition at line 84 of file rdline.c.
References RDLINE_INIT, and rdline::status.