libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
Loading...
Searching...
No Matches
console::Console Class Reference

Core text-console widget backed by an SDL_Surface. More...

#include <console.hpp>

Collaboration diagram for console::Console:
[legend]

Classes

struct  TextLine

Public Member Functions

 Console ()
 ~Console ()
 Console (const Console &)=delete
Console & operator= (const Console &)=delete
 Console (Console &&)=delete
Console & operator= (Console &&)=delete
void create (int x, int y, int w, int h)
 Set position and size of the console rectangle.
void load (const std::string &fnt, int size, const SDL_Color &col)
 Load font and rebuild the glyph cache.
void clear ()
 Clear the output buffer and reset scroll.
void print (const std::string &str)
 Append text to the output buffer.
void thread_safe_print (const std::string &str)
 Append text from any thread (uses the internal message queue).
void keypress (char c)
 Handle a single character key press for the input line.
SDL_Surface * drawText ()
 Render the console contents to an internal SDL_Surface.
std::string getText () const
 Return the current input-line text.
void setText (const std::string &text)
 Replace the input-line text.
size_t getCursorPos () const
void setCursorPos (size_t pos)
 Move the caret to pos within the input line.
void procCmd (const std::string &cmd)
 Tokenise and dispatch a command string.
void setPrompt (const std::string &text)
 Change the prompt prefix (default: "$ ").
void scrollToBottom ()
 Jump the scroll view to the most recent output.
void setCallback (gl::GLWindow *window, std::function< bool(gl::GLWindow *win, const std::vector< std::string > &)> callback)
 Register a command callback invoked when the user presses Enter.
void moveCursorLeft ()
 Move caret one character to the left.
void moveCursorRight ()
 Move caret one character to the right.
void moveCursorHome ()
 Move caret to start of input line.
void moveCursorEnd ()
 Move caret to end of input line.
void moveHistoryUp ()
 Recall the previous command from history.
void moveHistoryDown ()
 Move forward through command history.
void updateInputScrollOffset ()
 Recalculate horizontal scroll for long input lines.
int getHeight () const
int getWidth () const
void startFadeIn ()
 Begin a fade-in animation.
void startFadeOut ()
 Begin a fade-out animation.
bool isFading () const
bool isVisible () const
void show ()
 Make the console fully visible immediately.
void hide ()
 Make the console invisible immediately.
void reload ()
 Reload the glyph cache with the current font settings.
bool loaded () const
bool isScrollDragging () const
void setTextAttrib (const int size, const SDL_Color &col)
 Change font size and colour without reloading the widget.
std::ostringstream & bufferData ()
 Access the internal output buffer directly as an ostream.
void setInputCallback (std::function< int(gl::GLWindow *win, const std::string &)> callback)
 Register a callback for raw input-line submission (Enter key).
void process_message_queue ()
 Process pending messages from the thread-safe print queue (call each frame).
void scrollUp ()
 Scroll output up by one line.
void scrollDown ()
 Scroll output down by one line.
void resetScroll ()
 Reset scroll to the bottom.
void scrollPageUp ()
 Scroll up by one page.
void scrollPageDown ()
 Scroll down by one page.
void handleMouseScroll (int mouseX, int mouseY, int wheelY)
 Handle a mouse-wheel scroll event.
bool isMouseOverScrollbar (int mouseX, int mouseY) const
 Test whether the mouse is over the scrollbar thumb.
void beginScrollDrag (int mouseY)
 Start a scrollbar thumb drag.
void updateScrollDrag (int mouseY)
 Continue a scrollbar thumb drag.
void endScrollDrag ()
 Release the scrollbar thumb.

Public Attributes

mx::mxUtil * util
 Pointer to asset-path utilities (not owned).
std::string promptText = "$ "
 Prompt string displayed before the input line.
Uint32 cursorBlinkTime = 0
 SDL_GetTicks() value of the last cursor blink toggle.
bool cursorVisible = true
 Whether the cursor is currently shown.
gl::GLWindow * window = nullptr
 Owning GL window (weak reference).
std::string inputBuffer
 Current content of the input line (mirrors internal state).
