summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index 3527410..adaa058 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -194,27 +194,30 @@ fn handle_key(key: Key, st: &mut State) -> Option<bool> {
// Command
Key::Char(c) | Key::Alt(c) => {
- let mut delay_lf = 0;
- if st.input_buffer.len() != 0 {
- match st.input_buffer.parse::<Entry>() {
- Ok(val) => {
- st.stk.push(val);
- print!("{}\r{}{}",
- termion::clear::CurrentLine, " ".repeat(PROMPT_STR.len()),
- val);
- st.input_buffer.clear();
- st.input_cursor = 0;
- if st.entries_drawn < st.term_height - 1 {
- st.entries_drawn += 1;
- }
- delay_lf = 1;
- }
- Err(_) => return None,
- }
- }
-
let name = String::from(c.to_string());
if let Some(&(nargs, ref f)) = st.command_map.get(&name) {
+ let delay_lf;
+ if st.input_buffer.len() != 0 {
+ match st.input_buffer.parse::<Entry>() {
+ Ok(val) => {
+ st.stk.push(val);
+ print!("{}\r{}{}",
+ termion::clear::CurrentLine,
+ " ".repeat(PROMPT_STR.len()),
+ val);
+ st.input_buffer.clear();
+ st.input_cursor = 0;
+ if st.entries_drawn < st.term_height - 1 {
+ st.entries_drawn += 1;
+ }
+ delay_lf = 1;
+ }
+ Err(_) => return None,
+ }
+ } else {
+ delay_lf = 0;
+ }
+
if st.stk.len() < nargs {
return None;
}