on master help sign in
Make prompt suggestions greyed out
24cd7f6Jonathan LEI
book/src/themes.md+1
@@ -268,6 +268,7 @@ These scopes are used for theming the editor interface.
268| `ui.help` | Description box for commands |
268| `ui.help` | Description box for commands |
269| `ui.text` | Command prompts, popup text, etc. |
269| `ui.text` | Command prompts, popup text, etc. |
270| `ui.text.focus` | |
270| `ui.text.focus` | |
271+| `ui.text.inactive` | Same as `ui.text` but when the text is inactive (e.g. suggestions) |
271| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
272| `ui.text.info` | The key: command text in `ui.popup.info` boxes |
272| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
273| `ui.virtual.ruler` | Ruler columns (see the [`editor.rulers` config][editor-section]) |
273| `ui.virtual.whitespace` | Visible whitespace characters |
274| `ui.virtual.whitespace` | Visible whitespace characters |
helix-term/src/ui/prompt.rs+14−5
@@ -352,6 +352,7 @@ impl Prompt {
352 let prompt_color = theme.get("ui.text");
352 let prompt_color = theme.get("ui.text");
353 let completion_color = theme.get("ui.menu");
353 let completion_color = theme.get("ui.menu");
354 let selected_color = theme.get("ui.menu.selected");
354 let selected_color = theme.get("ui.menu.selected");
355+ let suggestion_color = theme.get("ui.text.inactive");
355 // completion
356 // completion
356
357
357 let max_len = self
358 let max_len = self
@@ -450,21 +451,29 @@ impl Prompt {
450 // render buffer text
451 // render buffer text
451 surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);
452 surface.set_string(area.x, area.y + line, &self.prompt, prompt_color);
452
453
453− let input: Cow<str> = if self.line.is_empty() {
454+ let (input, is_suggestion): (Cow<str>, bool) = if self.line.is_empty() {
454 // latest value in the register list
455 // latest value in the register list
456+ match self
455− self.history_register
457+ .history_register
456 .and_then(|reg| cx.editor.registers.last(reg))
458 .and_then(|reg| cx.editor.registers.last(reg))
457 .map(|entry| entry.into())
459 .map(|entry| entry.into())
458− .unwrap_or_else(|| Cow::from(""))
460+ {
461+ Some(value) => (value, true),
462+ None => (Cow::from(""), false),
463+ }
459 } else {
464 } else {
460− self.line.as_str().into()
465+ (self.line.as_str().into(), false)
461 };
466 };
462
467
463 surface.set_string(
468 surface.set_string(
464 area.x + self.prompt.len() as u16,
469 area.x + self.prompt.len() as u16,
465 area.y + line,
470 area.y + line,
466 &input,
471 &input,
472+ if is_suggestion {
473+ suggestion_color
474+ } else {
467− prompt_color,
475+ prompt_color
476+ },
468 );
477 );
469 }
478 }
470}
479}