bool needsRedraw = true
 Set to trigger an SDL_Surface redraw.
bool needsReflow = true
 Set to trigger line-wrapping recalculation.
FadeState fadeState = FADE_NONE
 Current fade animation state.

Protected Member Functions

void checkScroll ()
void updateCursorPosition ()
void checkForLineWrap ()
void processMultilineInput (const std::string &cmd)
bool checkBraceBalance (const std::string &text)
void calculateLines ()
void worker_thread_func ()
void clearText ()

Protected Attributes

std::recursive_mutex console_mutex
std::queue< std::string > message_queue
ConsoleChars c_chars
bool userScrolling = false
std::string font
int font_size = 16
SDL_Color color = {255, 255, 255, 255}
std::ostringstream data
std::string input_text
SDL_Surface * surface = nullptr
SDL_Rect console_rect
size_t cursorPos = 0
size_t stopPosition = 0
size_t inputCursorPos = 0
int cursorX = 0
int cursorY = 0
bool showInput = true
std::function< bool(gl::GLWindow *win, const std::vector< std::string > &)> callback = nullptr
std::function< int(gl::GLWindow *window, const std::string &)> callbackEnter = nullptr
bool callbackSet = false
std::vector< std::string > commandHistory
int historyIndex = -1
std::string tempBuffer
unsigned char alpha = 188
Uint32 fadeStartTime = 0
unsigned int fadeDuration = 500
int inputScrollOffset = 0
std::vector< TextLine > lines
bool inMultilineMode
int braceCount
std::string multilineBuffer
std::string originalPrompt
std::string continuationPrompt
std::unique_ptr< std::thread > worker_thread
CommandQueue command_queue
std::atomic< bool > worker_active {true}
bool enterCallbackSet = false
int visibleLineCount = 0
int scrollOffset = 0
bool scrollDragging = false
int scrollDragStartY = 0
int scrollDragStartOffset = 0
SDL_Rect scrollbarRect = {0, 0, 0, 0}

Friends

class GLConsole

Detailed Description

Core text-console widget backed by an SDL_Surface.

Manages an output buffer, an editable input line, command history, optional fade-in/out animation, and a thread-safe message queue. Rendered to an SDL_Surface by drawText(); GLConsole uploads that surface to a GL texture each frame.

Definition at line 154 of file console.hpp.

Constructor & Destructor Documentation

◆ Console() [1/3]

console::Console::Console ( )

◆ ~Console()

console::Console::~Console ( )

Definition at line 125 of file console.cpp.

References clear(), command_queue, surface, worker_active, and worker_thread.

◆ Console() [2/3]

console::Console::Console ( const Console & )
delete

References Console().

◆ Console() [3/3]

console::Console::Console ( Console && )
delete

References Console().

Member Function Documentation

◆ beginScrollDrag()

void console::Console::beginScrollDrag ( int mouseY)

Start a scrollbar thumb drag.

Definition at line 1397 of file console.cpp.

References console_mutex, scrollDragging, scrollDragStartOffset, scrollDragStartY, scrollOffset, and THREAD_GUARD.

◆ bufferData()

std::ostringstream & console::Console::bufferData ( )

Access the internal output buffer directly as an ostream.

Returns
Reference to the internal ostringstream.

Definition at line 916 of file console.cpp.

References data.

◆ calculateLines()

void console::Console::calculateLines ( )
protected

Definition at line 550 of file console.cpp.

References c_chars, console_mutex, console_rect, data, lines, needsReflow, surface, THREAD_GUARD, and visibleLineCount.

Referenced by checkScroll(), and drawText().

◆ checkBraceBalance()

bool console::Console::checkBraceBalance ( const std::string & text)
protected

◆ checkForLineWrap()

void console::Console::checkForLineWrap ( )
protected

Definition at line 424 of file console.cpp.

References c_chars, console_mutex, console_rect, cursorPos, data, and THREAD_GUARD.

◆ checkScroll()

void console::Console::checkScroll ( )
protected

◆ clear()

void console::Console::clear ( )

Clear the output buffer and reset scroll.

Definition at line 171 of file console.cpp.

References c_chars.

Referenced by ~Console().

◆ clearText()

