| Crates.io | multiline_input |
| lib.rs | multiline_input |
| version | 0.2.0 |
| created_at | 2025-11-15 12:28:48.555103+00 |
| updated_at | 2026-01-21 06:18:20.355279+00 |
| description | Terminal multiline input with rich editing (ENTER to submit, CTRL+ENTER for newline) |
| homepage | |
| repository | https://github.com/Wandalen/wTools |
| max_upload_size | |
| id | 1934302 |
| size | 182,958 |
Terminal multiline input with rich editing capabilities
Responsibility:
In Scope:
Out of Scope:
terminal_wizard crateuse multiline_input::collect;
fn main() {
match collect("Enter your message:") {
Ok(Some(text)) => println!("You entered:\n{}", text),
Ok(None) => println!("Cancelled"),
Err(e) => eprintln!("Error: {}", e),
}
}
| Key | Action |
|---|---|
| ENTER | Submit input and return |
| CTRL+ENTER | Insert newline |
| ESC | Cancel (returns None) |
| CTRL+C | Cancel (returns None) |
| CTRL+D | Submit (alternative to ENTER) |
| Backspace | Delete character before cursor |
| Delete | Delete character at cursor |
| ←/→ | Move cursor left/right |
| ↑/↓ | Move cursor up/down (between lines) |
| Home | Move to start of current line |
| End | Move to end of current line |
| CTRL+Home | Move to start of text |
| CTRL+End | Move to end of text |
use multiline_input::Builder;
let editor = Builder::new()
.prompt("Enter commit message:")
.min_length(10)
.max_length(500)
.show_line_numbers(true)
.show_status(true)
.color(true)
.build();
match editor.collect() {
Ok(Some(msg)) => println!("Commit:\n{}", msg),
Ok(None) => println!("Cancelled"),
Err(e) => eprintln!("Error: {}", e),
}
use multiline_input::Builder;
let editor = Builder::new()
.prompt("Enter message:")
.validator(|text| {
if text.contains("spam") {
Err("Message contains prohibited content".to_string())
} else {
Ok(())
}
})
.build();
match editor.collect() {
Ok(Some(text)) => println!("Valid: {}", text),
Ok(None) => println!("Cancelled"),
Err(e) => eprintln!("Error: {}", e),
}
use multiline_input::Builder;
let editor = Builder::new()
.prompt("Edit TODO:")
.initial_text("- Task 1\n- Task 2\n- Task 3")
.show_line_numbers(true)
.build();
match editor.collect() {
Ok(Some(text)) => println!("Updated:\n{}", text),
Ok(None) => println!("Cancelled"),
Err(e) => eprintln!("Error: {}", e),
}
| Option | Type | Default | Description |
|---|---|---|---|
prompt |
&str |
"" |
Prompt message to display |
allow_empty |
bool |
true |
Allow empty input |
min_length |
Option<usize> |
None |
Minimum text length |
max_length |
Option<usize> |
None |
Maximum text length |
validator |
Fn(&str) -> Result<(), String> |
None |
Custom validation function |
initial_text |
Option<String> |
None |
Pre-filled text |
placeholder |
Option<String> |
None |
Placeholder text when empty |
show_line_numbers |
bool |
false |
Display line numbers |
show_status |
bool |
false |
Display status line (line/col/chars) |
show_char_count |
bool |
false |
Display character count |
color |
bool |
true |
Enable colored output |
See examples/ directory for more usage examples:
basic_usage.rs - Simple input collectionwith_validation.rs - Custom validationwith_config.rs - Full configuration demopre_filled.rs - Edit existing textRun examples:
cargo run --example basic_usage
For complete specification and implementation details, see spec.md.
For API documentation: cargo doc --open
# Run tests
cargo test
# Run with coverage
cargo tarpaulin --out Html
Contributions welcome! Please:
MIT License - see LICENSE for details
Difference: multiline_input focuses specifically on multiline text collection with ENTER to submit and CTRL+ENTER for newlines, optimized for AI assistant integration and commit message editing.