Place Info::from_keymap() contents in keymap.infobox():

This makes it easier later control the order in which the key events
are presented.
This commit is contained in:
gibbz00 2023-06-03 10:37:06 +02:00 committed by Blaž Hrastnik
parent 19326d23d1
commit 3d0bc72099
2 changed files with 10 additions and 15 deletions

View File

@ -102,7 +102,15 @@ pub fn infobox(&self) -> Info {
.position(|&k| k == *keys.iter().next().unwrap())
.unwrap()
});
Info::from_keymap(self.name(), body)
let body: Vec<_> = body
.into_iter()
.map(|(events, desc)| {
let events = events.iter().map(ToString::to_string).collect::<Vec<_>>();
(events.join(", "), desc)
})
.collect();
Info::new(self.name(), &body)
}
}

View File

@ -1,6 +1,5 @@
use crate::input::KeyEvent;
use helix_core::{register::Registers, unicode::width::UnicodeWidthStr};
use std::{collections::BTreeSet, fmt::Write};
use std::fmt::Write;
#[derive(Debug)]
/// Info box used in editor. Rendering logic will be in other crate.
@ -55,18 +54,6 @@ pub fn new<T, U>(title: &str, body: &[(T, U)]) -> Self
}
}
pub fn from_keymap(title: &str, body: Vec<(BTreeSet<KeyEvent>, &str)>) -> Self {
let body: Vec<_> = body
.into_iter()
.map(|(events, desc)| {
let events = events.iter().map(ToString::to_string).collect::<Vec<_>>();
(events.join(", "), desc)
})
.collect();
Self::new(title, &body)
}
pub fn from_registers(registers: &Registers) -> Self {
let body: Vec<_> = registers
.inner()