void console::Console::clearText ( )
protected

Definition at line 1049 of file console.cpp.

References console_mutex, data, lines, needsRedraw, needsReflow, and THREAD_GUARD.

◆ create()

void console::Console::create ( int x,
int y,
int w,
int h )

Set position and size of the console rectangle.

Parameters
x,yTop-left corner in pixels.
w,hWidth and height in pixels.

Definition at line 142 of file console.cpp.

References console_rect, and surface.

◆ drawText()

SDL_Surface * console::Console::drawText ( )

◆ endScrollDrag()

void console::Console::endScrollDrag ( )

Release the scrollbar thumb.

Definition at line 1429 of file console.cpp.

References console_mutex, scrollDragging, and THREAD_GUARD.

◆ getCursorPos()

size_t console::Console::getCursorPos ( ) const
Returns
Current caret position within the input line.

◆ getHeight()

int console::Console::getHeight ( ) const
inline
Returns
Pixel height of the console area.

Definition at line 249 of file console.hpp.

References console_rect.

◆ getText()

std::string console::Console::getText ( ) const

Return the current input-line text.

◆ getWidth()

int console::Console::getWidth ( ) const
inline
Returns
Pixel width of the console area.

Definition at line 250 of file console.hpp.

References console_rect.

◆ handleMouseScroll()

void console::Console::handleMouseScroll ( int mouseX,
int mouseY,
int wheelY )

Handle a mouse-wheel scroll event.

Parameters
mouseX,mouseYCursor position.
wheelYScroll delta (positive = up).

Definition at line 1434 of file console.cpp.

References console_mutex, scrollDown(), scrollUp(), and THREAD_GUARD.

◆ hide()

void console::Console::hide ( )

Make the console invisible immediately.

Definition at line 1067 of file console.cpp.

References startFadeOut().

◆ isFading()

bool console::Console::isFading ( ) const
inline
Returns
true while animating.

Definition at line 259 of file console.hpp.

References console::FADE_NONE, and fadeState.

◆ isMouseOverScrollbar()

bool console::Console::isMouseOverScrollbar ( int mouseX,
int mouseY ) const

Test whether the mouse is over the scrollbar thumb.

Returns
true if the cursor is inside the scrollbar rectangle.

Definition at line 1389 of file console.cpp.

References scrollbarRect.

◆ isScrollDragging()

bool console::Console::isScrollDragging ( ) const
inline
Returns
Whether the scrollbar thumb is being dragged.

Definition at line 271 of file console.hpp.

References scrollDragging.

◆ isVisible()

bool console::Console::isVisible ( ) const
inline
Returns
true if at least partially visible.

Definition at line 260 of file console.hpp.

References alpha.

◆ keypress()

void console::Console::keypress ( char c)

Handle a single character key press for the input line.

Parameters
cCharacter received from SDL_TEXTINPUT or SDL_KEYDOWN.

Definition at line 279 of file console.cpp.

References braceCount, console_mutex, inMultilineMode, inputBuffer, inputCursorPos, inputScrollOffset, multilineBuffer, needsRedraw, needsReflow, originalPrompt, procCmd(), process_message_queue(), promptText, scrollOffset, scrollToBottom(), THREAD_GUARD, thread_safe_print(), updateInputScrollOffset(), and userScrolling.

◆ load()

void console::Console::load ( const std::string & fnt,
int size,
const SDL_Color & col )

Load font and rebuild the glyph cache.

Parameters
fntPath to a TTF font file.
sizePoint size.
colGlyph render colour.

Definition at line 163 of file console.cpp.

References c_chars, color, font, font_size, and scrollToBottom().

◆ loaded()

bool console::Console::loaded ( ) const
inline
Returns
true if the glyph cache has been populated.

Definition at line 266 of file console.hpp.

References c_chars, console_mutex, and THREAD_GUARD.

◆ moveCursorEnd()

void console::Console::moveCursorEnd ( )

Move caret to end of input line.

Definition at line 849 of file console.cpp.

References console_mutex, inputBuffer, inputCursorPos, THREAD_GUARD, and updateInputScrollOffset().

◆ moveCursorHome()

