Function broot::help::search_mode_help
source · pub fn search_mode_help(mode: SearchMode, con: &AppContext) -> SearchModeHelp
Expand description
return the rows of the “Search Modes” table in help.
Examples found in repository?
src/help/help_state.rs (line 155)
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)?)
}