mirror of https://github.com/rm-dr/daisy
Character checks, minor cleanup
parent
ef74b67f90
commit
cffb3726cc
20
src/lib.rs
20
src/lib.rs
|
@ -68,9 +68,7 @@ cfg_if::cfg_if! {
|
||||||
return format!("\r\n{}", daisy_prompt(state));
|
return format!("\r\n{}", daisy_prompt(state));
|
||||||
}
|
}
|
||||||
|
|
||||||
if in_str.trim() == "quit" {
|
|
||||||
return "[quit]".to_string();
|
|
||||||
} else {
|
|
||||||
let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
|
let r = crate::do_string( unsafe { &mut (*state).context }, &in_str);
|
||||||
|
|
||||||
match r {
|
match r {
|
||||||
|
@ -78,7 +76,6 @@ cfg_if::cfg_if! {
|
||||||
out += t;
|
out += t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
|
"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
|
||||||
|
@ -91,7 +88,20 @@ cfg_if::cfg_if! {
|
||||||
//'\x04' | '\x03'
|
//'\x04' | '\x03'
|
||||||
//=> { break 'outer; },
|
//=> { break 'outer; },
|
||||||
|
|
||||||
_ => { unsafe { (*state).promptbuffer.add_char(s.chars().next().unwrap()); } },
|
// Only process sane characters
|
||||||
|
|
||||||
|
_ => {
|
||||||
|
let c = s.chars().next().unwrap();
|
||||||
|
match c {
|
||||||
|
'a'..='z' | 'A'..='Z' | '0'..='9'
|
||||||
|
|'!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'
|
||||||
|
|'?'|'~'|','|'.'|'['|']'
|
||||||
|
|'<'|'>'|'/'|'_'|'-'|':'|'|'|'='|'+'|';'
|
||||||
|
=> { unsafe { (*state).promptbuffer.add_char(c); } },
|
||||||
|
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) };
|
let t = unsafe { (*state).promptbuffer.write_prompt(&mut (*state).context) };
|
||||||
|
|
Loading…
Reference in New Issue