From 75dfaff33891d0505e3018a8357fa0619ef1fcc2 Mon Sep 17 00:00:00 2001 From: Pascal Sommer Date: Wed, 11 Jan 2023 03:11:43 +0100 Subject: Add some function documentations (#5360) --- helix-term/src/ui/popup.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'helix-term/src/ui/popup.rs') diff --git a/helix-term/src/ui/popup.rs b/helix-term/src/ui/popup.rs index 62a6785a..5a95c1bb 100644 --- a/helix-term/src/ui/popup.rs +++ b/helix-term/src/ui/popup.rs @@ -42,6 +42,10 @@ impl Popup { } } + /// Set the anchor position next to which the popup should be drawn. + /// + /// Note that this is not the position of the top-left corner of the rendered popup itself, + /// but rather the screen-space position of the information to which the popup refers. pub fn position(mut self, pos: Option) -> Self { self.position = pos; self @@ -51,6 +55,10 @@ impl Popup { self.position } + /// Set the popup to prefer to render above or below the anchor position. + /// + /// This preference will be ignored if the viewport doesn't have enough space in the + /// chosen direction. pub fn position_bias(mut self, bias: Open) -> Self { self.position_bias = bias; self @@ -78,6 +86,8 @@ impl Popup { self } + /// Calculate the position where the popup should be rendered and return the coordinates of the + /// top left corner. pub fn get_rel_position(&mut self, viewport: Rect, cx: &Context) -> (u16, u16) { let position = self .position -- cgit v1.2.3-70-g09d2