\section{aversive\_\-10-03-12/modules/ihm/rdline/rdline.c File Reference}
\label{rdline_8c}\index{aversive\_\-10-03-12/modules/ihm/rdline/rdline.c@{aversive\_\-10-03-12/modules/ihm/rdline/rdline.c}}
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$stdarg.h$>$}\par
{\tt \#include $<$ctype.h$>$}\par
{\tt \#include $<$aversive/pgmspace.h$>$}\par
{\tt \#include $<$cirbuf.h$>$}\par
{\tt \#include \char`\"{}rdline.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf rdline\_\-init} (struct {\bf rdline} $\ast$rdl, {\bf rdline\_\-write\_\-char\_\-t} $\ast$write\_\-char, {\bf rdline\_\-validate\_\-t} $\ast$validate, {\bf rdline\_\-complete\_\-t} $\ast$complete)
\item 
void {\bf rdline\_\-newline} (struct {\bf rdline} $\ast$rdl, const char $\ast$prompt)
\item 
void {\bf rdline\_\-stop} (struct {\bf rdline} $\ast$rdl)
\item 
void {\bf rdline\_\-restart} (struct {\bf rdline} $\ast$rdl)
\item 
const char $\ast$ {\bf rdline\_\-get\_\-buffer} (struct {\bf rdline} $\ast$rdl)
\item 
void {\bf rdline\_\-redisplay} (struct {\bf rdline} $\ast$rdl)
\item 
int8\_\-t {\bf rdline\_\-char\_\-in} (struct {\bf rdline} $\ast$rdl, char c)
\item 
int8\_\-t {\bf rdline\_\-add\_\-history} (struct {\bf rdline} $\ast$rdl, const char $\ast$buf)
\item 
void {\bf rdline\_\-clear\_\-history} (struct {\bf rdline} $\ast$rdl)
\item 
char $\ast$ {\bf rdline\_\-get\_\-history\_\-item} (struct {\bf rdline} $\ast$rdl, uint8\_\-t {\bf i})
\end{CompactItemize}


\subsection{Function Documentation}
\index{rdline.c@{rdline.c}!rdline\_\-add\_\-history@{rdline\_\-add\_\-history}}
\index{rdline\_\-add\_\-history@{rdline\_\-add\_\-history}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-add\_\-history]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t rdline\_\-add\_\-history (struct {\bf rdline} $\ast$ {\em rdl}, \/  const char $\ast$ {\em buf})}\label{rdline_8c_fa223954c2184029beb24cd1ea8478b3}


Add the buffer to history. return $<$ 0 on \doxyref{error}{p.}{structerror}. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \item[{\em buf}]A buffer that is terminated by '' \end{description}
\end{Desc}


Definition at line 535 of file rdline.c.

Referenced by rdline\_\-char\_\-in().\index{rdline.c@{rdline.c}!rdline\_\-char\_\-in@{rdline\_\-char\_\-in}}
\index{rdline\_\-char\_\-in@{rdline\_\-char\_\-in}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-char\_\-in]{\setlength{\rightskip}{0pt plus 5cm}int8\_\-t rdline\_\-char\_\-in (struct {\bf rdline} $\ast$ {\em rdl}, \/  char {\em c})}\label{rdline_8c_e9186b1e2793d6dad174d0acdc655faf}


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 \doxyref{error}{p.}{structerror} case when the buffer is full ?

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \item[{\em c}]The character to append \end{description}
\end{Desc}


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.\index{rdline.c@{rdline.c}!rdline\_\-clear\_\-history@{rdline\_\-clear\_\-history}}
\index{rdline\_\-clear\_\-history@{rdline\_\-clear\_\-history}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-clear\_\-history]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-clear\_\-history (struct {\bf rdline} $\ast$ {\em rdl})}\label{rdline_8c_34a9e7bb84507ceb4644f36e0550a734}


Clear current history \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \end{description}
\end{Desc}


Definition at line 536 of file rdline.c.\index{rdline.c@{rdline.c}!rdline\_\-get\_\-buffer@{rdline\_\-get\_\-buffer}}
\index{rdline\_\-get\_\-buffer@{rdline\_\-get\_\-buffer}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-get\_\-buffer]{\setlength{\rightskip}{0pt plus 5cm}const char$\ast$ rdline\_\-get\_\-buffer (struct {\bf rdline} $\ast$ {\em rdl})}\label{rdline_8c_dcd2d89335b71f48a4b6d2de36176697}


Return the current buffer, terminated by ''. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \end{description}
\end{Desc}


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().\index{rdline.c@{rdline.c}!rdline\_\-get\_\-history\_\-item@{rdline\_\-get\_\-history\_\-item}}
\index{rdline\_\-get\_\-history\_\-item@{rdline\_\-get\_\-history\_\-item}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-get\_\-history\_\-item]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ rdline\_\-get\_\-history\_\-item (struct {\bf rdline} $\ast$ {\em rdl}, \/  uint8\_\-t {\em i})}\label{rdline_8c_86581280d1f466b2f725a68da18d09d9}


Get the i-th history item 

Definition at line 537 of file rdline.c.

Referenced by rdline\_\-char\_\-in().\index{rdline.c@{rdline.c}!rdline\_\-init@{rdline\_\-init}}
\index{rdline\_\-init@{rdline\_\-init}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-init]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-init (struct {\bf rdline} $\ast$ {\em rdl}, \/  {\bf rdline\_\-write\_\-char\_\-t} $\ast$ {\em write\_\-char}, \/  {\bf rdline\_\-validate\_\-t} $\ast$ {\em validate}, \/  {\bf rdline\_\-complete\_\-t} $\ast$ {\em complete})}\label{rdline_8c_8065da1f82fca174f2395c0c5fb057ae}