void console::Console::moveCursorHome ( )

Move caret to start of input line.

Definition at line 843 of file console.cpp.

References console_mutex, inputCursorPos, THREAD_GUARD, and updateInputScrollOffset().

◆ moveCursorLeft()

void console::Console::moveCursorLeft ( )

Move caret one character to the left.

Definition at line 821 of file console.cpp.

References console_mutex, inputCursorPos, inputScrollOffset, needsRedraw, THREAD_GUARD, and updateInputScrollOffset().

◆ moveCursorRight()

void console::Console::moveCursorRight ( )

Move caret one character to the right.

Definition at line 835 of file console.cpp.

References console_mutex, inputBuffer, inputCursorPos, THREAD_GUARD, and updateInputScrollOffset().

◆ moveHistoryDown()

void console::Console::moveHistoryDown ( )

Move forward through command history.

Definition at line 869 of file console.cpp.

References commandHistory, console_mutex, historyIndex, inputBuffer, inputCursorPos, inputScrollOffset, tempBuffer, THREAD_GUARD, and updateInputScrollOffset().

◆ moveHistoryUp()

void console::Console::moveHistoryUp ( )

Recall the previous command from history.

Definition at line 855 of file console.cpp.

References commandHistory, console_mutex, historyIndex, inputBuffer, inputCursorPos, inputScrollOffset, tempBuffer, THREAD_GUARD, and updateInputScrollOffset().

◆ operator=() [1/2]

Console & console::Console::operator= ( Console && )
delete

References Console().

◆ operator=() [2/2]

Console & console::Console::operator= ( const Console & )
delete

References Console().

◆ print()

void console::Console::print ( const std::string & str)

Append text to the output buffer.

Parameters
strString to append (may contain newlines).

Definition at line 205 of file console.cpp.

References console_mutex, cursorPos, data, needsRedraw, needsReflow, scrollToBottom(), and THREAD_GUARD.

◆ procCmd()

void console::Console::procCmd ( const std::string & cmd)

Tokenise and dispatch a command string.

Parameters
cmdRaw command text (may include arguments).

Definition at line 975 of file console.cpp.

References braceCount, callback, callbackEnter, callbackSet, checkScroll(), command_queue, commandHistory, enterCallbackSet, historyIndex, inMultilineMode, needsReflow, tempBuffer, console::tokenize(), updateCursorPosition(), and window.

Referenced by keypress().

◆ process_message_queue()

void console::Console::process_message_queue ( )

Process pending messages from the thread-safe print queue (call each frame).

Definition at line 952 of file console.cpp.

References console_mutex, data, message_queue, needsRedraw, needsReflow, scrollToBottom(), and THREAD_GUARD.

Referenced by keypress().

◆ processMultilineInput()

void console::Console::processMultilineInput ( const std::string & cmd)
protected

◆ reload()

void console::Console::reload ( )

Reload the glyph cache with the current font settings.

Definition at line 159 of file console.cpp.

References c_chars, color, font, and font_size.

Referenced by setTextAttrib().

◆ resetScroll()

void console::Console::resetScroll ( )

Reset scroll to the bottom.

Definition at line 195 of file console.cpp.

References needsRedraw, scrollOffset, and userScrolling.

◆ scrollDown()

void console::Console::scrollDown ( )

Scroll output down by one line.

Definition at line 186 of file console.cpp.

References console_mutex, needsRedraw, scrollOffset, THREAD_GUARD, and userScrolling.

Referenced by handleMouseScroll().

◆ scrollPageDown()

void console::Console::scrollPageDown ( )

Scroll down by one page.

Definition at line 1382 of file console.cpp.

References console_mutex, needsRedraw, scrollOffset, THREAD_GUARD, and visibleLineCount.

◆ scrollPageUp()

void console::Console::scrollPageUp ( )

Scroll up by one page.

Definition at line 1374 of file console.cpp.

References console_mutex, lines, needsRedraw, scrollOffset, THREAD_GUARD, and visibleLineCount.

◆ scrollToBottom()

void console::Console::scrollToBottom ( )

Jump the scroll view to the most recent output.

Definition at line 810 of file console.cpp.

