Support Forum G3D Web Page |
Command-line console.
More...
Inherits G3D::Widget.
Classes | |
class | Settings |
class | Text |
Public Types | |
typedef void(* | Callback) (const string &, void *) |
typedef String | string |
To allow later change to std::wstring. More... | |
Public Member Functions | |
virtual | ~GConsole () |
bool | active () const |
virtual Rect2D | bounds () const override |
Inherited from Surface2D. More... | |
void | clearBuffer () |
Clear displayed text. More... | |
void | clearHistory () |
Clear command history. More... | |
virtual float | depth () const override |
Inherited from Surface2D. More... | |
virtual void | fireEvent (const GEvent &event) |
Fire an event on the containing window. More... | |
WidgetManager * | manager () const |
virtual void | onAfterEvents () |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget. More... | |
virtual void | onAI () override |
virtual void | onBeforeGraphics () |
Invoked by WidgetManager immediately before GApp::onGraphics runs. More... | |
virtual bool | onEvent (const GEvent &event) override |
Pass all events to the console. More... | |
virtual void | onNetwork () override |
virtual void | onPose (Array< shared_ptr< Surface > > &surfaceArray, Array< shared_ptr< Surface2D > > &surface2DArray) |
Appends a posed model for this object to the array, if it has a graphic representation. More... | |
virtual void | onPose (Array< shared_ptr< Surface > > &posedArray, Array< shared_ptr< Surface2D >> &posed2DArray) override |
virtual void | onSimulation (RealTime rdt, SimTime sdt, SimTime idt) override |
virtual void | onUserInput (UserInput *ui) override |
void | paste (const string &s) |
Insert the string as if it was typed at the command line. More... | |
virtual float | positionalEventZ (const Point2 &pixel) const |
The camera-space z position that this Widget considers this pixel to be at. More... | |
void | print (const string &s) |
void | printf (const char *fmt,...) |
Print to the buffer. More... | |
void | render (RenderDevice *rd) const override |
Call to render the console. More... | |
void | setActive (bool a) |
void | setCallback (Callback c, void *callbackData=nullptr) |
virtual void | setDepth (float d) |
Called by the WidgetManager. More... | |
virtual void | setManager (WidgetManager *m) |
Called by the WidgetManager when this module is added to it. More... | |
void | vprintf (const char *, va_list argPtr) |
Print to the buffer. More... | |
virtual OSWindow * | window () const |
Returns the operating system window that is currently rendering this Widget. More... | |
Static Public Member Functions | |
static GConsoleRef | create (const shared_ptr< GFont > &f, const Settings &s=Settings(), Callback c=nullptr, void *callbackData=nullptr) |
static void | sort (Array< shared_ptr< Surface2D >> &array) |
Sorts from farthest to nearest. More... | |
static void | sortAndRender (RenderDevice *rd, Array< shared_ptr< Surface2D >> &array) |
Calls sort, RenderDevice::push2D, and then render on all elements. More... | |
Public Attributes | |
Rect2D | m_rect |
Protected Member Functions | |
GConsole (const shared_ptr< GFont > &f, const Settings &s, Callback c, void *callbackData) | |
virtual void | addToCompletionHistory (const string &s) |
Parses the string and adds new tokens to the completion history. More... | |
void | addTokenToCompletionHistory (const string &s) |
Only called from addToCompletionHistory. More... | |
void | beginCompletion () |
Called from processCompletion the first time TAB is pressed. More... | |
void | completeCommand (int direction) |
Invoked from processRepeatKeysym to handle command completion keys. More... | |
void | endCompletion () |
Invoked from processRepeatKeysym when a non-completion key is pressed. More... | |
void | generateFilenameCompletions (Array< string > &fcomplete) |
Called from beginCompletion to append filename and directory-based completions onto fcomplete. More... | |
void | historySelect (int direction) |
Called from repeatKeysym on UP/DOWN. More... | |
void | issueCommand () |
Invoked when the user presses enter. More... | |
virtual void | onCommand (const string &command) |
Invoked when the user presses enter. More... | |
virtual void | print (const string &s, const Color4 &c) |
Issues text to the buffer. More... | |
void | processRepeatKeysym () |
Called from render and onEvent to enact the action triggered by the repeat key. More... | |
void | setRepeatKeysym (GKeySym key) |
Called from onEvent when a key is pressed. More... | |
void | unsetRepeatKeysym () |
Called from onEvent when the repeat key is released. More... | |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Protected Attributes | |
bool | m_active |
True when the console is open and processing events. More... | |
Queue< Text > | m_buffer |
Previously displayed text. More... | |
int | m_bufferShift |
Number of lines before the end of the buffer that are visible (affected by page up/page down). More... | |
Callback | m_callback |
void * | m_callbackData |
Array< string > | m_completionArray |
Filled out by beginCompletion. More... | |
int | m_completionArrayIndex |
Index of the current completion in the m_completionArray. More... | |
string | m_completionBeginStr |
String to prepend onto the current completion list during scrolling. More... | |
string | m_completionEndStr |
String to append onto the current completion list during scrolling. More... | |
Queue< string > | m_completionHistory |
Buffer of identifiers to use for completions. More... | |
Set< string > | m_completionHistorySet |
All the strings that are in m_completionHistory. More... | |
string | m_currentLine |
Currently entered command. More... | |
int | m_cursorPos |
Position of the cursor within m_currentLine (0 is the first slot) More... | |
float | m_depth |
shared_ptr< GFont > | m_font |
Array< string > | m_history |
Previously executed commands. More... | |
int | m_historyIndex |
Current history line being retrieved when using UP/DOWN. More... | |
bool | m_inCompletion |
True when we have already generated a list of potential completions and are now simply scrolling through them. More... | |
RealTime | m_keyDownTime |
Time at which setRepeatKeysym was called. More... | |
RealTime | m_keyRepeatTime |
Time at which the key will repeat (if down). More... | |
WidgetManager * | m_manager |
The manager, set by setManager(). More... | |
GKeySym | m_repeatKeysym |
Key that is currently auto-repeating. More... | |
bool | m_resetHistoryIndexOnEnter |
When true, the history item has been modified since the last UP/DOWN. More... | |
Settings | m_settings |
Command-line console.
When enter is pressed, onCommand is invoked. The default implementation calls the callback function; this allows you to add a command processor either by subclassing GConsole or by passing a function to the constructor.
Beta API
Future versions may support access to the constants for blink rate and key repeat, provide colored fonts and line wrapping.
typedef void(* G3D::GConsole::Callback) (const string &, void *) |
typedef String G3D::GConsole::string |
To allow later change to std::wstring.
|
protected |
|
virtual |
|
inline |
|
protectedvirtual |
Parses the string and adds new tokens to the completion history.
Called from issueCommand and print.
|
protected |
Only called from addToCompletionHistory.
|
protected |
Called from processCompletion the first time TAB is pressed.
|
inlineoverridevirtual |
Inherited from Surface2D.
Reimplemented from G3D::Widget.
void G3D::GConsole::clearBuffer | ( | ) |
Clear displayed text.
void G3D::GConsole::clearHistory | ( | ) |
Clear command history.
|
protected |
Invoked from processRepeatKeysym to handle command completion keys.
|
static |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
|
inlineoverridevirtual |
Inherited from Surface2D.
Controls the depth of objects when rendering. Subclasses may override this but it can interfere with the normal handling of rendering and event delivery. depth = 0 is usually the "top" widget and depth = 1 is usually the "bottom" widget.
Reimplemented from G3D::Widget.
|
protected |
Invoked from processRepeatKeysym when a non-completion key is pressed.
|
virtualinherited |
Fire an event on the containing window.
Reimplemented in G3D::WidgetManager.
Called from beginCompletion to append filename and directory-based completions onto fcomplete.
|
protected |
Called from repeatKeysym on UP/DOWN.
|
protected |
Invoked when the user presses enter.
|
inlineinherited |
|
inlinevirtualinherited |
Invoked after all onEvent handlers for the current frame and before onUserInput for any other Widget.
Reimplemented in G3D::WidgetManager, and G3D::GameController.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
inlinevirtualinherited |
Invoked by WidgetManager immediately before GApp::onGraphics runs.
Reimplemented in G3D::WidgetManager, G3D::CallbackWidget, and G3D::XRWidget.
|
protectedvirtual |
Invoked when the user presses enter.
Default implementation calls m_callback.
|
overridevirtual |
Pass all events to the console.
It returns true if it processed (consumed) the event.
Reimplemented from G3D::Widget.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
inlinevirtualinherited |
Appends a posed model for this object to the array, if it has a graphic representation.
The posed model appended is allowed to reference the agent and is allowed to mutate if the agent is mutated.
Reimplemented in G3D::GuiWindow, G3D::WidgetManager, G3D::Discovery::Client, G3D::SceneEditorWindow, G3D::CallbackWidget, G3D::FullScreenWidget, G3D::UprightSplineManipulator, and G3D::ControlPointEditor.
|
overridevirtual |
Reimplemented from G3D::Widget.
|
overridevirtual |
Reimplemented from G3D::Widget.
void G3D::GConsole::paste | ( | const string & | s | ) |
Insert the string as if it was typed at the command line.
If the string contains newlines they will cause commands to issue.
|
inlinevirtualinherited |
The camera-space z position that this Widget considers this pixel to be at.
Used for positional event (e.g., mouse click) delivery. Higher means closer.
Large negative values are far away. 0 is the closest 3D object. Values greater than zero are used for 2D objects. Returning fnan() [the default] requests the WidgetManager to set hte positionalEventZ to the object's normal event zorder.
See the implementation of ControlPointEditor::positionalEventZ for an example of how to use this with a 3D object.
Reimplemented in G3D::ControlPointEditor.
Issues text to the buffer.
void G3D::GConsole::print | ( | const string & | s | ) |
void G3D::GConsole::printf | ( | const char * | fmt, |
... | |||
) |
Print to the buffer.
|
protected |
Called from render and onEvent to enact the action triggered by the repeat key.
|
overridevirtual |
Call to render the console.
Reimplemented from G3D::Widget.
void G3D::GConsole::setActive | ( | bool | a | ) |
void G3D::GConsole::setCallback | ( | Callback | c, |
void * | callbackData = nullptr |
||
) |
|
inlinevirtualinherited |
Called by the WidgetManager.
This is the depth that the Widget is expected to use when posed as a Surface2D. Subclasses may override or ignore this but it can interfere with the normal handling of rendering.
|
inlinevirtualinherited |
Called by the WidgetManager when this module is added to it.
The argument may be nullptr
Reimplemented in G3D::SceneEditorWindow, G3D::ControlPointEditor, G3D::CameraControlWindow, G3D::GameController, G3D::DeveloperWindow, G3D::ProfilerWindow, G3D::TextureBrowserWindow, and G3D::SettingsWindow.
|
protected |
Called from onEvent when a key is pressed.
Sorts from farthest to nearest.
|
staticinherited |
Calls sort, RenderDevice::push2D, and then render on all elements.
|
protected |
Called from onEvent when the repeat key is released.
void G3D::GConsole::vprintf | ( | const char * | , |
va_list | argPtr | ||
) |
Print to the buffer.
|
virtualinherited |
Returns the operating system window that is currently rendering this Widget.
Reimplemented in G3D::WidgetManager.
Referenced by G3D::FullScreenWidget::bounds().
|
protected |
True when the console is open and processing events.
Referenced by active().
|
protected |
Number of lines before the end of the buffer that are visible (affected by page up/page down).
|
protected |
|
protected |
|
protected |
Index of the current completion in the m_completionArray.
|
protected |
String to prepend onto the current completion list during scrolling.
|
protected |
String to append onto the current completion list during scrolling.
Buffer of identifiers to use for completions.
Updated by print and by issueCommand.
All the strings that are in m_completionHistory.
|
protected |
Currently entered command.
|
mutableprotected |
Position of the cursor within m_currentLine (0 is the first slot)
|
protectedinherited |
Referenced by G3D::Widget::depth(), and G3D::Widget::setDepth().
|
protected |
|
protected |
Current history line being retrieved when using UP/DOWN.
When a history command is used unmodified, the history index sticks. Otherwise it resets to the end of the list on Enter.
|
protected |
True when we have already generated a list of potential completions and are now simply scrolling through them.
|
mutableprotected |
Time at which setRepeatKeysym was called.
|
mutableprotected |
Time at which the key will repeat (if down).
|
protectedinherited |
The manager, set by setManager().
This cannot be a reference counted pointer because that would create a cycle between the Widget and its manager.
Referenced by G3D::Widget::manager(), G3D::GuiWindow::manager(), G3D::Widget::setManager(), and G3D::GuiWindow::setVisible().
|
protected |
Key that is currently auto-repeating.
|
protected |
When true, the history item has been modified since the last UP/DOWN.
|
protected |