@@ -19,6 +19,7 @@ pub struct Popup {
19 contents: Box<dyn Component>,
19 contents: Box<dyn Component>,
20 position: Option<Position>,
20 position: Option<Position>,
21 size: (u16, u16),
21 size: (u16, u16),
24impl Popup {
25impl Popup {
@@ -29,12 +30,21 @@ impl Popup {
30 position: None,
31 position: None,
31 size: (0, 0),
32 size: (0, 0),
35 pub fn set_position(&mut self, pos: Option<Position>) {
37 pub fn set_position(&mut self, pos: Option<Position>) {
36 self.position = pos;
38 self.position = pos;
41+ pub fn scroll(&mut self, offset: usize, direction: bool) {
43+ self.scroll += offset;
45+ self.scroll = self.scroll.saturating_sub(offset);
40impl Component for Popup {
50impl Component for Popup {
@@ -64,6 +74,21 @@ impl Component for Popup {
64 code: KeyCode::Char('c'),
74 code: KeyCode::Char('c'),
65 modifiers: KeyModifiers::CONTROL,
75 modifiers: KeyModifiers::CONTROL,
66 } => close_fn,
76 } => close_fn,
79+ code: KeyCode::Char('d'),
80+ modifiers: KeyModifiers::CONTROL,
82+ self.scroll(self.size.1 as usize / 2, true);
83+ return EventResult::Consumed(None);
86+ code: KeyCode::Char('u'),
87+ modifiers: KeyModifiers::CONTROL,
89+ self.scroll(self.size.1 as usize / 2, false);
90+ return EventResult::Consumed(None);
67 _ => self.contents.handle_event(event, cx),
92 _ => self.contents.handle_event(event, cx),
69 // for some events, we want to process them but send ignore, specifically all input except
94 // for some events, we want to process them but send ignore, specifically all input except
@@ -85,6 +110,8 @@ impl Component for Popup {
85 use tui::text::Text;
110 use tui::text::Text;
86 use tui::widgets::{Paragraph, Widget, Wrap};
111 use tui::widgets::{Paragraph, Widget, Wrap};
113+ cx.scroll = Some(self.scroll);
88 let position = self
115 let position = self
89 .position
116 .position
90 .or_else(|| cx.editor.cursor_position())
117 .or_else(|| cx.editor.cursor_position())