Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

CUI_Console Class Reference

A console. More...

#include <CUI_Console.h>

Inheritance diagram for CUI_Console:

CUI_Control CUI_Frame List of all members.

Public Types

typedef bool( cfun )(CUI_Console *con, const char *param)
 cfun's actual function pointer type

enum  cvartype_t { UI_TYPE_INT, UI_TYPE_UINT, UI_TYPE_FLOAT, UI_TYPE_STRING }
 enumeration of acceptable types (note: default is int)


Public Member Functions

 CUI_Console (CUI_UI *ui=NULL, float x=0, float y=0, float x2=1, float y2=1, CUI_Frame *parent=NULL, IUI_Shader *shader=NULL, IUI_Shader *cursor=NULL, CUI_CoordSys *coordsys=NULL, unsigned int m_historyLength=30, const char *prompt="%")
 constructor

virtual ~CUI_Console ()
 destructor

virtual bool SetUI (CUI_UI *ui)
 Set UI - add the textbox and scrollbars to the ui.

virtual bool ProcessKey (unsigned long key)
 Process a incoming key.

virtual bool CallbackFunc (int id, int numparam, void *param)
 Wrapper to m_callbackFunc to check for NULL and present a simple interface.

virtual bool AddCvar (const char *name, cvartype_t type, void *data)
 Add a console variable.

virtual bool AddCfun (const char *name, cfun *function)
 Add a console function.

virtual bool DeleteCfun (const char *name)
 delete a console function

virtual bool Exec (char *name, char *param)
 Execute a parsed line.

virtual bool ExecLine (const char *line)
 Parse and Execute a line.

virtual bool ExecFun (CUI_ConsoleFun *cfun, char *param)
 Execute a command.

virtual bool ExecAlias (const char *param)
 Execute an alias.

virtual bool ExecBuffer (char *buffer)
 Execuate a series of commands in a buffer.

virtual bool Complete ()
 Command completion.

virtual bool SetPrompt (const char *prompt)
 Set the prompt string.

virtual bool Echo (const char *string)
virtual bool PrintCvarList ()
 Print a list of available cvars.

virtual bool PrintCfunList ()
 Print a list of available cfuns.

virtual bool Alias (const char *name, const char *string)
 Alias a string to another string.

virtual CUI_TextFieldGetTextField ()
 Get pointer to the text field object.

virtual bool SetHistoryLength (unsigned int length)
 Set the maximum command history length.

virtual bool SetFieldWidth (unsigned short width)
 Set field width.

virtual bool SetFont (IUI_Font *font)
 set the font for the textbox

virtual bool SetScrollShader (IUI_Shader *shader)
 Set the scrollbar shader.

virtual bool SetSliderShader (IUI_Shader *shader)
 Set the actual slider's shader.

virtual bool SetTextBoxSize (int columns, int rows)
 set the textbox viewable size

virtual bool SetWordWrap (bool wordwrap)
 enable/disable word wrap on the text

virtual bool SetFieldHeight (float height)
 Set textfield height (in current space).

virtual bool CatText (const char *text)
 concatenate some text into the textbox


Protected Types

typedef std::map< std::string,
CUI_ConsoleVar *, std::less<
std::string > > 
CVARMAP
 type - STL map of cvars

typedef std::map< std::string,
CUI_ConsoleFun *, std::less<
std::string > > 
CFUNMAP
 type - STL map of cfuns

typedef std::map< std::string,
std::string, std::less< std::string > > 
CALIASMAP
 type - STL map of aliases (name, alias string)

typedef std::list< std::string > HISTORYLIST
 type - STL list of command history


Protected Attributes

CUI_TextFieldm_textField
 The textfield object.

CUI_ScrollableTextBoxm_textBox
 The scrollable textbox object.

char * m_prompt
 string to use as the prompt

unsigned m_promptLength
 length of the prompt

unsigned int m_historyLength
 maximum number of commands to keep in the history

CVARMAP m_cvarMap
 map of cvars

CFUNMAP m_cfunMap
 map of cfuns

CALIASMAP m_caliasMap
 map of aliases

HISTORYLIST m_historyList
 list of command history

unsigned int m_historyPosition
 current history list position


Detailed Description

A console.

CUI_Console is a TextField for inputting commands and a ScrollableTextBox for displaying history and general output.

CUI_Console keeps track of variables (cvar) and functions (cfun). These are hashed with STL maps. The CUI_ConsoleVar and CUI_ConsoleFun classes are not exported in the DLL and are for internal purposes only.

cvars and cfuns can NOT be described in the GUI xml file. They must be added by the application as they require variable and function pointers to initialize and work.

In the event that a cvar and cfun have the same name, the cfun will always have precedence.

Recognized flags:
[system]
UI_CLICKED
UI_HOVER
UI_SELECTED

UI_DISABLED
UI_INACTIVE


Member Function Documentation

bool CUI_Console::Alias const char *  name,
const char *  string
[virtual]
 

Alias a string to another string.

If it's already in the aliaslist, it is replaced.

Alias with a null string deletes the alias from the list.

bool CUI_Console::CallbackFunc int  id,
int  numparam,
void *  param
[virtual]
 

Wrapper to m_callbackFunc to check for NULL and present a simple interface.

Returns:
false if the global callback needs to be called as well

Reimplemented from CUI_Frame.

bool CUI_Console::Complete  )  [virtual]
 

Command completion.

pattered after the behavior of the *nix shell 'bash'

TODO: currently checks every cfun/cvar by hand. Need to rewrite it to use STL::map more efficiently.

bool CUI_Console::Echo const char *  string  )  [virtual]
 

Automatically appends a newline after the string

bool CUI_Console::Exec char *  name,
char *  param
[virtual]
 

Execute a parsed line.

Determine whether it is a cvar or cfun

bool CUI_Console::ExecBuffer char *  buffer  )  [virtual]
 

Execuate a series of commands in a buffer.

Commands should be seperated by newlines. Used for parsing file input. Load it into a buffer and pass it to this function

bool CUI_Console::ProcessKey unsigned long  key  )  [virtual]
 

Process a incoming key.

Everything except 'enter' gets passed to the textbox

Reimplemented from CUI_Frame.


Member Data Documentation

unsigned int CUI_Console::m_historyPosition [protected]
 

current history list position

moves with up/down arrows. Reset when a command is executed

char* CUI_Console::m_prompt [protected]
 

string to use as the prompt

no parsing stuff yet, just a plain string


The documentation for this class was generated from the following files:
Generated on Mon Sep 29 23:07:03 2003 for glGUI by doxygen 1.3.4