TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
tmk::app::tui::Model Class Reference

#include <app/tui.hpp>

Public Types

using Check = std::function<std::string(const std::vector<std::string>&)>
 Says what is wrong with a list of arguments (the command line's own parser); empty if nothing is.

Public Member Functions

 Model (std::string command, std::vector< Field > fields, Check check={})
Action press (int k)
 One key.
std::vector< Line > render (int rows, int cols) const
 The screen as rows lines of at most cols characters.
std::vector< std::string > args () const
 the chosen arguments: positionals first, then options in list order
std::string command_line () const
 the command with those arguments, quoted for a shell
std::string config_text (Scope s) const
 The options file of a scope: one name = value per line, as route --config reads it.
std::string config_text () const
std::vector< std::string > load_config (const std::string &text, Scope s=Scope::file)
 Takes the values of such a file into a scope; returns one message per line it could not use.
void enable_scope (Scope s, std::string path, bool exists)
 Makes a scope available as a place to keep options: path is its file, exists whether that file is there.
void disable_scope (Scope s)
Scope target () const
 The scope that edits go to and that s saves; Tab moves it.
void set_target (Scope s)
bool dirty (Scope s) const
void mark_saved ()
 Records that the target scope's file was written.
bool set (const std::string &name, const std::string &value)
 Sets a field by its label or its argument spelling (e.g. "board", "--output"); false if there is none.
const std::string & save_path () const
 The file of the target scope.
void set_save_path (std::string p)
void set_status (std::string s)
const std::string & status () const
const std::string & error () const
const std::vector< Field > & fields () const

Detailed Description

Definition at line 77 of file tui.hpp.

Member Typedef Documentation

◆ Check

using tmk::app::tui::Model::Check = std::function<std::string(const std::vector<std::string>&)>

Says what is wrong with a list of arguments (the command line's own parser); empty if nothing is.

Definition at line 80 of file tui.hpp.

Constructor & Destructor Documentation

◆ Model()

tmk::app::tui::Model::Model ( std::string command,
std::vector< Field > fields,
Check check = {} )

Member Function Documentation

◆ args()

std::vector< std::string > tmk::app::tui::Model::args ( ) const

the chosen arguments: positionals first, then options in list order

◆ command_line()

std::string tmk::app::tui::Model::command_line ( ) const

the command with those arguments, quoted for a shell

◆ config_text() [1/2]

std::string tmk::app::tui::Model::config_text ( ) const
inline

Definition at line 96 of file tui.hpp.

◆ config_text() [2/2]

std::string tmk::app::tui::Model::config_text ( Scope s) const

The options file of a scope: one name = value per line, as route --config reads it.

Only the values that belong to that scope are written; what a lower or higher scope sets stays in its own file.

◆ dirty()

bool tmk::app::tui::Model::dirty ( Scope s) const
inline

Definition at line 107 of file tui.hpp.

◆ disable_scope()

void tmk::app::tui::Model::disable_scope ( Scope s)

◆ enable_scope()

void tmk::app::tui::Model::enable_scope ( Scope s,
std::string path,
bool exists )

Makes a scope available as a place to keep options: path is its file, exists whether that file is there.

file is available from the start (the –config file); the caller enables global and project.

◆ error()

const std::string & tmk::app::tui::Model::error ( ) const
inline

Definition at line 119 of file tui.hpp.

◆ fields()

const std::vector< Field > & tmk::app::tui::Model::fields ( ) const
inline

Definition at line 120 of file tui.hpp.

◆ load_config()

std::vector< std::string > tmk::app::tui::Model::load_config ( const std::string & text,
Scope s = Scope::file )

Takes the values of such a file into a scope; returns one message per line it could not use.

◆ mark_saved()

void tmk::app::tui::Model::mark_saved ( )

Records that the target scope's file was written.

◆ press()

Action tmk::app::tui::Model::press ( int k)

One key.

save asks the caller to write config_text() to save_path(); run is only returned when the check passes.

◆ render()

std::vector< Line > tmk::app::tui::Model::render ( int rows,
int cols ) const

The screen as rows lines of at most cols characters.

◆ save_path()

const std::string & tmk::app::tui::Model::save_path ( ) const
inline

The file of the target scope.

Definition at line 115 of file tui.hpp.

◆ set()

bool tmk::app::tui::Model::set ( const std::string & name,
const std::string & value )

Sets a field by its label or its argument spelling (e.g. "board", "--output"); false if there is none.

◆ set_save_path()

void tmk::app::tui::Model::set_save_path ( std::string p)
inline

Definition at line 116 of file tui.hpp.

◆ set_status()

void tmk::app::tui::Model::set_status ( std::string s)
inline

Definition at line 117 of file tui.hpp.

◆ set_target()

void tmk::app::tui::Model::set_target ( Scope s)

◆ status()

const std::string & tmk::app::tui::Model::status ( ) const
inline

Definition at line 118 of file tui.hpp.

◆ target()

Scope tmk::app::tui::Model::target ( ) const
inline

The scope that edits go to and that s saves; Tab moves it.

Definition at line 105 of file tui.hpp.


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