Commit 952fea55b0

952fea55b0482683dfeec5e0f5ae7c345ec29eb8

parent: 195cabfdc3

Unregistered key

vaw <git@nlih.de> · 2026-09-26 19:43 UTC
committer: <noreply@github.com>

Add `theme.completion` to style the completion menu (#755)

Layout: unified · split

docs/iamb.5 +8
@@ -835,6 +835,14 @@ to force all usernames to use the value in
835.Sy color 835.Sy color
836or its inherited value from 836or its inherited value from
837.Sy "theme.default" . 837.Sy "theme.default" .
838.It Sy completion
839For controlling how the completion menu is styled.
840.Bl -tag -width Ds
841.It Sy default
842Configure the default style for entries in the menu.
843.It Sy selected
844Configure how the selected entry is styled.
845.El
838.It Sy windows 846.It Sy windows
839For controlling how the windows are styled. 847For controlling how the windows are styled.
840.Bl -tag -width Ds 848.Bl -tag -width Ds
src/config/theme.rs +55
@@ -34,6 +34,21 @@ pub fn default_theme() -> Theme {
34 title: Stylable::with_modifiers(StyleModifier::BOLD), 34 title: Stylable::with_modifiers(StyleModifier::BOLD),
35 ..Default::default() 35 ..Default::default()
36 }, 36 },
37 completion: ThemeCompletion {
38 default: Stylable {
39 color: Some(Color::Reset),
40 background: Some(Color::Reset),
41 modifiers: vec![
42 ModifierChange::Remove(StyleModifier::all()),
43 ModifierChange::Insert(StyleModifier::REVERSED),
44 ],
45 },
46 selected: Stylable {
47 color: Some(Color::Yellow),
48 background: Some(Color::Black),
49 modifiers: vec![ModifierChange::Remove(StyleModifier::REVERSED)],
50 },
51 },
37 timeline: ThemeTimeline { 52 timeline: ThemeTimeline {
38 date: Stylable::with_modifiers(StyleModifier::BOLD), 53 date: Stylable::with_modifiers(StyleModifier::BOLD),
39 unread_marker: Stylable::with_modifiers(StyleModifier::DIM), 54 unread_marker: Stylable::with_modifiers(StyleModifier::DIM),
@@ -241,6 +256,10 @@ pub struct Theme {
241 /// Configuration for styling windows. 256 /// Configuration for styling windows.
242 #[serde(default)] 257 #[serde(default)]
243 windows: ThemeWindows, 258 windows: ThemeWindows,
259
260 /// Configuration for the completion menu.
261 #[serde(default)]
262 completion: ThemeCompletion,
244} 263}
245 264
246impl Theme { 265impl Theme {
@@ -256,6 +275,7 @@ impl Theme {
256 rooms: self.rooms.merge(other.rooms), 275 rooms: self.rooms.merge(other.rooms),
257 users: self.users.merge(other.users), 276 users: self.users.merge(other.users),
258 windows: self.windows.merge(other.windows), 277 windows: self.windows.merge(other.windows),
278 completion: self.completion.merge(other.completion),
259 } 279 }
260 } 280 }
261 281
@@ -273,6 +293,7 @@ impl Theme {
273 tabs: self.tabs.values(base), 293 tabs: self.tabs.values(base),
274 users: self.users.values(base), 294 users: self.users.values(base),
275 windows: self.windows.values(base), 295 windows: self.windows.values(base),
296 completion: self.completion.values(base),
276 } 297 }
277 } 298 }
278} 299}
@@ -308,6 +329,9 @@ pub struct ThemeValues {
308 329
309 /// Styling for rendering windows. 330 /// Styling for rendering windows.
310 pub windows: ThemeWindowsValues, 331 pub windows: ThemeWindowsValues,
332
333 /// Styling for the completion menu.
334 pub completion: ThemeCompletionValues,
311} 335}
312 336
313#[derive(Clone, Debug, Default, Deserialize)] 337#[derive(Clone, Debug, Default, Deserialize)]
@@ -644,6 +668,37 @@ pub struct ThemeTimelineValues {
644 pub unread_marker: Style, 668 pub unread_marker: Style,
645} 669}
646 670
671#[derive(Clone, Debug, Default, Deserialize)]
672struct ThemeCompletion {
673 #[serde(default)]
674 default: Stylable,
675
676 #[serde(default)]
677 selected: Stylable,
678}
679
680impl ThemeCompletion {
681 fn merge(self, other: Self) -> Self {
682 Self {
683 default: self.default.merge(other.default),
684 selected: self.selected.merge(other.selected),
685 }
686 }
687
688 fn values(self, base: Style) -> ThemeCompletionValues {
689 let default = base.patch(self.default);
690 let selected = default.patch(self.selected);
691
692 ThemeCompletionValues { default, selected }
693 }
694}
695
696#[derive(Clone, Debug, Default)]
697pub struct ThemeCompletionValues {
698 pub default: Style,
699 pub selected: Style,
700}
701
647#[derive(Clone, Debug, Default, Deserialize)] 702#[derive(Clone, Debug, Default, Deserialize)]
648struct ThemeWindows { 703struct ThemeWindows {
649 #[serde(default)] 704 #[serde(default)]
src/main.rs +2
@@ -318,6 +318,8 @@ impl Application {
318 .cmdbar_style(theme.cmdbar.default) 318 .cmdbar_style(theme.cmdbar.default)
319 .tab_style(theme.tabs.title) 319 .tab_style(theme.tabs.title)
320 .tab_style_focused(theme.tabs.title_focused) 320 .tab_style_focused(theme.tabs.title_focused)
321 .completion_style(theme.completion.default)
322 .completion_style_selected(theme.completion.selected)
321 .focus(focused); 323 .focus(focused);
322 f.render_stateful_widget(screen, area, sstate); 324 f.render_stateful_widget(screen, area, sstate);
323 325