pub enum SearchMode {
    NameExact,
    NameFuzzy,
    NameRegex,
    NameTokens,
    PathExact,
    PathFuzzy,
    PathRegex,
    PathTokens,
    ContentExact,
    ContentRegex,
}
Expand description

a valid combination of SearchObject and SearchKind, determine how a pattern will be used

Variants§

§

NameExact

§

NameFuzzy

§

NameRegex

§

NameTokens

§

PathExact

§

PathFuzzy

§

PathRegex

§

PathTokens

§

ContentExact

§

ContentRegex

Implementations§

Return the prefix to type, eg “/” in standard for a name-regex, “” for a name-fuzzy, and “ep” for a path-exact

Examples found in repository?
src/help/help_search_modes.rs (line 18)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub fn search_mode_help(mode: SearchMode, con: &AppContext) -> SearchModeHelp {
    let prefix = mode.prefix(con);
    let description = format!(
        "{} search on {}",
        match mode.kind() {
            SearchKind::Exact => "exact string",
            SearchKind::Fuzzy => "fuzzy",
            SearchKind::Regex => "regex",
            SearchKind::Tokens => "tokens",
        },
        match mode.object() {
            SearchObject::Name => "file name",
            SearchObject::Path => "sub path",
            SearchObject::Content => "file content",
        },
    );
    let example = match mode {
        SearchMode::NameExact => format!("`{prefix}feat` matches *help_features.rs*"),
        SearchMode::NameFuzzy => format!("`{prefix}conh` matches *DefaultConf.hjson*"),
        SearchMode::NameRegex => format!("`{prefix}rs$` matches *build.rs*"),
        SearchMode::NameTokens => format!("`{prefix}fea,he` matches *HelpFeature.java*"),
        SearchMode::PathExact => format!("`{prefix}te\\/do` matches *website/docs*"),
        SearchMode::PathFuzzy => format!("`{prefix}flam` matches *src/flag/mod.rs*"),
        SearchMode::PathRegex => format!(r#"`{prefix}\d{{3}}.*txt` matches *dir/a123/b.txt*"#),
        SearchMode::PathTokens => format!("`{prefix}help,doc` matches *website/docs/help.md*"),
        SearchMode::ContentExact => format!("`{prefix}find(` matches a file containing *a.find(b);*"),
        SearchMode::ContentRegex => format!("`{prefix}find/i` matches a file containing *A::Find(b)*"),
    };
    SearchModeHelp {
        prefix,
        description,
        example,
    }
}
More examples
Hide additional examples
src/help/help_state.rs (line 171)
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    fn display(
        &mut self,
        w: &mut W,
        disc: &DisplayContext,
    ) -> Result<(), ProgramError> {
        let con = &disc.con;
        let mut text_area = disc.state_area.clone();
        text_area.pad_for_max_width(120);
        if text_area != self.text_area {
            self.dirty = true;
            self.text_area = text_area;
        }
        if self.dirty {
            disc.panel_skin.styles.default.queue_bg(w)?;
            disc.screen.clear_area_to_right(w, &disc.state_area)?;
            self.dirty = false;
        }
        let mut expander = help_content::expander();
        expander.set("version", env!("CARGO_PKG_VERSION"));
        let config_paths: Vec<String> = con.config_paths.iter()
            .map(|p| p.to_string_lossy().to_string())
            .collect();
        for path in &config_paths {
            expander.sub("config-files")
                .set("path", path);
        }
        let verb_rows = super::help_verbs::matching_verb_rows(&self.pattern, con);
        for row in &verb_rows {
            let sub = expander
                .sub("verb-rows")
                .set_md("name", row.name())
                .set_md("shortcut", row.shortcut())
                .set("key", &row.verb.keys_desc);
            if row.verb.description.code {
                sub.set("description", "");
                sub.set("execution", &row.verb.description.content);
            } else {
                sub.set_md("description", &row.verb.description.content);
                sub.set("execution", "");
            }
        }
        let mode_help;
        if let Ok(default_mode) = con.search_modes.search_mode(None) {
            mode_help = super::search_mode_help(default_mode, con);
            expander
                .sub("default-search")
                .set_md("default-search-example", &mode_help.example);
        }
        let search_rows: Vec<SearchModeHelp> = SEARCH_MODES
            .iter()
            .map(|mode| super::search_mode_help(*mode, con))
            .collect();
        for row in &search_rows {
            expander
                .sub("search-mode-rows")
                .set("search-prefix", &row.prefix)
                .set("search-type", &row.description)
                .set_md("search-example", &row.example);
        }
        let nr_prefix = SearchMode::NameRegex.prefix(con);
        let ce_prefix = SearchMode::ContentExact.prefix(con);
        expander
            .set("nr-prefix", &nr_prefix)
            .set("ce-prefix", &ce_prefix);
        let features = super::help_features::list();
        expander.set(
            "features-text",
            if features.is_empty() {
                "This release was compiled with no optional feature enabled."
            } else {
                "This release was compiled with those optional features enabled:"
            },
        );
        for feature in &features {
            expander
                .sub("features")
                .set("feature-name", feature.0)
                .set("feature-description", feature.1);
        }
        let text = expander.expand();
        let fmt_text = FmtText::from_text(
            &disc.panel_skin.help_skin,
            text,
            Some((self.text_area.width - 1) as usize),
        );
        let mut text_view = TextView::from(&self.text_area, &fmt_text);
        self.scroll = text_view.set_scroll(self.scroll);
        Ok(text_view.write_on(w)?)
    }
Examples found in repository?
src/help/help_search_modes.rs (line 27)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub fn search_mode_help(mode: SearchMode, con: &AppContext) -> SearchModeHelp {
    let prefix = mode.prefix(con);
    let description = format!(
        "{} search on {}",
        match mode.kind() {
            SearchKind::Exact => "exact string",
            SearchKind::Fuzzy => "fuzzy",
            SearchKind::Regex => "regex",
            SearchKind::Tokens => "tokens",
        },
        match mode.object() {
            SearchObject::Name => "file name",
            SearchObject::Path => "sub path",
            SearchObject::Content => "file content",
        },
    );
    let example = match mode {
        SearchMode::NameExact => format!("`{prefix}feat` matches *help_features.rs*"),
        SearchMode::NameFuzzy => format!("`{prefix}conh` matches *DefaultConf.hjson*"),
        SearchMode::NameRegex => format!("`{prefix}rs$` matches *build.rs*"),
        SearchMode::NameTokens => format!("`{prefix}fea,he` matches *HelpFeature.java*"),
        SearchMode::PathExact => format!("`{prefix}te\\/do` matches *website/docs*"),
        SearchMode::PathFuzzy => format!("`{prefix}flam` matches *src/flag/mod.rs*"),
        SearchMode::PathRegex => format!(r#"`{prefix}\d{{3}}.*txt` matches *dir/a123/b.txt*"#),
        SearchMode::PathTokens => format!("`{prefix}help,doc` matches *website/docs/help.md*"),
        SearchMode::ContentExact => format!("`{prefix}find(` matches a file containing *a.find(b);*"),
        SearchMode::ContentRegex => format!("`{prefix}find/i` matches a file containing *A::Find(b)*"),
    };
    SearchModeHelp {
        prefix,
        description,
        example,
    }
}
Examples found in repository?
src/help/help_search_modes.rs (line 21)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
pub fn search_mode_help(mode: SearchMode, con: &AppContext) -> SearchModeHelp {
    let prefix = mode.prefix(con);
    let description = format!(
        "{} search on {}",
        match mode.kind() {
            SearchKind::Exact => "exact string",
            SearchKind::Fuzzy => "fuzzy",
            SearchKind::Regex => "regex",
            SearchKind::Tokens => "tokens",
        },
        match mode.object() {
            SearchObject::Name => "file name",
            SearchObject::Path => "sub path",
            SearchObject::Content => "file content",
        },
    );
    let example = match mode {
        SearchMode::NameExact => format!("`{prefix}feat` matches *help_features.rs*"),
        SearchMode::NameFuzzy => format!("`{prefix}conh` matches *DefaultConf.hjson*"),
        SearchMode::NameRegex => format!("`{prefix}rs$` matches *build.rs*"),
        SearchMode::NameTokens => format!("`{prefix}fea,he` matches *HelpFeature.java*"),
        SearchMode::PathExact => format!("`{prefix}te\\/do` matches *website/docs*"),
        SearchMode::PathFuzzy => format!("`{prefix}flam` matches *src/flag/mod.rs*"),
        SearchMode::PathRegex => format!(r#"`{prefix}\d{{3}}.*txt` matches *dir/a123/b.txt*"#),
        SearchMode::PathTokens => format!("`{prefix}help,doc` matches *website/docs/help.md*"),
        SearchMode::ContentExact => format!("`{prefix}find(` matches a file containing *a.find(b);*"),
        SearchMode::ContentRegex => format!("`{prefix}find/i` matches a file containing *A::Find(b)*"),
    };
    SearchModeHelp {
        prefix,
        description,
        example,
    }
}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.