FACT++  1.0
ReadlineWindow Class Reference

Helper to redirect readline's in- and output to an ncurses window. More...

#include <ReadlineWindow.h>

+ Inheritance diagram for ReadlineWindow:
+ Collaboration diagram for ReadlineWindow:

Public Member Functions

 ReadlineWindow (const char *prgname)
 
void SetWindow (WINDOW *w)
 
void SetColorPrompt (int col)
 
void RewindCursor () const
 
- Public Member Functions inherited from Readline
 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...
 

Protected Member Functions

void Startup ()
 Color index in which the prompt should be displayed. More...
 
void Redisplay ()
 
void EventHook (bool=false)
 
void CompletionDisplay (char **matches, int num, int max)
 
virtual void Refresh ()
 
void Shutdown (const char *buf)
 
- Protected Member Functions inherited from Readline
virtual int Getc (FILE *)
 The non static implementations of the callback funtions above. 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)
 

Private Attributes

WINDOWfWindow
 
int fPromptX
 Pointer to the panel for the input stream. More...
 
int fPromptY
 When the readline call is issued the x position at which the output will start is stored here. More...
 
int fColor
 When the readline call is issued the y position at which the output will start is stored here. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Readline
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 ReadlineInstance ()
 
static void StaticPushHistory (const std::string &fname)
 
static std::string StaticPrompt (const std::string &prompt)
 
static void StaticPopHistory (const std::string &fname)
 
- Protected Attributes inherited from Readline
const std::vector< std::string > * fCompletion
 Pointer to a list of possible matched for auto-completion. More...
 
- Static Protected Attributes inherited from Readline
static ReadlineThis = 0
 
static std::string fScript
 

Detailed Description

Helper to redirect readline's in- and output to an ncurses window.

The idea of this class is to allow the use of the readline functionality within a ncurses window. Therefore, several callback and hook function of the readline libarary are redirected, which allow to redirect the window's input stream to readline and the readline output to the window.

After instantisation a pointer to a ncurses WINDOW must be given to the object to 'bind' readline to this window.

In addition the color of the readline prompt can be set using the SetPromptColor() member function. Note that the given color must be the index of a COLOR_PAIR. For details on this see the ncurses documentation

If ncurses will use more than one window on the screen it might be necessary to redraw the screen before the cursor is displayed. Therefore, the Refresh() function must be overwritten. It is called before the cursor is put to its final location in the readline line and after all update to the screen was performed.

Refresh() can be used to force a redisplay of the current input line from a derived class. This might be necessary after changes top the screen or window size.

References

Definition at line 8 of file ReadlineWindow.h.


The documentation for this class was generated from the following files: