aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui
diff options
context:
space:
mode:
authorPascal Sommer2023-01-11 02:11:43 +0000
committerGitHub2023-01-11 02:11:43 +0000
commit75dfaff33891d0505e3018a8357fa0619ef1fcc2 (patch)
treef20cc068b867d70933374380631f00eabf0318fa /helix-term/src/ui
parenta8248c50e1017cbba42c602d480d3c4ffa7162a0 (diff)
Add some function documentations (#5360)
Diffstat (limited to 'helix-term/src/ui')
-rw-r--r--helix-term/src/ui/popup.rs10
1 files changed, 10 insertions, 0 deletions
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<T: Component> Popup<T> {
}
}
+ /// 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<Position>) -> Self {
self.position = pos;
self
@@ -51,6 +55,10 @@ impl<T: Component> Popup<T> {
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<T: Component> Popup<T> {
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