Skip to main content

FileSource

Struct FileSource 

Source
pub struct FileSource {
    pub root: PathBuf,
    pub items: Arc<Mutex<Vec<PathBuf>>>,
    /* private fields */
}
Expand description

File-source: gitignore-aware cwd walker. Items are paths relative to root, preview reads from disk capped at PREVIEW_MAX_BYTES with a binary-byte heuristic.

Bonsai-agnostic — the preview returns just the file contents. The host (e.g. apps/hjkl) is responsible for layering syntax highlight spans by reading PickerLogic::preview_path and feeding the buffer bytes through its own highlighter.

Fields§

§root: PathBuf§items: Arc<Mutex<Vec<PathBuf>>>

Implementations§

Source§

impl FileSource

Source

pub fn new(root: PathBuf) -> Self

Trait Implementations§

Source§

impl PickerLogic for FileSource

Source§

fn title(&self) -> &str

Title shown above the input row (e.g. “files”, “buffers”, “grep”).
Source§

fn item_count(&self) -> usize

Number of items currently available (grows as enumeration progresses).
Source§

fn label(&self, idx: usize) -> String

Display label for the row at idx.
Source§

fn match_text(&self, idx: usize) -> String

Text the fuzzy scorer scores against. May equal label.
Source§

fn preview(&self, idx: usize) -> (Buffer, String)

Build the preview pane for the row. Default: empty buffer. Read more
Source§

fn preview_path(&self, idx: usize) -> Option<PathBuf>

File-system path the preview’s content was loaded from, when one exists. Used by the host to drive language-aware preview rendering (e.g. tree-sitter syntax highlighting). Default None for sources whose preview has no on-disk path (an in-memory snapshot, a help message, etc.).
Source§

fn select(&self, _idx: usize) -> PickerAction

Translate the picked row into an action.
Source§

fn requery_mode(&self) -> RequeryMode

How the picker should react when the query changes.
Source§

fn enumerate( &mut self, _query: Option<&str>, cancel: Arc<AtomicBool>, ) -> Option<JoinHandle<()>>

Re-enumerate items. Read more
Source§

fn has_preview(&self) -> bool

Whether this source wants the preview pane.
Source§

fn preview_top_row(&self, idx: usize) -> usize

Initial scroll position (top row) for the preview viewport. Sources that show a windowed preview around a specific line override this so the gutter line numbers reflect the actual file line. Default 0.
Source§

fn preview_match_row(&self, idx: usize) -> Option<usize>

0-based row to visually mark in the preview (e.g. grep match line). Default None → no highlight. Returning Some(row) tells the renderer to paint a cursor_line_bg across that row.
Source§

fn preview_line_offset(&self, idx: usize) -> usize

Added to the gutter line numbers in the preview. Sources that snapshot a window of a larger document (e.g. buffer picker snapshotting ±N lines around the cursor) use this so the gutter shows the original document line numbers rather than restarting at 1. Default 0.
Source§

fn handle_key(&self, idx: usize, key: KeyEvent) -> Option<PickerAction>

Handle a key before the picker’s default handling. Return Some(action) to short-circuit and emit that action immediately. Return None to let the picker handle the key normally. Default: None.
Source§

fn label_match_positions( &self, idx: usize, query: &str, label: &str, ) -> Option<Vec<usize>>

Override the highlight positions for the row at idx. Read more
Source§

fn preserve_source_order(&self) -> bool

Whether the picker should keep the source’s enumeration order when the query is empty. Default false means empty-query rows are sorted by match-text ascending. Sources that pre-sort meaningfully (e.g. by recency, by HEAD-first) override to true.
Source§

fn label_styles( &self, idx: usize, label: &str, ) -> Option<Vec<(Range<usize>, Style)>>

Optional per-row semantic styling for the label. Char-index ranges into the label with a base style. Fuzzy-match positions overlay these. Default None means no extra styling.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.