From bf773db45171b59a758b7dabf9f10ffb8852dcf0 Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Fri, 5 Nov 2021 00:03:31 +0530 Subject: Show infobox with register contents --- helix-term/src/commands.rs | 3 +++ helix-term/src/keymap.rs | 3 +-- helix-term/src/ui/editor.rs | 12 +++++------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index e766417c..2e430106 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -20,6 +20,7 @@ use helix_view::{ clipboard::ClipboardType, document::{Mode, SCRATCH_BUFFER_NAME}, editor::{Action, Motion}, + info::Info, input::KeyEvent, keyboard::KeyCode, view::View, @@ -5745,8 +5746,10 @@ fn wonly(cx: &mut Context) { } fn select_register(cx: &mut Context) { + cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers)); cx.on_next_key(move |cx, event| { if let Some(ch) = event.char() { + cx.editor.autoinfo = None; cx.editor.selected_register = Some(ch); } }) diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index e5990d72..212b27a9 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -222,9 +222,8 @@ impl KeyTrieNode { .map(|(desc, keys)| (desc.strip_prefix(&prefix).unwrap(), keys)) .collect(); } - Info::new(self.name(), body) + Info::from_keymap(self.name(), body) } - /// Get a reference to the key trie node's order. pub fn order(&self) -> &[KeyEvent] { self.order.as_slice() diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index d3af921e..e68f5ff0 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -21,7 +21,6 @@ use helix_view::{ document::{Mode, SCRATCH_BUFFER_NAME}, editor::CursorShapeConfig, graphics::{CursorKind, Modifier, Rect, Style}, - info::Info, input::KeyEvent, keyboard::{KeyCode, KeyModifiers}, Document, Editor, Theme, View, @@ -37,7 +36,6 @@ pub struct EditorView { last_insert: (commands::MappableCommand, Vec), pub(crate) completion: Option, spinners: ProgressSpinners, - autoinfo: Option, } impl Default for EditorView { @@ -54,7 +52,6 @@ impl EditorView { last_insert: (commands::MappableCommand::normal_mode, Vec::new()), completion: None, spinners: ProgressSpinners::default(), - autoinfo: None, } } @@ -678,13 +675,13 @@ impl EditorView { cxt: &mut commands::Context, event: KeyEvent, ) -> Option { - self.autoinfo = None; + cxt.editor.autoinfo = None; let key_result = self.keymaps.get_mut(&mode).unwrap().get(event); - self.autoinfo = key_result.sticky.map(|node| node.infobox()); + cxt.editor.autoinfo = key_result.sticky.map(|node| node.infobox()); match &key_result.kind { KeymapResultKind::Matched(command) => command.execute(cxt), - KeymapResultKind::Pending(node) => self.autoinfo = Some(node.infobox()), + KeymapResultKind::Pending(node) => cxt.editor.autoinfo = Some(node.infobox()), KeymapResultKind::MatchedSequence(commands) => { for command in commands { command.execute(cxt); @@ -1093,8 +1090,9 @@ impl Component for EditorView { } if cx.editor.config.auto_info { - if let Some(ref mut info) = self.autoinfo { + if let Some(mut info) = cx.editor.autoinfo.take() { info.render(area, surface, cx); + cx.editor.autoinfo = Some(info) } } -- cgit v1.2.3-70-g09d2