|
|
@ -711,6 +711,30 @@ impl EditorView {
|
|
|
|
event: KeyEvent,
|
|
|
|
event: KeyEvent,
|
|
|
|
) -> Option<KeymapResult> {
|
|
|
|
) -> Option<KeymapResult> {
|
|
|
|
self.autoinfo = None;
|
|
|
|
self.autoinfo = None;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if cxt.editor.variables.is_some() {
|
|
|
|
|
|
|
|
match event {
|
|
|
|
|
|
|
|
KeyEvent {
|
|
|
|
|
|
|
|
code: KeyCode::Char('h'),
|
|
|
|
|
|
|
|
..
|
|
|
|
|
|
|
|
} => {
|
|
|
|
|
|
|
|
cxt.editor.variables_page = cxt.editor.variables_page.saturating_sub(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyEvent {
|
|
|
|
|
|
|
|
code: KeyCode::Char('l'),
|
|
|
|
|
|
|
|
..
|
|
|
|
|
|
|
|
} => {
|
|
|
|
|
|
|
|
cxt.editor.variables_page = cxt.editor.variables_page.saturating_add(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
KeyEvent {
|
|
|
|
|
|
|
|
code: KeyCode::Esc, ..
|
|
|
|
|
|
|
|
} => {
|
|
|
|
|
|
|
|
cxt.editor.variables = None;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return None;
|
|
|
|
|
|
|
|
}
|
|
|
|
match self.keymaps.get_mut(&mode).unwrap().get(event) {
|
|
|
|
match self.keymaps.get_mut(&mode).unwrap().get(event) {
|
|
|
|
KeymapResult::Matched(command) => command.execute(cxt),
|
|
|
|
KeymapResult::Matched(command) => command.execute(cxt),
|
|
|
|
KeymapResult::Pending(node) => self.autoinfo = Some(node.into()),
|
|
|
|
KeymapResult::Pending(node) => self.autoinfo = Some(node.into()),
|
|
|
@ -1084,6 +1108,35 @@ impl Component for EditorView {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(ref vars) = cx.editor.variables {
|
|
|
|
|
|
|
|
let mut text = String::new();
|
|
|
|
|
|
|
|
let mut height = 0;
|
|
|
|
|
|
|
|
let mut max_len = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let per_page = 15;
|
|
|
|
|
|
|
|
let num_vars = vars.len();
|
|
|
|
|
|
|
|
let start = (per_page * cx.editor.variables_page).min(num_vars);
|
|
|
|
|
|
|
|
let end = (start + per_page).min(num_vars);
|
|
|
|
|
|
|
|
for line in vars[start..end].to_vec() {
|
|
|
|
|
|
|
|
max_len = max_len.max(line.len() as u16);
|
|
|
|
|
|
|
|
height += 1;
|
|
|
|
|
|
|
|
text.push_str(&line);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if vars.len() > per_page {
|
|
|
|
|
|
|
|
text += "\nMove h, l";
|
|
|
|
|
|
|
|
height += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut info = Info {
|
|
|
|
|
|
|
|
height: 20.min(height + 2),
|
|
|
|
|
|
|
|
width: 70.min(max_len),
|
|
|
|
|
|
|
|
title: format!("{} variables", num_vars),
|
|
|
|
|
|
|
|
text: text + "\nExit Esc",
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
info.render(area, surface, cx);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(ref mut info) = self.autoinfo {
|
|
|
|
if let Some(ref mut info) = self.autoinfo {
|
|
|
|
info.render(area, surface, cx);
|
|
|
|
info.render(area, surface, cx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|