Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new theme scope ui.text.inactive for prompt suggestions #5104

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions base16_theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
19 changes: 14 additions & 5 deletions helix-term/src/ui/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -450,21 +451,29 @@ impl Prompt {
// render buffer text
surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);

let input: Cow<str> = if self.line.is_empty() {
let (input, is_suggestion): (Cow<str>, 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
},
);
}
}
Expand Down
1 change: 1 addition & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down