From 08ac37d295d91ff5ccb73ac065e0736d1ae0f664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BA=A6=E8=8A=BD=E7=B3=96?= Date: Mon, 29 Jul 2024 22:52:15 +0800 Subject: [PATCH] Add theme keys for the picker header area (#11343) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: pertty header * 更新 themes.md Co-authored-by: Michael Davis --------- Co-authored-by: Michael Davis --- book/src/themes.md | 7 ++++--- helix-term/src/ui/picker.rs | 28 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/book/src/themes.md b/book/src/themes.md index f9f8393c..1bc2627d 100644 --- a/book/src/themes.md +++ b/book/src/themes.md @@ -293,12 +293,13 @@ These scopes are used for theming the editor interface: | `ui.statusline.select` | Statusline mode during select mode ([only if `editor.color-modes` is enabled][editor-section]) | | `ui.statusline.separator` | Separator character in statusline | | `ui.bufferline` | Style for the buffer line | -| `ui.bufferline.active` | Style for the active buffer in buffer line | +| `ui.bufferline.active` | Style for the active buffer in buffer line | | `ui.bufferline.background` | Style for bufferline background | | `ui.popup` | Documentation popups (e.g. Space + k) | | `ui.popup.info` | Prompt for multiple key options | -| `ui.picker.header` | Column names in pickers with multiple columns | -| `ui.picker.header.active` | The column name in pickers with multiple columns where the cursor is entering into. | +| `ui.picker.header` | Header row area in pickers with multiple columns | +| `ui.picker.header.column` | Column names in pickers with multiple columns | +| `ui.picker.header.column.active` | The column name in pickers with multiple columns where the cursor is entering into. | | `ui.window` | Borderlines separating splits | | `ui.help` | Description box for commands | | `ui.text` | Default text style, command prompts, popup text, etc. | diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 118dafa7..82fe9689 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -799,21 +799,25 @@ impl Picker { if self.columns.len() > 1 { let active_column = self.query.active_column(self.prompt.position()); let header_style = cx.editor.theme.get("ui.picker.header"); + let header_column_style = cx.editor.theme.get("ui.picker.header.column"); - table = table.header(Row::new(self.columns.iter().map(|column| { - if column.hidden { - Cell::default() - } else { - let style = if active_column.is_some_and(|name| Arc::ptr_eq(name, &column.name)) - { - cx.editor.theme.get("ui.picker.header.active") + table = table.header( + Row::new(self.columns.iter().map(|column| { + if column.hidden { + Cell::default() } else { - header_style - }; + let style = + if active_column.is_some_and(|name| Arc::ptr_eq(name, &column.name)) { + cx.editor.theme.get("ui.picker.header.column.active") + } else { + header_column_style + }; - Cell::from(Span::styled(Cow::from(&*column.name), style)) - } - }))); + Cell::from(Span::styled(Cow::from(&*column.name), style)) + } + })) + .style(header_style), + ); } use tui::widgets::TableState;