References checkScroll(), console_mutex, cursorPos, data, inputBuffer, inputCursorPos, needsRedraw, scrollOffset, THREAD_GUARD, updateCursorPosition(), and userScrolling.

Referenced by keypress(), load(), print(), and process_message_queue().

◆ scrollUp()

void console::Console::scrollUp ( )

Scroll output up by one line.

Definition at line 175 of file console.cpp.

References console_mutex, lines, needsRedraw, scrollOffset, THREAD_GUARD, userScrolling, and visibleLineCount.

Referenced by handleMouseScroll().

◆ setCallback()

void console::Console::setCallback ( gl::GLWindow * window,
std::function< bool(gl::GLWindow *win, const std::vector< std::string > &)> callback )

Register a command callback invoked when the user presses Enter.

Parameters
windowParent GL window.
callbackHandler receives tokenised arguments; return true to suppress default handling.

Definition at line 214 of file console.cpp.

References callback, callbackSet, and window.

◆ setCursorPos()

void console::Console::setCursorPos ( size_t pos)

Move the caret to pos within the input line.

◆ setInputCallback()

void console::Console::setInputCallback ( std::function< int(gl::GLWindow *win, const std::string &)> callback)

Register a callback for raw input-line submission (Enter key).

Parameters
callbackHandler receives the raw input string; return value is unused.

Definition at line 969 of file console.cpp.

References callback, callbackEnter, console_mutex, enterCallbackSet, and THREAD_GUARD.

◆ setPrompt()

void console::Console::setPrompt ( const std::string & text)

Change the prompt prefix (default: "$ ").

References callback, and window.

◆ setText()

void console::Console::setText ( const std::string & text)

Replace the input-line text.

◆ setTextAttrib()

void console::Console::setTextAttrib ( const int size,
const SDL_Color & col )

Change font size and colour without reloading the widget.

Parameters
sizeNew point size.
colNew colour.

Definition at line 1071 of file console.cpp.

References color, console_mutex, font_size, reload(), and THREAD_GUARD.

◆ show()

void console::Console::show ( )

Make the console fully visible immediately.

Definition at line 1063 of file console.cpp.

References startFadeIn().

◆ startFadeIn()

void console::Console::startFadeIn ( )

Begin a fade-in animation.

Definition at line 1042 of file console.cpp.

References alpha, console::FADE_IN, fadeStartTime, and fadeState.

Referenced by show().

◆ startFadeOut()

void console::Console::startFadeOut ( )

Begin a fade-out animation.

Definition at line 1058 of file console.cpp.

References console::FADE_OUT, fadeStartTime, and fadeState.

Referenced by hide().

◆ thread_safe_print()

void console::Console::thread_safe_print ( const std::string & str)

Append text from any thread (uses the internal message queue).

Parameters
strString to append.

Definition at line 920 of file console.cpp.

References console_mutex, message_queue, needsRedraw, needsReflow, and THREAD_GUARD.

Referenced by keypress(), and worker_thread_func().

◆ updateCursorPosition()

void console::Console::updateCursorPosition ( )
protected

Definition at line 464 of file console.cpp.

References c_chars, console_mutex, console_rect, cursorPos, cursorX, cursorY, data, surface, and THREAD_GUARD.

Referenced by procCmd(), and scrollToBottom().

◆ updateInputScrollOffset()

void console::Console::updateInputScrollOffset ( )

Recalculate horizontal scroll for long input lines.

Definition at line 219 of file console.cpp.

References c_chars, console_rect, inputBuffer, inputCursorPos, inputScrollOffset, and promptText.

Referenced by keypress(), moveCursorEnd(), moveCursorHome(), moveCursorLeft(), moveCursorRight(), moveHistoryDown(), and moveHistoryUp().

◆ updateScrollDrag()

void console::Console::updateScrollDrag ( int mouseY)

Continue a scrollbar thumb drag.

Definition at line 1404 of file console.cpp.

References console_mutex, lines, needsRedraw, scrollbarRect, scrollDragging, scrollOffset, THREAD_GUARD, and visibleLineCount.

◆ worker_thread_func()

void console::Console::worker_thread_func ( )
protected

