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

#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)


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