Struct SuggestionList
pub struct SuggestionList { /* private fields */ }Expand description
A floating list of suggestions under (or, without room, above) an
anchor: the one list behind Autocomplete and a code editor’s caret
completion.
It is a floating Panel (surface::panel, radii.panel, the floating
shadow) placed by floating_surface::place_anchored, so it flips above
its anchor near the window’s bottom and shifts to stay inside it. Rows
are menu rows with the armed-row lift, an optional leading icon and an
optional trailing detail column. More suggestions than fit scroll, the
armed row always in view. A status line (and a spinner while busy)
stands in for rows while there are none.
Implementations§
§impl SuggestionList
impl SuggestionList
pub fn new() -> SuggestionList
pub fn with_text_role(self, role: TextRole) -> SuggestionList
pub fn with_text_role(self, role: TextRole) -> SuggestionList
Set the rows’ labels in role (a code completion’s labels are Code).
pub fn with_max_visible(self, rows: usize) -> SuggestionList
pub fn with_max_visible(self, rows: usize) -> SuggestionList
Rows beyond this scroll instead of growing the panel.
pub fn set_text_role(&mut self, role: TextRole)
pub fn set_text_role(&mut self, role: TextRole)
Set the rows’ label role; see Self::with_text_role.
pub fn set_suggestions(&mut self, suggestions: Vec<Suggestion>)
pub fn set_suggestions(&mut self, suggestions: Vec<Suggestion>)
Replace the suggestions. Keeps the armed row when it still exists and clears the status line once there are rows.
pub fn suggestions(&self) -> &[Suggestion]
pub fn highlighted(&self) -> Option<&Suggestion>
pub fn set_highlight(&mut self, index: Option<usize>)
pub fn set_highlight(&mut self, index: Option<usize>)
Arm row index (clamped; None disarms) and scroll it into view.
pub fn move_highlight(&mut self, forward: bool)
pub fn move_highlight(&mut self, forward: bool)
Arm the next (or previous) row, wrapping at both ends.
pub fn set_status(&mut self, status: Option<String>)
pub fn set_status(&mut self, status: Option<String>)
A line shown while there are no rows (“Searching…”, “No matches”);
None clears it.
pub fn is_busy(&self) -> bool
pub fn set_anchor(&mut self, anchor: Rect)
pub fn set_anchor(&mut self, anchor: Rect)
The rect the list opens from (a field, or the caret’s line).
pub fn set_viewport(&mut self, viewport: Rect)
pub fn set_viewport(&mut self, viewport: Rect)
The bounds the list stays inside, normally the window.
pub fn has_content(&self) -> bool
pub fn has_content(&self) -> bool
Whether there is anything to show: rows, a status line or a spinner.
pub fn clear(&mut self)
pub fn clear(&mut self)
Clear rows, status and armed row.
pub fn rect(&self) -> Option<Rect>
pub fn rect(&self) -> Option<Rect>
The panel’s rect: under the anchor, or above it when there is more
room there, inside the viewport. None with nothing to show.
pub fn row_rect(&self, index: usize) -> Option<Rect>
pub fn row_rect(&self, index: usize) -> Option<Rect>
The rect of suggestion index, when it is in view.
pub fn hover_at(&mut self, point: Point) -> bool
pub fn hover_at(&mut self, point: Point) -> bool
Track the pointer for the hover lift; returns whether it changed.
pub fn paint(
&mut self,
scene: &mut Scene,
transform: Affine,
text: &mut TextRenderer,
theme: &Theme,
)
pub fn paint( &mut self, scene: &mut Scene, transform: Affine, text: &mut TextRenderer, theme: &Theme, )
Paint the list in the window’s top layer.
Trait Implementations§
§impl Default for SuggestionList
impl Default for SuggestionList
§fn default() -> SuggestionList
fn default() -> SuggestionList
Auto Trait Implementations§
impl Freeze for SuggestionList
impl RefUnwindSafe for SuggestionList
impl Send for SuggestionList
impl Sync for SuggestionList
impl Unpin for SuggestionList
impl UnsafeUnpin for SuggestionList
impl UnwindSafe for SuggestionList
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more