From d6a9c2c0f6f4af98146b52d1c886a1ca99d15676 Mon Sep 17 00:00:00 2001 From: CossonLeo <20379044+cossonleo@users.noreply.github.com> Date: Sat, 28 Aug 2021 12:54:24 +0800 Subject: [PATCH] Add ui.menu text style (#664) * add menu text style * add ui.menu.text ui.info ui.info.text to book * change ui.menu.text to ui.menu * fix book's ui.menu --- book/src/themes.md | 3 +++ helix-term/src/ui/menu.rs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index f17195aaa..0a4d58ad5 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -91,6 +91,9 @@ ## Creating a theme | `ui.help` | | | `ui.text` | | | `ui.text.focus` | | +| `ui.info` | | +| `ui.info.text` | | +| `ui.menu` | | | `ui.menu.selected` | | | `ui.selection` | For selections in the editing area | | `ui.selection.primary` | | diff --git a/helix-term/src/ui/menu.rs b/helix-term/src/ui/menu.rs index a56cf19b2..24dd3e618 100644 --- a/helix-term/src/ui/menu.rs +++ b/helix-term/src/ui/menu.rs @@ -259,8 +259,11 @@ fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> { // TODO: required size should re-trigger when we filter items so we can draw a smaller menu fn render(&mut self, area: Rect, surface: &mut Surface, cx: &mut Context) { - let style = cx.editor.theme.get("ui.text"); - let selected = cx.editor.theme.get("ui.menu.selected"); + let theme = &cx.editor.theme; + let style = theme + .try_get("ui.menu") + .unwrap_or_else(|| theme.get("ui.text")); + let selected = theme.get("ui.menu.selected"); let scroll = self.scroll;