navi/finder/
structures.rs1use crate::filesystem;
2use crate::prelude::*;
3
4#[derive(Debug, PartialEq, Clone)]
5pub struct Opts {
6 pub query: Option<String>,
7 pub filter: Option<String>,
8 pub prompt: Option<String>,
9 pub preview: Option<String>,
10 pub preview_window: Option<String>,
11 pub overrides: Option<String>,
12 pub header_lines: u8,
13 pub header: Option<String>,
14 pub suggestion_type: SuggestionType,
15 pub delimiter: Option<String>,
16 pub column: Option<u8>,
17 pub map: Option<String>,
18 pub prevent_select1: bool,
19 pub show_all_columns: bool,
20}
21
22impl Default for Opts {
23 fn default() -> Self {
24 Self {
25 query: None,
26 filter: None,
27 preview: None,
28 preview_window: None,
29 overrides: None,
30 header_lines: 0,
31 header: None,
32 prompt: None,
33 suggestion_type: SuggestionType::SingleSelection,
34 column: None,
35 delimiter: None,
36 map: None,
37 prevent_select1: true,
38 show_all_columns: false,
39 }
40 }
41}
42
43impl Opts {
44 pub fn snippet_default() -> Self {
45 Self {
46 suggestion_type: SuggestionType::SnippetSelection,
47 overrides: CONFIG.fzf_overrides(),
48 preview: Some(format!("{} preview {{}}", filesystem::exe_string())),
49 prevent_select1: !CONFIG.best_match(),
50 query: if CONFIG.best_match() {
51 None
52 } else {
53 CONFIG.get_query()
54 },
55 filter: if CONFIG.best_match() {
56 CONFIG.get_query()
57 } else {
58 None
59 },
60 ..Default::default()
61 }
62 }
63
64 pub fn var_default() -> Self {
65 Self {
66 overrides: CONFIG.fzf_overrides_var(),
67 suggestion_type: SuggestionType::SingleRecommendation,
68 prevent_select1: false,
69 ..Default::default()
70 }
71 }
72}
73
74#[derive(Clone, Copy, Debug, PartialEq)]
75pub enum SuggestionType {
76 Disabled,
78 SingleSelection,
80 MultipleSelections,
82 SingleRecommendation,
84 SnippetSelection,
86}