1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! A small, embeddable terminal widget for [`egui`](eframe::egui).
//!
//! It renders an interactive command line — a colored prompt, the text you are
//! typing, a block cursor, and a scrollable backlog of output — and hands each
//! submitted command back to your app as a [`String`](alloc::string::String).
//! What those commands *do* is entirely up to you.
//!
//! The public surface is deliberately tiny:
//!
//! - [`Terminal`] — the widget. Call [`Terminal::show`] every frame.
//! - [`Palette`] — the three colors (`prompt_color`, `record_color`,
//! `cursor_color`).
//! - [`Line`] / [`CellGroup`] — the low-level data model behind the backlog,
//! exposed for advanced use.
//!
//! # Quick start
//!
//! ```no_run
//! use eframe::{
//! App, Frame, NativeOptions, Result as EframeResult,
//! egui::{CentralPanel, Ui, ViewportBuilder},
//! };
//! use egui_simple_term::{Palette, Terminal};
//!
//! struct Repl {
//! term: Terminal,
//! }
//!
//! impl App for Repl {
//! fn ui(&mut self, ui: &mut Ui, _frame: &mut Frame) {
//! // Drive the terminal from a panel; `show` handles input + painting.
//! CentralPanel::no_frame().show(ui, |ui| {
//! if let Some(command) = self.term.show(ui) {
//! // `command` is the text the user typed, without the prompt.
//! self.term.writeln_grid(&format!("unknown command: {command}"));
//! }
//! });
//! }
//! }
//!
//! fn main() -> EframeResult {
//! let options = NativeOptions {
//! viewport: ViewportBuilder::default().with_inner_size([800.0, 600.0]),
//! ..Default::default()
//! };
//! eframe::run_native(
//! "repl",
//! options,
//! Box::new(|_cc| Ok(Box::new(Repl {
//! term: Terminal::new("> ", Palette::default()),
//! }))),
//! )
//! }
//! ```
//!
//! A complete, runnable version lives in `examples/demo.rs` — run it with
//! `cargo run --example demo`.
extern crate alloc;
pub use CellGroup;
pub use Line;
pub use Palette;
pub use Terminal;