Skip to main content

rl_lang/repl/
mod.rs

1//! TUI REPL for rl, built on [`ratatui`] and [`crossterm`].
2//!
3//! # Layout
4//!
5//! ```text
6//! |---------------------------------|
7//! |  output area  (scrollable)      |
8//! |  >> dec int x = 10              |
9//! |  >> x + 1                       |
10//! |  11                             |
11//! |---------------------------------|
12//! |  >> _  (input bar)              |
13//! |---------------------------------|
14//! ```
15//!
16//! # Key bindings
17//!
18//! | Key            | Action                        |
19//! |----------------|-------------------------------|
20//! | `Enter`        | Submit / continue multiline   |
21//! | `Ctrl+C`       | Exit                          |
22//! | `Esc`          | Cancel multiline input        |
23//! | `↑` / `↓`     | History navigation            |
24//! | `Shift+↑/↓`   | Scroll output                 |
25//! | `Ctrl+←/→`    | Word jump                     |
26//! | `Home` / `End` | Line start / end              |
27
28mod command_handler;
29mod depth_checker;
30mod input_eval;
31mod lines_types;
32mod logic_loop;
33mod output_render;
34mod syntax_highlighting;
35mod utils;
36
37/// Initializes the ratatui terminal, runs the REPL loop, and restores the
38/// terminal on exit. Prints any IO error to stderr.
39pub fn start_repl() {
40    let mut terminal = ratatui::init();
41    let result = logic_loop::run_repl(&mut terminal);
42    ratatui::restore();
43
44    if let Err(e) = result {
45        eprintln!("repl error: {}", e);
46    }
47}