◆ GLConsole

friend class GLConsole
friend

Definition at line 164 of file console.hpp.

References GLConsole.

Referenced by GLConsole.

Member Data Documentation

◆ alpha

unsigned char console::Console::alpha = 188
protected

Definition at line 354 of file console.hpp.

Referenced by drawText(), isVisible(), and startFadeIn().

◆ braceCount

int console::Console::braceCount
protected

Definition at line 365 of file console.hpp.

Referenced by Console(), keypress(), and procCmd().

◆ c_chars

ConsoleChars console::Console::c_chars
protected

◆ callback

std::function<bool(gl::GLWindow *win, const std::vector<std::string> &)> console::Console::callback = nullptr
protected

Definition at line 348 of file console.hpp.

Referenced by procCmd(), setCallback(), setInputCallback(), and setPrompt().

◆ callbackEnter

std::function<int(gl::GLWindow *window, const std::string &)> console::Console::callbackEnter = nullptr
protected

Definition at line 349 of file console.hpp.

Referenced by procCmd(), and setInputCallback().

◆ callbackSet

bool console::Console::callbackSet = false
protected

Definition at line 350 of file console.hpp.

Referenced by procCmd(), and setCallback().

◆ color

SDL_Color console::Console::color = {255, 255, 255, 255}
protected

Definition at line 334 of file console.hpp.

Referenced by load(), reload(), and setTextAttrib().

◆ command_queue

CommandQueue console::Console::command_queue
protected

Definition at line 373 of file console.hpp.

Referenced by procCmd(), worker_thread_func(), and ~Console().

◆ commandHistory

std::vector<std::string> console::Console::commandHistory
protected

Definition at line 351 of file console.hpp.

Referenced by moveHistoryDown(), moveHistoryUp(), and procCmd().

◆ console_mutex

◆ console_rect

SDL_Rect console::Console::console_rect
protected

◆ continuationPrompt

std::string console::Console::continuationPrompt
protected

Definition at line 368 of file console.hpp.

◆ cursorBlinkTime

Uint32 console::Console::cursorBlinkTime = 0

SDL_GetTicks() value of the last cursor blink toggle.

Definition at line 253 of file console.hpp.

◆ cursorPos

size_t console::Console::cursorPos = 0
protected

◆ cursorVisible

bool console::Console::cursorVisible = true

Whether the cursor is currently shown.

Definition at line 254 of file console.hpp.

Referenced by drawText().

◆ cursorX

int console::Console::cursorX = 0
protected

Definition at line 342 of file console.hpp.

Referenced by updateCursorPosition().

◆ cursorY

int console::Console::cursorY = 0
protected

Definition at line 343 of file console.hpp.

Referenced by updateCursorPosition().

◆ data

std::ostringstream console::Console::data
protected

◆ enterCallbackSet

bool console::Console::enterCallbackSet = false
protected

Definition at line 376 of file console.hpp.

Referenced by procCmd(), and setInputCallback().

◆ fadeDuration

unsigned int console::Console::fadeDuration = 500
protected

Definition at line 356 of file console.hpp.

Referenced by drawText().

◆ fadeStartTime

Uint32 console::Console::fadeStartTime = 0
protected

Definition at line 355 of file console.hpp.

Referenced by drawText(), startFadeIn(), and startFadeOut().

◆ fadeState

FadeState console::Console::fadeState = FADE_NONE

Current fade animation state.

Definition at line 295 of file console.hpp.

Referenced by drawText(), isFading(), startFadeIn(), and startFadeOut().

◆ font

std::string console::Console::font
protected

Definition at line 332 of file console.hpp.

Referenced by load(), and reload().

◆ font_size

int console::Console::font_size = 16
protected

Definition at line 333 of file console.hpp.

Referenced by load(), reload(), and setTextAttrib().

◆ historyIndex

int console::Console::historyIndex = -1
protected

Definition at line 352 of file console.hpp.

Referenced by moveHistoryDown(), moveHistoryUp(), and procCmd().

◆ inMultilineMode

bool console::Console::inMultilineMode
protected

Definition at line 364 of file console.hpp.

Referenced by Console(), keypress(), and procCmd().

