on master help sign in
ui: prompt: Render aliases + border on the doc
c7b326bBlaž Hrastnik
helix-term/src/commands.rs+5−2
@@ -3384,8 +3384,11 @@ fn command_mode(cx: &mut Context) {
3384 prompt.doc_fn = Box::new(|input: &str| {
3384 prompt.doc_fn = Box::new(|input: &str| {
3385 let part = input.split(' ').next().unwrap_or_default();
3385 let part = input.split(' ').next().unwrap_or_default();
3386
3386
3387− if let Some(cmd::TypableCommand { doc, .. }) = cmd::TYPABLE_COMMAND_MAP.get(part) {
3387+ if let Some(cmd::TypableCommand { doc, aliases, .. }) = cmd::TYPABLE_COMMAND_MAP.get(part) {
3388+ if aliases.is_empty() {
3388− return Some(doc);
3389+ return Some((*doc).into());
3390+ }
3391+ return Some(format!("{}\nAliases: {}", doc, aliases.join(", ")).into());
3389 }
3392 }
3390
3393
3391 None
3394 None
helix-term/src/ui/prompt.rs+14−9
@@ -5,6 +5,7 @@ use helix_view::input::KeyEvent;
5use helix_view::keyboard::{KeyCode, KeyModifiers};
5use helix_view::keyboard::{KeyCode, KeyModifiers};
6use std::{borrow::Cow, ops::RangeFrom};
6use std::{borrow::Cow, ops::RangeFrom};
7use tui::buffer::Buffer as Surface;
7use tui::buffer::Buffer as Surface;
8+use tui::widgets::{Block, Borders, Widget};
8
9
9use helix_core::{
10use helix_core::{
10 unicode::segmentation::GraphemeCursor, unicode::width::UnicodeWidthStr, Position,
11 unicode::segmentation::GraphemeCursor, unicode::width::UnicodeWidthStr, Position,
@@ -26,7 +27,7 @@ pub struct Prompt {
26 history_pos: Option<usize>,
27 history_pos: Option<usize>,
27 completion_fn: Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>,
28 completion_fn: Box<dyn FnMut(&Editor, &str) -> Vec<Completion>>,
28 callback_fn: Box<dyn FnMut(&mut Context, &str, PromptEvent)>,
29 callback_fn: Box<dyn FnMut(&mut Context, &str, PromptEvent)>,
29− pub doc_fn: Box<dyn Fn(&str) -> Option<&'static str>>,
30+ pub doc_fn: Box<dyn Fn(&str) -> Option<Cow<str>>>,
30}
31}
31
32
32#[derive(Clone, Copy, PartialEq)]
33#[derive(Clone, Copy, PartialEq)]
@@ -406,14 +407,18 @@ impl Prompt {
406 let background = theme.get("ui.help");
407 let background = theme.get("ui.help");
407 surface.clear_with(area, background);
408 surface.clear_with(area, background);
408
409
409− text.render(
410+ let block = Block::default()
411+ // .title(self.title.as_str())
412+ .borders(Borders::ALL)
413+ .border_style(background);
414+
410− area.inner(&Margin {
415+ let inner = block.inner(area).inner(&Margin {
411− vertical: padding,
416+ vertical: 0,
412− horizontal: padding,
417+ horizontal: 1,
413− }),
418+ });
419+
420+ block.render(area, surface);
414− surface,
421+ text.render(inner, surface, cx);
415− cx,
416− );
417 }
422 }
418
423
419 let line = area.height - 1;
424 let line = area.height - 1;