Character checks, minor cleanup

pull/8/head
Mark 2023-09-22 10:08:28 -07:00
parent ef74b67f90
commit cffb3726cc
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
1 changed files with 19 additions and 9 deletions

View File

@ -68,9 +68,7 @@ cfg_if::cfg_if! {
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);
match r {
@ -78,7 +76,6 @@ cfg_if::cfg_if! {
out += t;
}
}
}
},
"\x7F" => { unsafe { (*state).promptbuffer.backspace(); } },
@ -91,7 +88,20 @@ cfg_if::cfg_if! {
//'\x04' | '\x03'
//=> { 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) };