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
//! Scott's Own Editor — a built-in TUI text editor for CLI tools.
//!
//! Drop-in fallback editor when no external editor (`$EDITOR`, `$VISUAL`,
//! `core.editor`) is configured. Also usable as a standalone file editor.
//!
//! ```no_run
//! use soe::{edit, EditorMode};
//!
//! // Open with initial content, returns Some(content) on save, None on cancel
//! let result = edit("commit message", "fix: resolve panic on empty input", EditorMode::CommitMessage)?;
//!
//! // Edit a file on disk
//! soe::edit_file(std::path::Path::new("README.md"))?;
//! # Ok::<(), anyhow::Error>(())
//! ```
pub use EditorMode;
/// Open the built-in TUI editor with initial content.
///
/// - `filename` is shown in the UI (doesn't touch disk).
/// - `initial_content` is pre-loaded into the buffer.
/// - `mode` controls wrapping and guide lines.
///
/// Returns `Some(content)` if the user saved, `None` if cancelled.
/// Open the built-in editor for a file on disk.
///
/// Reads the file (or starts empty if it doesn't exist), lets the user
/// edit, and writes it back on save.