cli_text_reader/
lib.rs

1mod bookmarks;
2mod config;
3mod core_state;
4mod core_types;
5mod debug;
6pub mod demo_components;
7mod demo_content;
8pub mod demo_registry;
9pub mod demo_script;
10mod demo_tutorial_test;
11mod editor;
12mod help;
13mod highlights;
14mod highlights_core;
15mod highlights_persistence;
16mod interactive_tutorial;
17mod interactive_tutorial_buffer;
18mod interactive_tutorial_steps;
19mod interactive_tutorial_tests;
20mod interactive_tutorial_utils;
21mod progress;
22mod tutorial;
23mod utils;
24
25use editor::Editor;
26
27pub fn run_cli_text_reader(
28  lines: Vec<String>,
29  col: usize,
30) -> Result<(), Box<dyn std::error::Error>> {
31  run_cli_text_reader_with_demo(lines, col, false)
32}
33
34pub fn run_cli_text_reader_with_demo(
35  lines: Vec<String>,
36  col: usize,
37  demo_mode: bool,
38) -> Result<(), Box<dyn std::error::Error>> {
39  run_cli_text_reader_with_content(lines, col, None, demo_mode)
40}
41
42pub fn run_cli_text_reader_with_content(
43  lines: Vec<String>,
44  col: usize,
45  raw_content: Option<String>,
46  demo_mode: bool,
47) -> Result<(), Box<dyn std::error::Error>> {
48  // Initialize debug logging
49  debug::init_debug_logging()?;
50  debug::debug_log("main", "Starting cli-text-reader");
51  debug::debug_log_state("main", "lines_count", &lines.len().to_string());
52  debug::debug_log_state("main", "col", &col.to_string());
53  debug::debug_log_state("main", "demo_mode", &demo_mode.to_string());
54  if raw_content.is_some() {
55    debug::debug_log("main", "Raw content provided for consistent hashing");
56  }
57
58  let mut editor = if let Some(content) = raw_content {
59    Editor::new_with_content(lines, col, content)
60  } else {
61    Editor::new(lines, col)
62  };
63  editor.tutorial_demo_mode = demo_mode;
64  let result = editor.run();
65
66  debug::debug_log("main", "Editor run completed");
67  debug::flush_debug_log();
68  result
69}
70
71pub fn run_cli_text_reader_with_demo_id(
72  lines: Vec<String>,
73  col: usize,
74  demo_id: usize,
75) -> Result<(), Box<dyn std::error::Error>> {
76  // Initialize debug logging
77  debug::init_debug_logging()?;
78  debug::debug_log("main", "Starting cli-text-reader with demo");
79  debug::debug_log_state("main", "demo_id", &demo_id.to_string());
80  debug::debug_log_state("main", "col", &col.to_string());
81
82  let mut editor = Editor::new(lines, col);
83  editor.tutorial_demo_mode = true;
84  editor.demo_id = Some(demo_id);
85  let result = editor.run();
86
87  debug::debug_log("main", "Editor run completed");
88  debug::flush_debug_log();
89  result
90}