on master help sign in
Move FilePicker struct def closer to impl block
fc11121Gokul Soumya
helix-term/src/ui/picker.rs+30−30
@@ -77,36 +77,6 @@ type FileCallback<T> = Box<dyn Fn(&Editor, &T) -> Option<FileLocation>>;
77/// File path and range of lines (used to align and highlight lines)
77/// File path and range of lines (used to align and highlight lines)
78pub type FileLocation = (PathOrId, Option<(usize, usize)>);
78pub type FileLocation = (PathOrId, Option<(usize, usize)>);
79
79
80−pub struct FilePicker<T: Item> {
81− options: Vec<T>,
82− editor_data: T::Data,
83− // filter: String,
84− matcher: Box<Matcher>,
85− matches: Vec<PickerMatch>,
86−
87− /// Current height of the completions box
88− completion_height: u16,
89−
90− cursor: usize,
91− // pattern: String,
92− prompt: Prompt,
93− previous_pattern: (String, FuzzyQuery),
94− /// Whether to show the preview panel (default true)
95− show_preview: bool,
96− /// Constraints for tabular formatting
97− widths: Vec<Constraint>,
98−
99− callback_fn: PickerCallback<T>,
100−
101− picker: Picker<T>,
102− pub truncate_start: bool,
103− /// Caches paths to documents
104− preview_cache: HashMap<PathBuf, CachedPreview>,
105− read_buffer: Vec<u8>,
106− /// Given an item in the picker, return the file path and line number to display.
107− file_fn: FileCallback<T>,
108−}
109−
110pub enum CachedPreview {
80pub enum CachedPreview {
111 Document(Box<Document>),
81 Document(Box<Document>),
112 Binary,
82 Binary,
@@ -144,6 +114,36 @@ impl Preview<'_, '_> {
144 }
114 }
145}
115}
146
116
117+pub struct FilePicker<T: Item> {
118+ options: Vec<T>,
119+ editor_data: T::Data,
120+ // filter: String,
121+ matcher: Box<Matcher>,
122+ matches: Vec<PickerMatch>,
123+
124+ /// Current height of the completions box
125+ completion_height: u16,
126+
127+ cursor: usize,
128+ // pattern: String,
129+ prompt: Prompt,
130+ previous_pattern: (String, FuzzyQuery),
131+ /// Whether to show the preview panel (default true)
132+ show_preview: bool,
133+ /// Constraints for tabular formatting
134+ widths: Vec<Constraint>,
135+
136+ callback_fn: PickerCallback<T>,
137+
138+ picker: Picker<T>,
139+ pub truncate_start: bool,
140+ /// Caches paths to documents
141+ preview_cache: HashMap<PathBuf, CachedPreview>,
142+ read_buffer: Vec<u8>,
143+ /// Given an item in the picker, return the file path and line number to display.
144+ file_fn: FileCallback<T>,
145+}
146+
147impl<T: Item + 'static> FilePicker<T> {
147impl<T: Item + 'static> FilePicker<T> {
148 pub fn new(
148 pub fn new(
149 options: Vec<T>,
149 options: Vec<T>,