FACT++
1.0
|
C++ wrapper for GNU's readline library. More...
#include <Readline.h>
Public Member Functions | |
Readline (const char *prgname) | |
virtual | ~Readline () |
void | BindKeySequence (const char *seq, int(*func)(int, int)) |
virtual bool | PrintGeneralHelp () |
virtual bool | PrintCommands () |
virtual bool | PrintKeyBindings () |
std::string | GetName () const |
void | AddToHistory (const std::string &str, int skip=2) |
std::vector< const char * > | GetHistory () const |
Return a list of pointer to the history contents. More... | |
void | SetMaxSize (int lines) |
void | UpdatePrompt (const std::string &prompt) const |
void | UpdatePrompt () const |
virtual bool | PreProcess (const std::string &str) |
virtual bool | Process (const std::string &str) |
virtual std::string | GetUpdatePrompt () const |
virtual bool | PromptEOF (std::string &str) |
virtual std::string | Prompt (const std::string &prompt) |
virtual void | Run (const char *prompt=0) |
virtual bool | ExecuteShellCommand (const std::string &cmd) |
int | Execute (const std::string &fname, const std::map< std::string, std::string > &args=std::map< std::string, std::string >()) |
bool | IsStopped () const |
void | ProcessLine (const std::string &str) |
void | SetLabel (int l) |
int | GetLine () const |
virtual std::string | GetLinePrompt () const |
int | GetCols () const |
Get the number of cols readline assumes the screen size to be. More... | |
int | GetRows () const |
Get the number of rows readline assumes the screen size to be. More... | |
Static Public Member Functions | |
static bool | RedirectionWrapper (std::ostream &out, bool(*function)()) |
static bool | DumpVariables () |
static bool | DumpFunctions () |
static bool | DumpFunmap () |
static bool | DumpHistory () |
static bool | ClearHistory () |
static void | Stop () |
static void | StopScript () |
static bool | IsScriptStopped () |
static int | GetScriptDepth () |
static void | SetScriptDepth (unsigned int d) |
static void | SetExternalInput (const std::string &inp) |
static std::string | GetScript () |
static std::string | GetExternalInput () |
static char * | Compare (const std::string &str, const std::string &txt) |
static char ** | CompletionMatches (const char *text, char *(*func)(const char *, int)) |
static FILE * | SetStreamOut (FILE *f) |
static FILE * | SetStreamIn (FILE *f) |
static std::string | GetPrompt () |
static std::string | GetBuffer () |
static int | GetAbsCursor () |
return strlen(rl_display_prompt) + rl_point More... | |
static int | GetCursor () |
return rl_point (the current cursor position within the line buffer) More... | |
static int | GetBufferLength () |
static int | GetLineLength () |
return the length of the prompt plus the length of the line buffer More... | |
static void | Resize () |
static void | Resize (int w, int h) |
static Readline * | Instance () |
static void | StaticPushHistory (const std::string &fname) |
static std::string | StaticPrompt (const std::string &prompt) |
static void | StaticPopHistory (const std::string &fname) |
Protected Member Functions | |
virtual int | Getc (FILE *) |
The non static implementations of the callback funtions above. More... | |
virtual void | Startup () |
Default: Do nothing. More... | |
virtual void | EventHook (bool newline=false) |
virtual void | Shutdown (const char *buf) |
virtual void | Redisplay () |
Default: call rl_redisplay() More... | |
virtual void | CompletionDisplay (char **matches, int num, int max) |
Default: call rl_completion_display_matches() More... | |
virtual char * | Complete (const char *text, int state) |
Functions dealing with auto completion. More... | |
virtual char ** | Completion (const char *text, int start, int end) |
void | SetCompletion (const std::vector< std::string > *v) |
char ** | Complete (const std::vector< std::string > &v, const char *text) |
virtual void | SetSection (int) |
virtual void | PrintReadlineError (const std::string &str) |
Protected Attributes | |
const std::vector< std::string > * | fCompletion |
Pointer to a list of possible matched for auto-completion. More... | |
Static Protected Attributes | |
static Readline * | This = 0 |
static std::string | fScript |
Static Private Member Functions | |
static int | rl_ncurses_getc (FILE *) |
Static member function which are used to adapt readline to ncurses. More... | |
static int | rl_ncurses_startup () |
static void | rl_ncurses_redisplay () |
static int | rl_ncurses_event_hook () |
static void | rl_ncurses_completion_display (char **matches, int num, int max) |
static char ** | rl_ncurses_completion_function (const char *text, int start, int end) |
static char * | CompleteImp (const char *text, int state) |
Calls Complete() More... | |
Private Attributes | |
std::string | fName |
int | fMaxLines |
Filename for the history file compiled in the constructor. More... | |
std::ofstream | fCommandLog |
Maximum number of lines in the history file. More... | |
std::string | fLastLine |
int | fLine |
Last line adde to history. More... | |
int | fSection |
int | fLabel |
Static Private Attributes | |
static int | fScriptDepth = 0 |
static bool | fStopScript = false |
static std::string | fExternalInput |
C++ wrapper for GNU's readline library.
This class is meant as a C++ wrapper around GNU's readline library. Note that because readline uses a global namespace only one instance of this class can exist at a time. Instantiating a second object after a first one was deleted might show unexpected results.
When the object is instantiated readline's history is read from a file. At destruction the history in memory is copied back to that file. The history file will be truncated to fMaxLines.
By overloading the Readline class the function used for auto-completion can be overwritten.
Simple example:
Simpler example (you need to implement the Process() function)
Definition at line 10 of file Readline.h.