Init fields for a struct \doxyref{rdline}{p.}{structrdline}. Call this only once at the beginning of your program. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to an uninitialized struct \doxyref{rdline}{p.}{structrdline} \item[{\em write\_\-char}]The function used by the function to write a character \item[{\em validate}]A pointer to the function to execute when the user validates the buffer. \item[{\em complete}]A pointer to the function to execute when the user completes the buffer. \end{description}
\end{Desc}


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.\index{rdline.c@{rdline.c}!rdline\_\-newline@{rdline\_\-newline}}
\index{rdline\_\-newline@{rdline\_\-newline}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-newline]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-newline (struct {\bf rdline} $\ast$ {\em rdl}, \/  const char $\ast$ {\em prompt})}\label{rdline_8c_d793c0f725f1cbe3e11c2bd633152063}


Init the current buffer, and display a prompt. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \item[{\em prompt}]A string containing the prompt \end{description}
\end{Desc}


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().\index{rdline.c@{rdline.c}!rdline\_\-redisplay@{rdline\_\-redisplay}}
\index{rdline\_\-redisplay@{rdline\_\-redisplay}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-redisplay]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-redisplay (struct {\bf rdline} $\ast$ {\em rdl})}\label{rdline_8c_4d5ea46995e07c00aa753ed0ced7ef08}


Redisplay the current buffer \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \end{description}
\end{Desc}


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().\index{rdline.c@{rdline.c}!rdline\_\-restart@{rdline\_\-restart}}
\index{rdline\_\-restart@{rdline\_\-restart}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-restart]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-restart (struct {\bf rdline} $\ast$ {\em rdl})}\label{rdline_8c_bb5a2436df7746ba8f42aa52ebc22814}


Restart after a call to \doxyref{rdline\_\-stop()}{p.}{rdline_8c_f2a86401dff132869fc6b8e6b138fad8} \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \end{description}
\end{Desc}


Definition at line 90 of file rdline.c.

References RDLINE\_\-RUNNING, and rdline::status.\index{rdline.c@{rdline.c}!rdline\_\-stop@{rdline\_\-stop}}
\index{rdline\_\-stop@{rdline\_\-stop}!rdline.c@{rdline.c}}
\subsubsection[rdline\_\-stop]{\setlength{\rightskip}{0pt plus 5cm}void rdline\_\-stop (struct {\bf rdline} $\ast$ {\em rdl})}\label{rdline_8c_f2a86401dff132869fc6b8e6b138fad8}


Call it and all received chars will be ignored. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em rdl}]A pointer to a struct \doxyref{rdline}{p.}{structrdline} \end{description}
\end{Desc}


Definition at line 84 of file rdline.c.

References RDLINE\_\-INIT, and rdline::status.