@@ -19,6 +19,7 @@ pub struct Popup {
1919 contents: Box<dyn Component>,
2020 position: Option<Position>,
2121 size: (u16, u16),
22+ scroll: usize,
2223}
2324
2425impl Popup {
@@ -29,12 +30,21 @@ impl Popup {
2930 contents,
3031 position: None,
3132 size: (0, 0),
33+ scroll: 0,
3234 }
3335 }
3436
3537 pub fn set_position(&mut self, pos: Option<Position>) {
3638 self.position = pos;
3739 }
40+
41+ pub fn scroll(&mut self, offset: usize, direction: bool) {
42+ if direction {
43+ self.scroll += offset;
44+ } else {
45+ self.scroll = self.scroll.saturating_sub(offset);
46+ }
47+ }
3848}
3949
4050impl Component for Popup {
@@ -64,6 +74,21 @@ impl Component for Popup {
6474 code: KeyCode::Char('c'),
6575 modifiers: KeyModifiers::CONTROL,
6676 } => close_fn,
77+
78+ KeyEvent {
79+ code: KeyCode::Char('d'),
80+ modifiers: KeyModifiers::CONTROL,
81+ } => {
82+ self.scroll(self.size.1 as usize / 2, true);
83+ return EventResult::Consumed(None);
84+ }
85+ KeyEvent {
86+ code: KeyCode::Char('u'),
87+ modifiers: KeyModifiers::CONTROL,
88+ } => {
89+ self.scroll(self.size.1 as usize / 2, false);
90+ return EventResult::Consumed(None);
91+ }
6792 _ => self.contents.handle_event(event, cx),
6893 }
6994 // for some events, we want to process them but send ignore, specifically all input except
@@ -85,6 +110,8 @@ impl Component for Popup {
85110 use tui::text::Text;
86111 use tui::widgets::{Paragraph, Widget, Wrap};
87112
113+ cx.scroll = Some(self.scroll);
114+
88115 let position = self
89116 .position
90117 .or_else(|| cx.editor.cursor_position())