on master help sign in
Make prompt suggestions greyed out
commit24cd7f6adf7a46b8386583b17f01839eb592a2eb authorJonathan LEI <me@xjonathan.dev> dateSat 10 Dec 2022, 09:56 (4 years ago) parent042d032
2 files changed+15−5
book/src/themes.md+1 helix-term/src/ui/prompt.rs+14−5
book/src/themes.md+1
@@ -268,6 +268,7 @@ These scopes are used for theming the editor interface.
268268| `ui.help` | Description box for commands |
269269| `ui.text` | Command prompts, popup text, etc. |
270270| `ui.text.focus` | |
271+| `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) |
271272| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
272273| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
273274| `ui.virtual.whitespace` | Visible whitespace characters |
helix-term/src/ui/prompt.rs+14−5
@@ -352,6 +352,7 @@ impl Prompt {
352352 let prompt_color = theme.get("ui.text");
353353 let completion_color = theme.get("ui.menu");
354354 let selected_color = theme.get("ui.menu.selected");
355+ let suggestion_color = theme.get("ui.text.inactive");
355356 // completion
356357
357358 let max_len = self
@@ -450,21 +451,29 @@ impl Prompt {
450451 // render buffer text
451452 surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);
452453
453− let input: Cow<str> = if self.line.is_empty() {
454+ let (input, is_suggestion): (Cow<str>, bool) = if self.line.is_empty() {
454455 // latest value in the register list
455− self.history_register
456+ match self
457+ .history_register
456458 .and_then(|reg| cx.editor.registers.last(reg))
457459 .map(|entry| entry.into())
458− .unwrap_or_else(|| Cow::from(""))
460+ {
461+ Some(value) => (value, true),
462+ None => (Cow::from(""), false),
463+ }
459464 } else {
460− self.line.as_str().into()
465+ (self.line.as_str().into(), false)
461466 };
462467
463468 surface.set_string(
464469 area.x + self.prompt.len() as u16,
465470 area.y + line,
466471 &input,
467− prompt_color,
472+ if is_suggestion {
473+ suggestion_color
474+ } else {
475+ prompt_color
476+ },
468477 );
469478 }
470479}