MTMS main
Modern Turing Machine Simulator
Loading...
Searching...
No Matches
cli.cpp File Reference

Implementation of the interactive CLI session loops. More...

#include "cli.hpp"
#include <cstdlib>
#include <iostream>
#include <print>
Include dependency graph for cli.cpp:

Go to the source code of this file.

Functions

void clear_viewport ()
 Flushes the active terminal frame using standard ANSI escape codes.
 
void render_dashboard (const TuringMachine &machine, int steps)
 Renders the consolidated simulation status metrics and stacked tapes layout.
 
int run_cli_session (TuringMachine &machine, std::string_view input_word, bool interactive)
 Executes the simulation via the terminal view layer.
 

Detailed Description

Implementation of the interactive CLI session loops.

Author
wh0crypt (wh0cr.nosp@m.ypt@.nosp@m.proto.nosp@m.n.me)
Version
0.1
Date
2026-06-27

Definition in file cli.cpp.

Function Documentation

◆ clear_viewport()

void clear_viewport ( )
inline

Flushes the active terminal frame using standard ANSI escape codes.

Highly performant viewport reset preventing rendering flickering sequences.

Definition at line 23 of file cli.cpp.

Referenced by render_dashboard().

◆ render_dashboard()

void render_dashboard ( const TuringMachine machine,
int  steps 
)

Renders the consolidated simulation status metrics and stacked tapes layout.

Definition at line 28 of file cli.cpp.

References clear_viewport(), TuringMachine::get_current_state(), State::get_label(), and TuringMachine::get_tapes().

Referenced by run_cli_session().

◆ run_cli_session()

int run_cli_session ( TuringMachine machine,
std::string_view  input_word,
bool  interactive 
)

Executes the simulation via the terminal view layer.

Parameters
machineThe initialized Multi-Tape Turing Machine engine instance.
input_wordThe raw string sequence to process.
interactiveIf true, steps interactively. If false, executes instantly (batch mode).
Returns
int Exit status code (EXIT_SUCCESS or EXIT_FAILURE).

Definition at line 53 of file cli.cpp.

References TuringMachine::get_current_state(), State::get_label(), State::is_accept(), TuringMachine::load_input(), render_dashboard(), and TuringMachine::step().

Referenced by main().