51 #ifndef _DYNASHELL_READLINE_H 52 #define _DYNASHELL_READLINE_H 54 #include <sys/types.h> 67 #include <readline/readline.h> 68 #include <readline/history.h> 69 #endif // HAVE_READLINE 93 typedef char *(*ReadLineAppGenFunc_T)(
int nUid,
129 return m_regex.IsValid();
170 static const int FIRST = 0;
171 static const int NOT_REG = -1;
197 return RegisterGenerator(strRegEx.c_str(), fnAppGen, pAppArg);
200 int RegisterGenerator(
const char *sRegEx,
204 void UnregisterGenerator(
int nUid);
220 return readline(sPrompt);
222 retrun fReadLine(stdin, sPrompt);
223 #endif // HAVE_READLINE 226 static char *fReadLine(FILE *fp,
const char *sPrompt);
228 void AddToHistory(
const char *sInput);
248 return rl_filename_completion_function(sText, nState);
251 #endif // HAVE_READLINE 267 return rl_username_completion_function(sText, nState);
270 #endif // HAVE_READLINE 290 static char *dupstr(
const char *s);
292 static string strip(
string &str);
294 static char *strip(
char *s);
304 static string c14n(
const string &str,
size_t nLen)
309 static string c14n(
const char *s,
size_t nLen);
311 static int tokenize(
char *s,
char *tokv[],
size_t tokmax);
320 static int wc(
const string &str)
325 static int wc(
const char *s);
340 static char **CompletionWrap(
const char *sText,
int nStart,
int nEnd);
342 char **Completion(
const char *sText,
int nStart,
int nEnd);
344 static char *GeneratorWrap(
const char *sText,
int nState);
346 void MatchGenerator(
int nEnd);
350 #endif // _DYNASHELL_READLINE_H int RegisterGenerator(const string strRegEx, ReadLineAppGenFunc_T fnAppGen, void *pAppArg)
Register application-specific tab-completion generator associated.
RegEx m_regex
applicatin matching regular expression
int GetUid()
Get the unique id associated with this entry.
VecAppEntry::iterator m_posMatched
matched entry position
static string c14n(const string &str, size_t nLen)
Canonicalization of a string.
ReadLineAppGenFunc_T m_fnAppGen
application-specific generator
VecAppEntry m_vecGenerators
map of generators
static char * dupstr(const string &str)
Duplicate string.
static ReadLine * ReadLineThis
static pointer this single instance
char *(* ReadLineAppGenFunc_T)(int nUid, const char *sText, size_t uTextLen, int nState, const char *sContext, void *pAppArg)
Application-specific tab completion generator function type.
static int wc(const string &str)
Count the words in the string.
size_t m_uTextLen
text length of text to generator
int m_nUidCounter
unique id counter
ReadLine class provides a c++ wrapper around the readline c library.
char * m_sName
readline name
void * m_pAppArg
application-specific argument
bool IsValid()
Check if entry is valid.
char * iReadLine(const char *sPrompt)
Interactively read a line of input from standard input.
vector< ReadLineEntry > VecAppEntry
Internal registered generator map type.
The Dynamixel Shell Regular Expression Class.
string m_strContext
current readline buffer context
static char * FileCompletionGenerator(const char *sText, int nState)
File name tab completion generator.
static char * UserCompletionGenerator(const char *sText, int nState)
User name tab completion generator.