From 649c2b3e623c26228faf9630b983ebba9c68e009 Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Sat, 10 Dec 2022 09:56:12 +0000 Subject: [PATCH 1/2] Make prompt suggestions greyed out --- book/src/themes.md | 1 + helix-term/src/ui/prompt.rs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index 392b5f8c956a..bebc7b47bedf 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -268,6 +268,7 @@ These scopes are used for theming the editor interface. | `ui.help` | Description box for commands | | `ui.text` | Command prompts, popup text, etc. | | `ui.text.focus` | | +| `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) | | `ui.text.info` | The key: command text in `ui.popup.info` boxes | | `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) | | `ui.virtual.whitespace` | Visible whitespace characters | diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index b19b9a9fce90..5fb6745a90e5 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -352,6 +352,7 @@ impl Prompt { let prompt_color = theme.get("ui.text"); let completion_color = theme.get("ui.menu"); let selected_color = theme.get("ui.menu.selected"); + let suggestion_color = theme.get("ui.text.inactive"); // completion let max_len = self @@ -450,21 +451,29 @@ impl Prompt { // render buffer text surface.set_string(area.x, area.y + line, &self.prompt, prompt_color); - let input: Cow = if self.line.is_empty() { + let (input, is_suggestion): (Cow, bool) = if self.line.is_empty() { // latest value in the register list - self.history_register + match self + .history_register .and_then(|reg| cx.editor.registers.last(reg)) .map(|entry| entry.into()) - .unwrap_or_else(|| Cow::from("")) + { + Some(value) => (value, true), + None => (Cow::from(""), false), + } } else { - self.line.as_str().into() + (self.line.as_str().into(), false) }; surface.set_string( area.x + self.prompt.len() as u16, area.y + line, &input, - prompt_color, + if is_suggestion { + suggestion_color + } else { + prompt_color + }, ); } } From 3ee53fcbd06b904f124fc2aaf731d9d56d90953c Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Sat, 10 Dec 2022 09:56:37 +0000 Subject: [PATCH 2/2] Set ui.text.inactive for official themes --- base16_theme.toml | 1 + theme.toml | 1 + 2 files changed, 2 insertions(+) diff --git a/base16_theme.toml b/base16_theme.toml index 63fc2f790e72..268a38df61bd 100644 --- a/base16_theme.toml +++ b/base16_theme.toml @@ -7,6 +7,7 @@ "ui.linenr.selected" = { fg = "white", bg = "black", modifiers = ["bold"] } "ui.selection" = { fg = "black", bg = "blue" } "ui.selection.primary" = { fg = "white", bg = "blue" } +"ui.text.inactive" = { fg = "gray" } "comment" = { fg = "gray" } "ui.statusline" = { fg = "black", bg = "white" } "ui.statusline.inactive" = { fg = "gray", bg = "white" } diff --git a/theme.toml b/theme.toml index 054093195a87..c7b5dc84e7e0 100644 --- a/theme.toml +++ b/theme.toml @@ -54,6 +54,7 @@ label = "honey" "ui.text" = { fg = "lavender" } "ui.text.focus" = { fg = "white" } +"ui.text.inactive" = "sirocco" "ui.virtual" = { fg = "comet" } "ui.virtual.indent-guide" = { fg = "comet" }