libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
TuiApplication Class Reference

Application class for TUI programs. More...

#include <application.h>

Inheritance diagram for TuiApplication:
Collaboration diagram for TuiApplication:

Public Member Functions

 TuiApplication (int argc, char **argv)
 Constructs a TuiApplication.
 
 ~TuiApplication ()
 Destructor. Restores terminal state.
 
 TuiApplication (const TuiApplication &)=delete
 
TuiApplicationoperator= (const TuiApplication &)=delete
 
void setRootWidget (TuiWidget *widget)
 Sets the top-level (root) widget.
 
TuiWidgetrootWidget () const
 Returns the root widget.
 
TuiScreenscreen ()
 Returns the screen.
 
Terminalterminal ()
 Returns the terminal.
 
const TuiPalettepalette () const
 Returns the palette.
 
TuiPalettepalette ()
 Returns the palette for modification.
 
void setPalette (const TuiPalette &palette)
 Sets the palette.
 
int exec ()
 Runs the TUI application event loop.
 
void quit (int exitCode=0)
 Requests the application to quit.
 
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.
 
- Public Member Functions inherited from Application
 Application (int argc, char **argv)
 Constructs and registers an Application instance.
 
 ~Application ()
 Destroys the Application and clears the current instance.
 
 Application (const Application &)=delete
 
 Application (Application &&)=delete
 
Applicationoperator= (const Application &)=delete
 
Applicationoperator= (Application &&)=delete
 

Static Public Member Functions

static TuiApplicationinstance ()
 Returns the TuiApplication instance.
 
- Static Public Member Functions inherited from Application
static const StringListarguments ()
 Returns the command-line arguments.
 
static const UUIDappUUID ()
 Returns the application UUID used as a namespace for UUID v3/v5 generation.
 
static void setAppUUID (const UUID &uuid)
 Sets the application UUID used as a namespace for UUID v3/v5 generation.
 
static const StringappName ()
 Returns the application name used for UUID v3/v5 generation.
 
static void setAppName (const String &name)
 Sets the application name used for UUID v3/v5 generation.
 
static ThreadmainThread ()
 Returns the Thread object for the main (application) thread.
 
static EventLoopmainEventLoop ()
 Returns the EventLoop for the main thread.
 
static IODevicestdinDevice ()
 Returns an IODevice wrapping C stdin.
 
static IODevicestdoutDevice ()
 Returns an IODevice wrapping C stdout.
 
static IODevicestderrDevice ()
 Returns an IODevice wrapping C stderr.
 

Detailed Description

Application class for TUI programs.

Derives from Application and manages the Terminal, TuiScreen, and input parsing. Provides the main event loop integration for TUI applications: reads raw input, parses escape sequences, dispatches events to widgets, and flushes the screen.

Constructor & Destructor Documentation

◆ TuiApplication()

TuiApplication::TuiApplication ( int  argc,
char **  argv 
)

Constructs a TuiApplication.

Parameters
argcArgument count from main().
argvArgument vector from main().

Member Function Documentation

◆ colorMode()

Terminal::ColorSupport TuiApplication::colorMode ( ) const
inline

Returns the current color mode.

Returns
The color support level in use.

◆ exec()

int TuiApplication::exec ( )

Runs the TUI application event loop.

Returns
The exit code.

◆ focusNext()

void TuiApplication::focusNext ( bool  reverse = false)

Cycles focus to the next focusable widget.

Parameters
reverseIf true, cycles in reverse order.

◆ grabMouse()

void TuiApplication::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 TuiApplication::markNeedsRepaint ( )

Marks the screen as needing a repaint.

Called internally when widget state changes. The screen is only repainted when this flag is set, avoiding unnecessary work and CPU usage.

◆ quit()

void TuiApplication::quit ( int  exitCode = 0)

Requests the application to quit.

Parameters
exitCodeThe exit code.

◆ setColorMode()

void TuiApplication::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 TuiApplication::setFocusWidget ( TuiWidget widget)

Sets the focused widget.

Parameters
widgetThe widget to focus.

◆ setRootWidget()

void TuiApplication::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: