morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::tui::Frontend Class Referencefinal

Runs a morph application in a terminal, on one thread. More...

#include <frontend.hpp>

Inheritance diagram for morph::tui::Frontend:
morph::ui::Frontend

Public Member Functions

 Frontend (FrontendConfig config={})
std::string_view name () const override
 The name --ui= and MORPH_UI select this frontend by.
int run (ui::AppSource &source) override
 Runs the application the source opens on the calling thread until it quits or the input ends.
Public Member Functions inherited from morph::ui::Frontend
 Frontend (Frontend const &)=delete
Frontend & operator= (Frontend const &)=delete
 Frontend (Frontend &&)=delete
Frontend & operator= (Frontend &&)=delete

Detailed Description

Runs a morph application in a terminal, on one thread.

run builds a caller-driven exec::IoLoop, a LoopExecutor on it (the reactive runtime's owner and every bridge handler's callback executor), the runtime, a core::tui::Screen and a TuiRuntime, then runs the source through ui::runApp: it opens the source, mounts the shell through FrontendConfig::mountShell when the source is ready, and pumps input until AppContext::quit() or the end of input. Sockets, timers, bridge callbacks and input all run on the thread that called run. Tab and Shift+Tab move the focus (inside an open dialog only, while one is open); Esc ends a drag wherever the focus is; Ctrl+C quits; a resize re-fits the view. Each input event is followed by a frame before the next one is handled, and redraws are coalesced to one per loop turn.

Definition at line 58 of file frontend.hpp.

Constructor & Destructor Documentation

◆ Frontend()

morph::tui::Frontend::Frontend ( FrontendConfig config = {})
explicit
Parameters
configThe terminal, the input and the mouse mode; the defaults use the process's terminal.

Member Function Documentation

◆ name()

std::string_view morph::tui::Frontend::name ( ) const
nodiscardoverridevirtual

The name --ui= and MORPH_UI select this frontend by.

Returns
"tui".

Implements morph::ui::Frontend.

◆ run()

int morph::tui::Frontend::run ( ui::AppSource & source)
overridevirtual

Runs the application the source opens on the calling thread until it quits or the input ends.

Parameters
sourceOpened once the runtime exists, and closed before it is destroyed.
Returns
The exit code given to AppContext::quit(); kInterruptExitCode (130) when Ctrl+C ended the run, 0 when the end of input did.
Exceptions
std::runtime_errorwhen the terminal cannot be initialised; std::invalid_argument when FrontendConfig::mountShell is empty; whatever the source or the shell factory throws.

Implements morph::ui::Frontend.


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