blob: 0e7c3b2804dd956b659c7dfaf067215f5f4d4281 (
plain)
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
|
use crate::commands::KeyCommand;
use crate::context::JoshutoContext;
use crate::error::JoshutoResult;
use crate::ui::widgets::TuiTextField;
use crate::ui::TuiBackend;
use super::JoshutoRunnable;
pub fn readline(
context: &mut JoshutoContext,
backend: &mut TuiBackend,
prefix: &str,
suffix: &str,
) -> JoshutoResult<()> {
let user_input: Option<String> = TuiTextField::default()
.prompt(":")
.prefix(prefix)
.suffix(suffix)
.get_input(backend, context);
if let Some(s) = user_input {
let trimmed = s.trim_start();
let command = KeyCommand::parse_command(trimmed)?;
command.execute(context, backend)
} else {
Ok(())
}
}
|