aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-02 09:24:24 +0000
committerBlaž Hrastnik2021-03-02 09:24:24 +0000
commit0b85c16be91d9326876b2e4a1ae6bdc1381d700d (patch)
tree4bbb758097d6b3aecb8791b061bd49a59dc5ad7a /helix-term/src/commands.rs
parent11c4e0b05325d8fd8046a764ec4b9e655486313d (diff)
ui: Share popup code with menu.
Menu is now just wrapped in a popup.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs31
1 files changed, 5 insertions, 26 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 7ffa28a3..bbd78092 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1117,16 +1117,8 @@ pub fn completion(cx: &mut Context) {
},
);
- cx.callback = Some(Box::new(
- move |compositor: &mut Compositor, editor: &mut Editor| {
- if let Some(mut pos) = editor.cursor_position() {
- pos.row += 1; // shift down by one row
- menu.set_position(pos);
- };
-
- compositor.push(Box::new(menu));
- },
- ));
+ let popup = Popup::new(Box::new(menu));
+ cx.push_layer(Box::new(popup));
// TODO!: when iterating over items, show the docs in popup
@@ -1171,22 +1163,9 @@ pub fn hover(cx: &mut Context) {
// skip if contents empty
- // Popup: box frame + Box<Component> for internal content.
- // it will use the contents.size_hint/required size to figure out sizing & positioning
- // can also use render_buffer to render the content.
- // render_buffer(highlights/scopes, text, surface, theme)
- //
- let mut popup = Popup::new(contents);
-
- cx.callback = Some(Box::new(
- move |compositor: &mut Compositor, editor: &mut Editor| {
- if let Some(mut pos) = editor.cursor_position() {
- popup.set_position(pos);
- };
-
- compositor.push(Box::new(popup));
- },
- ));
+ let contents = ui::Text::new(contents);
+ let mut popup = Popup::new(Box::new(contents));
+ cx.push_layer(Box::new(popup));
}
}