Lightweight command console renderer for mxvk::VK_Window. More...
#include <mxvk/include/mxvk/mxvk_console.hpp>
Public Types | |
| using | CommandCallback |
Public Member Functions | |
| void | attach (VK_Window &window, const std::string &fontPath, int fontSize=18) |
| Attach this console to a window and configure console font rendering. | |
| void | clear () |
| Clear all buffered output lines. | |
| void | draw () |
| Draw the current console overlay. | |
| void | handleEvent (const SDL_Event &event) |
| Handle keyboard/text events for the console. | |
| void | hide () noexcept |
| Hide console. | |
| const std::string & | inputBuffer () const noexcept |
| void | invalidateLayoutCache () |
| Recompute cached line wrapping after font or layout metrics change. | |
| bool | isVisible () const noexcept |
| void | printLine (const std::string &line, SDL_Color color=SDL_Color{255, 255, 255, 255}) |
| Append one line to console output. | |
| void | setCommandCallback (CommandCallback callback) |
| Register a command callback. | |
| void | setFont (const std::string &fontPath, int fontSize) |
| Change only the console font, leaving the window default font unchanged. | |
| void | setMaxLines (std::size_t maxLines) |
| Set max number of retained output lines. | |
| void | setMaxVisibleLines (std::size_t maxVisibleLines) |
| Set max number of lines rendered on screen. | |
| void | setPrompt (const std::string &prompt) |
| Set the input prompt text. | |
| void | setSpriteYOriginTopLeft (bool enabled) noexcept |
| Select whether console sprite elements use top-left Y coordinates. | |
| void | setVisible (bool value) noexcept |
| Show or hide the console. | |
| void | show () noexcept |
| Show console. | |
| void | toggle () noexcept |
| Toggle console visibility. | |
| VK_Console ()=default | |
Lightweight command console renderer for mxvk::VK_Window.
The console captures keyboard input, keeps command history, renders buffered lines via VK_Window::printText, and allows applications to register a command callback.
Definition at line 32 of file mxvk_console.hpp.
Definition at line 34 of file mxvk_console.hpp.
|
default |
| void mxvk::VK_Console::attach | ( | VK_Window & | window, |
| const std::string & | fontPath, | ||
| int | fontSize = 18 ) |
Attach this console to a window and configure console font rendering.
Definition at line 18 of file mxvk_console.cpp.
| void mxvk::VK_Console::clear | ( | ) |
Clear all buffered output lines.
Definition at line 148 of file mxvk_console.cpp.
| void mxvk::VK_Console::draw | ( | ) |
Draw the current console overlay.
Call once per frame from proc().
Definition at line 741 of file mxvk_console.cpp.
| void mxvk::VK_Console::handleEvent | ( | const SDL_Event & | event | ) |
Handle keyboard/text events for the console.
Definition at line 626 of file mxvk_console.cpp.
|
noexcept |
Hide console.
Definition at line 84 of file mxvk_console.cpp.
|
nodiscardnoexcept |
Definition at line 116 of file mxvk_console.cpp.
| void mxvk::VK_Console::invalidateLayoutCache | ( | ) |
Recompute cached line wrapping after font or layout metrics change.
Definition at line 111 of file mxvk_console.cpp.
|
nodiscardnoexcept |
Definition at line 96 of file mxvk_console.cpp.
| void mxvk::VK_Console::printLine | ( | const std::string & | line, |
| SDL_Color | color = SDL_Color{255, 255, 255, 255} ) |
Append one line to console output.
| line | Text to append. Embedded newlines are split into separate lines. |
| color | Optional text color for this output line. Defaults to white. |
Definition at line 120 of file mxvk_console.cpp.
| void mxvk::VK_Console::setCommandCallback | ( | CommandCallback | callback | ) |
Register a command callback.
Return true to indicate the command was handled.
Definition at line 46 of file mxvk_console.cpp.
| void mxvk::VK_Console::setFont | ( | const std::string & | fontPath, |
| int | fontSize ) |
Change only the console font, leaving the window default font unchanged.
Definition at line 40 of file mxvk_console.cpp.
| void mxvk::VK_Console::setMaxLines | ( | std::size_t | maxLines | ) |
Set max number of retained output lines.
Definition at line 100 of file mxvk_console.cpp.
| void mxvk::VK_Console::setMaxVisibleLines | ( | std::size_t | maxVisibleLines | ) |
Set max number of lines rendered on screen.
Definition at line 107 of file mxvk_console.cpp.
| void mxvk::VK_Console::setPrompt | ( | const std::string & | prompt | ) |
Set the input prompt text.
Definition at line 50 of file mxvk_console.cpp.
|
inlinenoexcept |
Select whether console sprite elements use top-left Y coordinates.
Definition at line 92 of file mxvk_console.hpp.
|
noexcept |
Show or hide the console.
Definition at line 56 of file mxvk_console.cpp.
|
noexcept |
|
noexcept |
Toggle console visibility.
Definition at line 88 of file mxvk_console.cpp.