◆ input_text

std::string console::Console::input_text
protected

Definition at line 336 of file console.hpp.

◆ inputBuffer

std::string console::Console::inputBuffer

Current content of the input line (mirrors internal state).

Definition at line 292 of file console.hpp.

Referenced by drawText(), keypress(), moveCursorEnd(), moveCursorRight(), moveHistoryDown(), moveHistoryUp(), scrollToBottom(), and updateInputScrollOffset().

◆ inputCursorPos

size_t console::Console::inputCursorPos = 0
protected

◆ inputScrollOffset

int console::Console::inputScrollOffset = 0
protected

◆ lines

std::vector<TextLine> console::Console::lines
protected

◆ message_queue

std::queue<std::string> console::Console::message_queue
protected

Definition at line 329 of file console.hpp.

Referenced by process_message_queue(), and thread_safe_print().

◆ multilineBuffer

std::string console::Console::multilineBuffer
protected

Definition at line 366 of file console.hpp.

Referenced by Console(), and keypress().

◆ needsRedraw

bool console::Console::needsRedraw = true

◆ needsReflow

bool console::Console::needsReflow = true

Set to trigger line-wrapping recalculation.

Definition at line 294 of file console.hpp.

Referenced by calculateLines(), checkScroll(), clearText(), drawText(), keypress(), print(), procCmd(), process_message_queue(), and thread_safe_print().

◆ originalPrompt

std::string console::Console::originalPrompt
protected

Definition at line 367 of file console.hpp.

Referenced by Console(), and keypress().

◆ promptText

std::string console::Console::promptText = "$ "

Prompt string displayed before the input line.

Definition at line 252 of file console.hpp.

Referenced by drawText(), keypress(), and updateInputScrollOffset().

◆ scrollbarRect

SDL_Rect console::Console::scrollbarRect = {0, 0, 0, 0}
protected

Definition at line 384 of file console.hpp.

Referenced by drawText(), isMouseOverScrollbar(), and updateScrollDrag().

◆ scrollDragging

bool console::Console::scrollDragging = false
protected

Definition at line 381 of file console.hpp.

Referenced by beginScrollDrag(), endScrollDrag(), isScrollDragging(), and updateScrollDrag().

◆ scrollDragStartOffset

int console::Console::scrollDragStartOffset = 0
protected

Definition at line 383 of file console.hpp.

Referenced by beginScrollDrag().

◆ scrollDragStartY

int console::Console::scrollDragStartY = 0
protected

Definition at line 382 of file console.hpp.

Referenced by beginScrollDrag().

◆ scrollOffset

int console::Console::scrollOffset = 0
protected

◆ showInput

bool console::Console::showInput = true
protected

Definition at line 344 of file console.hpp.

◆ stopPosition

size_t console::Console::stopPosition = 0
protected

Definition at line 340 of file console.hpp.

◆ surface

SDL_Surface* console::Console::surface = nullptr
protected

◆ tempBuffer

std::string console::Console::tempBuffer
protected

Definition at line 353 of file console.hpp.

Referenced by moveHistoryDown(), moveHistoryUp(), and procCmd().

◆ userScrolling

bool console::Console::userScrolling = false
protected

Definition at line 331 of file console.hpp.

Referenced by keypress(), resetScroll(), scrollDown(), scrollToBottom(), and scrollUp().

◆ util

mx::mxUtil* console::Console::util

Pointer to asset-path utilities (not owned).

Definition at line 165 of file console.hpp.

◆ visibleLineCount

int console::Console::visibleLineCount = 0
protected

◆ window

gl::GLWindow* console::Console::window = nullptr

Owning GL window (weak reference).

Definition at line 255 of file console.hpp.

Referenced by procCmd(), setCallback(), setPrompt(), and worker_thread_func().

◆ worker_active

std::atomic<bool> console::Console::worker_active {true}
protected

Definition at line 374 of file console.hpp.

Referenced by Console(), worker_thread_func(), and ~Console().

◆ worker_thread

std::unique_ptr<std::thread> console::Console::worker_thread
protected

Definition at line 372 of file console.hpp.

Referenced by Console(), and ~Console().


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