mirror of
https://github.com/PaddiM8/kalker.git
synced 2025-06-24 19:51:45 +02:00
Added completion for ceil and floor.
This commit is contained in:
parent
165df6d3f3
commit
9495ab9f6e
@ -90,6 +90,8 @@ impl Helper for RLHelper {}
|
|||||||
const COMPLETION_FUNCS: phf::Map<&'static str, &'static str> = phf::phf_map! {
|
const COMPLETION_FUNCS: phf::Map<&'static str, &'static str> = phf::phf_map! {
|
||||||
"sqrt" => "√",
|
"sqrt" => "√",
|
||||||
"deg" => "°",
|
"deg" => "°",
|
||||||
|
"floor" => "⌊⌋",
|
||||||
|
"ceil" => "⌈⌉",
|
||||||
};
|
};
|
||||||
|
|
||||||
impl Completer for RLHelper {
|
impl Completer for RLHelper {
|
||||||
@ -102,15 +104,19 @@ impl Completer for RLHelper {
|
|||||||
) -> Result<(usize, Vec<Self::Candidate>), ReadlineError> {
|
) -> Result<(usize, Vec<Self::Candidate>), ReadlineError> {
|
||||||
for key in COMPLETION_FUNCS.keys() {
|
for key in COMPLETION_FUNCS.keys() {
|
||||||
if line[..pos].ends_with(key) {
|
if line[..pos].ends_with(key) {
|
||||||
return Ok((
|
let value = *COMPLETION_FUNCS.get(key).unwrap();
|
||||||
pos - key.len(),
|
return Ok((pos - key.len(), vec![value.to_string()]));
|
||||||
vec![String::from(*COMPLETION_FUNCS.get(key).unwrap())],
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok((0, vec![line.to_string()]))
|
Ok((0, vec![line.to_string()]))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn update(&self, line: &mut rustyline::line_buffer::LineBuffer, start: usize, elected: &str) {
|
||||||
|
line.backspace(line.pos() - start);
|
||||||
|
line.insert_str(line.pos(), elected);
|
||||||
|
line.move_forward(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Highlighter for RLHelper {
|
impl Highlighter for RLHelper {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user