aversive_10-03-12/modules/ihm/rdline/rdline.h File Reference

#include <cirbuf.h>
#include <vt100.h>

Go to the source code of this file.

Data Structures

struct  rdline

Defines

#define vt100_bell   "\007"
#define vt100_bs   "\010"
#define vt100_bs_clear   "\010 \010"
#define vt100_tab   "\011"
#define vt100_crnl   "\012\015"
#define vt100_clear_right   "\033[0K"
#define vt100_clear_left   "\033[1K"
#define vt100_clear_down   "\033[0J"
#define vt100_clear_up   "\033[1J"
#define vt100_clear_line   "\033[2K"
#define vt100_clear_screen   "\033[2J"
#define vt100_up_arr   "\033\133\101"
#define vt100_down_arr   "\033\133\102"
#define vt100_right_arr   "\033\133\103"
#define vt100_left_arr   "\033\133\104"
#define vt100_multi_right   "\033\133%uC"
#define vt100_multi_left   "\033\133%uD"
#define vt100_suppr   "\033\133\063\176"
#define vt100_home   "\033M\033E"
#define vt100_word_left   "\033\142"
#define vt100_word_right   "\033\146"
#define RDLINE_BUF_SIZE   64
#define RDLINE_PROMPT_SIZE   16
#define RDLINE_VT100_BUF_SIZE   8
#define RDLINE_HISTORY_BUF_SIZE   128
#define RDLINE_HISTORY_MAX_LINE   64

Typedefs

typedef void( rdline_write_char_t )(char)
typedef void( rdline_validate_t )(const char *buf, uint8_t size)
typedef int8_t( rdline_complete_t )(const char *buf, char *dstbuf, uint8_t dstsize, int16_t *state)

Enumerations

enum  rdline_status { RDLINE_INIT, RDLINE_RUNNING }

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)
void rdline_redisplay (struct rdline *rdl)
int8_t rdline_char_in (struct rdline *rdl, char c)
const char * rdline_get_buffer (struct rdline *rdl)
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)


Define Documentation

#define RDLINE_BUF_SIZE   64

Definition at line 60 of file rdline.h.

Referenced by rdline_char_in(), and rdline_newline().

#define RDLINE_HISTORY_BUF_SIZE   128

Definition at line 63 of file rdline.h.

Referenced by rdline_init().

#define RDLINE_HISTORY_MAX_LINE   64

Definition at line 64 of file rdline.h.

#define RDLINE_PROMPT_SIZE   16

Definition at line 61 of file rdline.h.

#define RDLINE_VT100_BUF_SIZE   8

Definition at line 62 of file rdline.h.

#define vt100_bell   "\007"

This library is a small equivalent to the GNU readline library, but it is designed for small systems, like Atmel AVR microcontrollers (8 bits). Indeed, we don't use any malloc that is sometimes not implemented on such systems.

Definition at line 37 of file rdline.h.

#define vt100_bs   "\010"

Definition at line 38 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_bs_clear   "\010 \010"

Definition at line 39 of file rdline.h.

#define vt100_clear_down   "\033[0J"

Definition at line 44 of file rdline.h.

#define vt100_clear_left   "\033[1K"

Definition at line 43 of file rdline.h.

#define vt100_clear_line   "\033[2K"

Definition at line 46 of file rdline.h.

#define vt100_clear_right   "\033[0K"

Definition at line 42 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_clear_screen   "\033[2J"

Definition at line 47 of file rdline.h.

#define vt100_clear_up   "\033[1J"

Definition at line 45 of file rdline.h.

#define vt100_crnl   "\012\015"

Definition at line 41 of file rdline.h.

#define vt100_down_arr   "\033\133\102"

Definition at line 49 of file rdline.h.

#define vt100_home   "\033M\033E"

Definition at line 55 of file rdline.h.

Referenced by rdline_redisplay().

#define vt100_left_arr   "\033\133\104"

Definition at line 51 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_multi_left   "\033\133%uD"

Definition at line 53 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_multi_right   "\033\133%uC"

Definition at line 52 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_right_arr   "\033\133\103"

Definition at line 50 of file rdline.h.

Referenced by rdline_char_in().

#define vt100_suppr   "\033\133\063\176"

Definition at line 54 of file rdline.h.

#define vt100_tab   "\011"

Definition at line 40 of file rdline.h.

#define vt100_up_arr   "\033\133\101"

Definition at line 48 of file rdline.h.

#define vt100_word_left   "\033\142"

Definition at line 56 of file rdline.h.

#define vt100_word_right   "\033\146"

Definition at line 57 of file rdline.h.


Typedef Documentation

typedef int8_t( rdline_complete_t)(const char *buf, char *dstbuf, uint8_t dstsize, int16_t *state)

Definition at line 75 of file rdline.h.

typedef void( rdline_validate_t)(const char *buf, uint8_t size)

Definition at line 74 of file rdline.h.

typedef void( rdline_write_char_t)(char)

Definition at line 73 of file rdline.h.


Enumeration Type Documentation

Enumerator:
RDLINE_INIT 
RDLINE_RUNNING 

Definition at line 66 of file rdline.h.


Function Documentation

int8_t rdline_add_history ( struct rdline rdl,
const char *  buf 
)

Add the buffer to history. return < 0 on error.

Parameters:
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 
)

void rdline_clear_history ( struct rdline rdl  ) 

Clear current history

Parameters:
rdl A pointer to a struct rdline

Definition at line 536 of file rdline.c.

const char* rdline_get_buffer ( struct rdline rdl  ) 

Return the current buffer, terminated by ''.

Parameters:
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 
)

Get the i-th history item

Definition at line 537 of file rdline.c.

Referenced by rdline_char_in().

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.

Parameters:
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.

Parameters:
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

Parameters:
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()

Parameters:
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.

Parameters:
rdl A pointer to a struct rdline

Definition at line 84 of file rdline.c.

References RDLINE_INIT, and rdline::status.


Generated on Fri Mar 12 06:32:07 2010 for AVR by  doxygen 1.5.6