Crates.io | minime |
lib.rs | minime |
version | 0.2.0 |
source | src |
created_at | 2021-04-08 23:19:00.002861 |
updated_at | 2021-04-13 06:06:17.819971 |
description | Embeddable in-line text editor. |
homepage | https://github.com/Avarel/mini-me |
repository | https://github.com/Avarel/mini-me |
max_upload_size | |
id | 381070 |
size | 62,623 |
An embeddable, customizable, inline text-editor based on crossterm
.
╭─── Input Prompt
1 │ hello there
2 │ this is a simple prompt
3 │ thats multiline and decent enough
4 ┃ _
╰─── Lines: 4 Chars: 70 Ln: 3, Col: 0
minime
can be used as a CLI. The best way to install it is using:
cargo install --features=bin --path .
The binary can be used by invoking minime -h
.
Esc
or Enter
on the last empty line to close and submit the prompt.This is the most basic setup available.
use minime::{editor::keybindings::NormalKeybinding, editor::Editor, Result};
fn main() -> Result<()> {
println!("Write something cool!");
let term = Editor::default();
dbg!(term.read(NormalKeybinding))?;
Ok(())
}
You can lock stdout()
or stderr()
to get better performance. You can also
customize several settings in the renderer.
use minime::{
editor::{keybindings::NormalKeybinding, Editor},
renderer::{
full::CrosstermRenderer,
styles::classic::{ClassicFooter, ClassicGutter, ClassicHeader},
},
Result,
};
fn main() -> Result<()> {
// Redirect our output to stdout (default).
let stdout = std::io::stdout();
let mut lock = stdout.lock();
let renderer = CrosstermRenderer::render_to(&mut lock)
.max_height(Some(10))
.margin(ClassicGutter)
.header(ClassicHeader(
"Enter on the last line or Esc to submit your input!",
))
.footer(ClassicFooter);
// Print out some prompt using styling options.
let term = Editor::with_renderer(renderer);
dbg!(term.read(NormalKeybinding)?);
Ok(())
}