Add theme keys for the picker header area (#11343)

* feat: pertty header

* 更新 themes.md

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
pull/11371/head
麦芽糖 4 months ago committed by GitHub
parent 8e041c99df
commit 08ac37d295
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -297,8 +297,9 @@ These scopes are used for theming the editor interface:
| `ui.bufferline.background` | Style for bufferline background | | `ui.bufferline.background` | Style for bufferline background |
| `ui.popup` | Documentation popups (e.g. Space + k) | | `ui.popup` | Documentation popups (e.g. Space + k) |
| `ui.popup.info` | Prompt for multiple key options | | `ui.popup.info` | Prompt for multiple key options |
| `ui.picker.header` | Column names in pickers with multiple columns | | `ui.picker.header` | Header row area 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.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.window` | Borderlines separating splits |
| `ui.help` | Description box for commands | | `ui.help` | Description box for commands |
| `ui.text` | Default text style, command prompts, popup text, etc. | | `ui.text` | Default text style, command prompts, popup text, etc. |

@ -799,21 +799,25 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
if self.columns.len() > 1 { if self.columns.len() > 1 {
let active_column = self.query.active_column(self.prompt.position()); let active_column = self.query.active_column(self.prompt.position());
let header_style = cx.editor.theme.get("ui.picker.header"); 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| { table = table.header(
Row::new(self.columns.iter().map(|column| {
if column.hidden { if column.hidden {
Cell::default() Cell::default()
} else { } else {
let style = if active_column.is_some_and(|name| Arc::ptr_eq(name, &column.name)) let style =
{ if active_column.is_some_and(|name| Arc::ptr_eq(name, &column.name)) {
cx.editor.theme.get("ui.picker.header.active") cx.editor.theme.get("ui.picker.header.column.active")
} else { } else {
header_style 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; use tui::widgets::TableState;

Loading…
Cancel
Save