libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
promeki::TuiSubsystem Class Reference

TUI subsystem installed alongside an Application. More...

#include <tuisubsystem.h>

Public Member Functions

 TuiSubsystem ()
 Installs the TUI on the current Application.
 
 ~TuiSubsystem ()
 Destructor. Restores terminal state and releases I/O sources.
 
 TuiSubsystem (const TuiSubsystem &)=delete
 
TuiSubsystemoperator= (const TuiSubsystem &)=delete
 
void setRootWidget (TuiWidget *widget)
 Sets the top-level (root) widget.
 
TuiWidgetrootWidget () const
 Returns the root widget.
 
TuiScreenscreen ()
 Returns the screen.
 
Terminal & terminal ()
 Returns the terminal.
 
const TuiPalettepalette () const
 Returns the palette.
 
TuiPalettepalette ()
 Returns the palette for modification.
 
void setPalette (const TuiPalette &palette)
 Sets the palette.
 
void setColorMode (Terminal::ColorSupport mode)
 Sets the color mode for the TUI screen.
 
Terminal::ColorSupport colorMode () const
 Returns the current color mode.
 
void updateAll ()
 Forces a full screen repaint.
 
void setFocusWidget (TuiWidget *widget)
 Sets the focused widget.
 
TuiWidgetfocusWidget () const
 Returns the currently focused widget.
 
void focusNext (bool reverse=false)
 Cycles focus to the next focusable widget.
 
void markNeedsRepaint ()
 Marks the screen as needing a repaint.
 
void grabMouse (TuiWidget *widget)
 Grabs mouse events for a widget.
 
void releaseMouse ()
 Releases the mouse grab.
 

Static Public Member Functions

static TuiSubsysteminstance ()
 Returns the active TuiSubsystem instance.
 

Detailed Description

TUI subsystem installed alongside an Application.

Owns the Terminal, TuiScreen, palette, input parser, and the event-loop plumbing (STDIN + SIGWINCH self-pipe as EventLoop::addIoSource callbacks) that drive a text UI. Stack- construct one after Application:

int main(int argc, char **argv) {
Application app(argc, argv);
tui.setRootWidget(myRoot);
return app.exec();
}
TUI subsystem installed alongside an Application.
Definition tuisubsystem.h:57
void setRootWidget(TuiWidget *widget)
Sets the top-level (root) widget.

The subsystem resolves its EventLoop from the current Application via Application::mainEventLoop() — no constructor argument is needed. The constructor puts the terminal into raw mode, enables the alternate screen, and installs signal handlers and event sources; the destructor reverses all of that.

Thread Safety
Thread-affine. TuiSubsystem must be constructed, used, and destroyed on the thread that owns the bound EventLoop (typically the main thread). All TUI widgets and their input/paint callbacks are dispatched on the same thread. Cross-thread interaction is supported only through EventLoop::postCallable / ObjectBase signal/slot dispatch.

Constructor & Destructor Documentation

◆ TuiSubsystem()

promeki::TuiSubsystem::TuiSubsystem ( )

Installs the TUI on the current Application.

Requires an Application to have been constructed before this object. Puts the terminal in raw mode and registers STDIN / SIGWINCH as EventLoop I/O sources.

Member Function Documentation

◆ colorMode()

Terminal::ColorSupport promeki::TuiSubsystem::colorMode ( ) const
inline

Returns the current color mode.

Returns
The color support level in use.

◆ focusNext()

void promeki::TuiSubsystem::focusNext ( bool  reverse = false)

Cycles focus to the next focusable widget.

Parameters
reverseIf true, cycles in reverse order.

◆ grabMouse()

void promeki::TuiSubsystem::grabMouse ( TuiWidget widget)
inline

Grabs mouse events for a widget.

While grabbed, all mouse events are sent to the grabbing widget regardless of cursor position.

◆ markNeedsRepaint()

void promeki::TuiSubsystem::markNeedsRepaint ( )

Marks the screen as needing a repaint.

Thread-safe. At most one repaint is pending at any time — repeated calls before the pending paint fires are coalesced, so widgets can call this freely in response to state changes without flooding the event loop.

◆ setColorMode()

void promeki::TuiSubsystem::setColorMode ( Terminal::ColorSupport  mode)
inline

Sets the color mode for the TUI screen.

Changes how RGB colors are converted to ANSI output. The screen will do its best to gracefully degrade colors to the requested mode, but for optimal appearance, provide a TuiPalette whose colors suit the target mode.

Parameters
modeThe color support level to use.
See also
TuiPalette

◆ setFocusWidget()

void promeki::TuiSubsystem::setFocusWidget ( TuiWidget widget)

Sets the focused widget.

Parameters
widgetThe widget to focus.

◆ setRootWidget()

void promeki::TuiSubsystem::setRootWidget ( TuiWidget widget)

Sets the top-level (root) widget.

Parameters
widgetThe root widget to display.

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