pub struct Skim<Backend = CrosstermBackend<BufWriter<Stderr>>>{ /* private fields */ }Expand description
Main entry point for running skim
Implementations§
Source§impl Skim
impl Skim
Sourcepub fn run_with(
options: SkimOptions,
source: Option<SkimItemReceiver>,
) -> Result<SkimOutput>
pub fn run_with( options: SkimOptions, source: Option<SkimItemReceiver>, ) -> Result<SkimOutput>
Run skim, collecting items from the source and using options
§Params
- options: the “complex” options that control how skim behaves
- source: a stream of items to be passed to skim for filtering. If None is given, skim will invoke the command given to fetch the items.
§Returns
- None: on internal errors.
SkimOutput: the collected key, event, query, selected items, etc.
§Errors
Returns an error if skim initialization or the TUI loop fails.
§Panics
Panics if the tui fails to initialize
Sourcepub fn run_items<I, T>(options: SkimOptions, items: I) -> Result<SkimOutput>where
I: IntoIterator<Item = T>,
T: SkimItem,
pub fn run_items<I, T>(options: SkimOptions, items: I) -> Result<SkimOutput>where
I: IntoIterator<Item = T>,
T: SkimItem,
Run skim with a Vec of items
§Errors
Returns an error if sending items to the channel or running skim fails.
use skim::prelude::*;
let opts = SkimOptionsBuilder::default().multi(true).build().unwrap();
Skim::run_items(opts, ["foo", "bar"]);Sourcepub fn init_tui(&mut self) -> Result<()>
pub fn init_tui(&mut self) -> Result<()>
Initialize the TUI with the default crossterm backend, but do not enter it yet
§Errors
Returns an error if the TUI backend cannot be initialized.
Sourcepub fn new(
options: SkimOptions,
source: Option<SkimItemReceiver>,
) -> Result<Self>
pub fn new( options: SkimOptions, source: Option<SkimItemReceiver>, ) -> Result<Self>
Initialize and start skim without entering the terminal UI.
§Errors
Returns an error if skim or the TUI backend cannot be initialized.
Sourcepub fn new_items<I, T>(options: SkimOptions, items: I) -> Result<Self>where
I: IntoIterator<Item = T>,
T: SkimItem,
pub fn new_items<I, T>(options: SkimOptions, items: I) -> Result<Self>where
I: IntoIterator<Item = T>,
T: SkimItem,
Initialize and start skim with items without entering the terminal UI.
§Errors
Returns an error if sending items or initializing skim or its TUI fails.
Source§impl<Backend: Backend + 'static> Skim<Backend>
impl<Backend: Backend + 'static> Skim<Backend>
Sourcepub fn init(
options: SkimOptions,
source: Option<SkimItemReceiver>,
) -> Result<Self>
pub fn init( options: SkimOptions, source: Option<SkimItemReceiver>, ) -> Result<Self>
Initialize skim, without starting anything yet
§Errors
Returns an error if parsing the height or other options fails.
Sourcepub fn handle_reload(&mut self, new_cmd: &str)
pub fn handle_reload(&mut self, new_cmd: &str)
Handle a reload event by killing the current reader, clearing items, and starting a new reader.
This encapsulates the reload logic from the main event loop so it can be reused by test harnesses without reimplementing it.
Sourcepub fn check_reader(&mut self) -> bool
pub fn check_reader(&mut self) -> bool
Check if the reader has finished and restart the matcher if needed.
This encapsulates the reader-status check from the main event loop so it can be reused by test harnesses.
Returns true if the reader has completed.
Sourcepub fn reader_done(&self) -> bool
pub fn reader_done(&self) -> bool
Returns true if the reader is done (has finished producing items).
Sourcepub fn matcher_stopped(&self) -> bool
pub fn matcher_stopped(&self) -> bool
Returns true if the matcher is stopped
Sourcepub fn init_tui_with(&mut self, tui: Tui<Backend>)
pub fn init_tui_with(&mut self, tui: Tui<Backend>)
Initialize the TUI with a caller-provided instance.
Use this instead of init_tui() when you need a
non-default backend (e.g. TestBackend for snapshot tests).
Sourcepub fn app_and_tui(&mut self) -> (&mut App, &mut Tui<Backend>)
pub fn app_and_tui(&mut self) -> (&mut App, &mut Tui<Backend>)
Returns mutable references to both the app and the TUI simultaneously.
This is useful when you need to call app.handle_event(tui, ...) or
tui.draw(|frame| frame.render_widget(app, ...)), which require
disjoint mutable borrows of both fields.
§Panics
Panics if the TUI has not been initialized yet.
Sourcepub fn final_event(&self) -> &Event
pub fn final_event(&self) -> &Event
Returns a shared reference to the final event that caused skim to quit.
Sourcepub fn event_sender(&self) -> Sender<Event>
pub fn event_sender(&self) -> Sender<Event>
Returns a clone of the TUI event sender.
Use this to send events (e.g. Event::Render, Event::Action)
to the running skim instance from outside the event loop. The sender
is cheap to clone and can be moved into async blocks or other tasks.
Must be called after init_tui().
§Panics
Panics if init_tui has not been called before this method.
Sourcepub fn should_enter(&mut self) -> bool
pub fn should_enter(&mut self) -> bool
Checks read-0 select-1, filter, and sync to wait and returns whether or not we should enter
§Panics
Panics if start has not been called before this method.
Sourcepub fn output(self) -> SkimOutput
pub fn output(self) -> SkimOutput
Capture self and extract the output
This will perform cleanup
§Panics
Panics if the selected items or current item cannot be retrieved.
Sourcepub fn should_quit(&self) -> bool
pub fn should_quit(&self) -> bool
Returns true if skim has finished (the user accepted or aborted)
Sourcepub async fn tick(&mut self) -> Result<bool>
pub async fn tick(&mut self) -> Result<bool>
Process a single event loop iteration.
This awaits the next event from the TUI, matcher, or IPC listener, processes it, and returns. Use this in your own event loop when you need fine-grained control over the application lifecycle.
Returns Ok(true) if skim should quit, Ok(false) to continue.
§Errors
Returns an error if the TUI cannot produce the next event or if event handling fails.
§Panics
Panics if init_tui has not been called before this method.
§Example
while !skim.tick().await? {
// do your own work between ticks
}Sourcepub async fn run_until<F: Future + 'static>(
self,
user_task: F,
) -> Result<SkimOutput>
pub async fn run_until<F: Future + 'static>( self, user_task: F, ) -> Result<SkimOutput>
Spawn the event loop and run a user-provided future concurrently.
This consumes self, spawns the event loop as a local task, and runs
user_task alongside it. When the user accepts or aborts in the TUI,
the event loop completes and the SkimOutput is returned — regardless
of whether user_task has finished.
Use this when you need to send items or do other work concurrently while the TUI is running.
§Errors
Returns an error if the event loop or the task join fails.
§Example
let output = skim.run_until(async {
for i in 1..=10 {
tx.send(vec![Arc::new(format!("item {i}"))]);
tokio::time::sleep(Duration::from_millis(100)).await;
}
}).await?;Auto Trait Implementations§
impl<Backend = CrosstermBackend<BufWriter<Stderr>>> !Freeze for Skim<Backend>
impl<Backend = CrosstermBackend<BufWriter<Stderr>>> !RefUnwindSafe for Skim<Backend>
impl<Backend = CrosstermBackend<BufWriter<Stderr>>> !Send for Skim<Backend>
impl<Backend = CrosstermBackend<BufWriter<Stderr>>> !Sync for Skim<Backend>
impl<Backend = CrosstermBackend<BufWriter<Stderr>>> !UnwindSafe for Skim<Backend>
impl<Backend> Unpin for Skim<Backend>
impl<Backend> UnsafeUnpin for Skim<Backend>
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere
T: Real + Zero + Arithmetics + Clone,
Swp: WhitePoint<T>,
Dwp: WhitePoint<T>,
D: AdaptFrom<S, Swp, Dwp, T>,
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<T>,
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
replaced by palette::chromatic_adaptation::AdaptIntoUnclamped
Source§impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
impl<T, C> AdaptIntoUnclamped<T> for Cwhere
T: AdaptFromUnclamped<C>,
Source§type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
type Scalar = <T as AdaptFromUnclamped<C>>::Scalar
Source§fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
fn adapt_into_unclamped_with<M>(self) -> Twhere
M: LmsToXyz<<C as AdaptIntoUnclamped<T>>::Scalar> + XyzToLms<<C as AdaptIntoUnclamped<T>>::Scalar>,
Source§impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
impl<T, C> ArraysFrom<C> for Twhere
C: IntoArrays<T>,
Source§fn arrays_from(colors: C) -> T
fn arrays_from(colors: C) -> T
Source§impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
impl<T, C> ArraysInto<C> for Twhere
C: FromArrays<T>,
Source§fn arrays_into(self) -> C
fn arrays_into(self) -> C
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
Source§impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for Uwhere
T: FromCam16Unclamped<WpParam, U>,
Source§type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn cam16_into_unclamped(
self,
parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>,
) -> T
fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
impl<T, C> ComponentsFrom<C> for Twhere
C: IntoComponents<T>,
Source§fn components_from(colors: C) -> T
fn components_from(colors: C) -> T
Source§impl<T, C> ComponentsInto<C> for T
impl<T, C> ComponentsInto<C> for T
Source§fn components_into(self) -> C
fn components_into(self) -> C
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> FromAngle<T> for T
impl<T> FromAngle<T> for T
Source§fn from_angle(angle: T) -> T
fn from_angle(angle: T) -> T
angle.Source§impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
impl<T, U> FromStimulus<U> for Twhere
U: IntoStimulus<T>,
Source§fn from_stimulus(other: U) -> T
fn from_stimulus(other: U) -> T
other into Self, while performing the appropriate scaling,
rounding and clamping.Source§impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
impl<T, U> IntoAngle<U> for Twhere
U: FromAngle<T>,
Source§fn into_angle(self) -> U
fn into_angle(self) -> U
T.Source§impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for Uwhere
T: Cam16FromUnclamped<WpParam, U>,
Source§type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar
parameters when converting.Source§fn into_cam16_unclamped(
self,
parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>,
) -> T
fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T
self into C, using the provided parameters.Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
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 moreSource§impl<T> IntoStimulus<T> for T
impl<T> IntoStimulus<T> for T
Source§fn into_stimulus(self) -> T
fn into_stimulus(self) -> T
self into T, while performing the appropriate scaling,
rounding and clamping.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
impl<T, C> TryComponentsInto<C> for Twhere
C: TryFromComponents<T>,
Source§type Error = <C as TryFromComponents<T>>::Error
type Error = <C as TryFromComponents<T>>::Error
try_into_colors fails to cast.Source§fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>
Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more