Commit a99b1160f6

a99b1160f6ded21e2a37cd1aa125d555a4952922

parent: ff4d92e890

Unregistered key

Ulyssa <git@ulyssa.dev> · 2026-09-24 06:53 UTC
committer: <noreply@github.com>

Support using style modifiers in the `theme` section (#740)

Layout: unified · split

config.example.toml +1
@@ -92,5 +92,6 @@ downloads = "/home/user/Downloads/"
9292[theme]
9393timeline.state.color = "cyan"
9494timeline.redacted.color = "245" # light gray
95timeline.redacted.modifiers = ["bold"] # make redacted messages bold
9596# How to use truecolor for terminals that support it:
9697# rooms.unread.color = "#ff55bb" # pink
docs/iamb.5 +82 −2
@@ -687,11 +687,56 @@ Configure the background color for text.
687687See the
688688.Sx "COLORS"
689689section for the supported color format.
690.It Sy modifiers
691An array of strings specifying modifiers to how the text is styled.
692Possible values are
693.Dq Sy "bold" ,
694.Dq Sy "crossed-out" ,
695.Dq Sy "dim" ,
696.Dq Sy "hidden" ,
697.Dq Sy "italic" ,
698.Dq Sy "rapid-blink" ,
699.Dq Sy "reversed" ,
700.Dq Sy "slow-blink" ,
701and
702.Dq Sy "underlined" .
703Modifier names prefixed with
704.Sy ~
705will remove the modifier if it was inherited from another default, global config, etc.
690706.El
707.Pp
691708Within
692709.Sy theme ,
693710there are several subsections for specific UI areas:
694711.Bl -tag -width Ds
712.It Sy default
713The base, default style that everything else should inherit.
714.It Sy cmdbar
715For controlling how the text in the command bar is styled.
716.Bl -tag -width Ds
717.It Sy default
718Configure the default styling for the command bar.
719.El
720.It Sy encryption
721For controlling how the encryption indicators are styled.
722UI elements you can set within this subsection are:
723.Bl -tag -width Ds
724.It Sy default
725Configure the default styling for the encryption status indicators.
726.It Sy icon_encrypted
727Configure the styling for the encrypted indicator.
728.It Sy icon_unencrypted
729Configure the styling for the unencrypted indicator.
730.It Sy icon_unknown
731Configure the styling for the unknown encryption status indicator.
732.El
733.It Sy msgbar
734For controlling how the text in the message bar is styled.
735UI elements you can set within this subsection are:
736.Bl -tag -width Ds
737.It Sy default
738Configure the default styling for the message bar.
739.El
695740.It Sy messages
696741For controlling how the bodies of messages are styled.
697742UI elements you can set within this subsection are:
@@ -706,6 +751,29 @@ elements in formatted message bodies.
706751Configure the styling for
707752.Sy "<pre>"
708753elements in formatted message bodies.
754.It Sy "emphasis"
755Configure the styling for
756.Sy "<em>"
757and
758.Sy "<i>"
759elements in formatted message bodies.
760.It Sy "strikethrough"
761Configure the styling for
762.Sy "<del>" ,
763.Sy "<s>" ,
764and
765.Sy "<strike>"
766elements in formatted message bodies.
767.It Sy "strong"
768Configure the styling for
769.Sy "<strong>"
770and
771.Sy "<b>"
772elements in formatted message bodies.
773.It Sy "underlined"
774Configure the styling for
775.Sy "<u>"
776elements in formatted message bodies.
709777.El
710778.It Sy timeline
711779For controlling how other elements within the timeline are styled.
@@ -717,6 +785,8 @@ Configure the default styling for text in the timeline.
717785Configure the how the dates for messages are styled.
718786.It Sy time
719787Configure the how the time a message was sent is styled.
788.It Sy unread_marker
789Configure the style of the bar for marking the start of unread messages.
720790.It Sy state
721791Configure how the text shown for state events is styled.
722792.It Sy sticker
@@ -731,6 +801,8 @@ Configure how redacted events in the timeline is styled.
731801.It Sy windows
732802For controlling how the windows are styled.
733803.Bl -tag -width Ds
804.It Sy default
805Configure the default style for characters that draw the window border or title.
734806.It Sy border
735807Configure how the border characters are styled.
736808.It Sy border_focused
@@ -757,11 +829,13 @@ UI elements you can set within this subsection are:
757829.Bl -tag -width Ds
758830.It Sy default
759831Configure the default style for text in room lists.
832.It Sy labels
833Configure the style for the labels following room names in lists.
760834.It Sy unread
761Configure the text for unread rooms in lists is styled.
835Configure the style for unread room names in lists.
762836.El
763837.El
764.Ss Example: Make code blocks a lighter gray background and state events red
838.Ss Example 1: Make code blocks a lighter gray background and state events red
765839.Bd -literal -offset indent
766840[theme.messages]
767841code_block.background = "245"
@@ -769,6 +843,12 @@ code_block.background = "245"
769843[theme.timeline]
770844state.color = "cyan"
771845.Ed
846.Ss Example 2: Replace default bold style in window and tab titles with italic
847.Bd -literal -offset indent
848[theme]
849tabs.title.modifiers = ["~bold", "italic"]
850windows.title.modifiers = ["~bold", "italic"]
851.Ed
772852.Sh "USER OVERRIDES"
773853The
774854.Sy settings.users
src/config/mod.rs +80 −27
@@ -573,6 +573,7 @@ impl EncryptionValues {
573573 &self,
574574 location: EncryptionIndicatorLocation,
575575 state: EncryptionState,
576 theme: &ThemeValues,
576577 ) -> Option<Span<'static>> {
577578 if !self.indicator_location.contains(location) {
578579 return None;
@@ -590,19 +591,19 @@ impl EncryptionValues {
590591 EncryptionState::Encrypted,
591592 ) => {
592593 // Green encrypted icon:
593 Span::styled(self.icon_encrypted.clone(), Style::new().fg(Color::LightGreen))
594 Span::styled(self.icon_encrypted.clone(), theme.encryption.icon_encrypted)
594595 },
595596 (
596597 EncryptionIndicator::Enabled | EncryptionIndicator::OnlyUnencrypted,
597598 EncryptionState::NotEncrypted,
598599 ) => {
599600 // Red unencrypted icon:
600 Span::styled(self.icon_unencrypted.clone(), Style::new().fg(Color::Red))
601 Span::styled(self.icon_unencrypted.clone(), theme.encryption.icon_unencrypted)
601602 },
602603
603604 (_, EncryptionState::Unknown) => {
604605 // Yellow unknown icon:
605 Span::styled(self.icon_unknown.clone(), Style::new().fg(Color::Yellow))
606 Span::styled(self.icon_unknown.clone(), theme.encryption.icon_unknown)
606607 },
607608 };
608609
@@ -1951,22 +1952,35 @@ mod tests {
19511952 ..Default::default()
19521953 };
19531954 let enc = enc.values();
1955 let theme = theme::ThemeValues::default();
19541956
19551957 // Always shows in the title:
1956 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_some());
19571958 assert!(
1958 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted)
1959 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted, &theme)
1960 .is_some()
1961 );
1962 assert!(
1963 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted, &theme)
1964 .is_some()
1965 );
1966 assert!(
1967 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown, &theme)
19591968 .is_some()
19601969 );
1961 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown).is_some());
19621970
19631971 // Doesn't show in the prompt:
1964 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted).is_none());
19651972 assert!(
1966 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted)
1973 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted, &theme)
1974 .is_none()
1975 );
1976 assert!(
1977 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted, &theme)
1978 .is_none()
1979 );
1980 assert!(
1981 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown, &theme)
19671982 .is_none()
19681983 );
1969 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown).is_none());
19701984 }
19711985
19721986 #[test]
@@ -1979,20 +1993,33 @@ mod tests {
19791993 ..Default::default()
19801994 };
19811995 let enc = enc.values();
1996 let theme = theme::ThemeValues::default();
19821997
19831998 // Never shows in the title or the prompt:
1984 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_none());
19851999 assert!(
1986 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted)
2000 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted, &theme)
2001 .is_none()
2002 );
2003 assert!(
2004 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted, &theme)
2005 .is_none()
2006 );
2007 assert!(
2008 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown, &theme)
2009 .is_none()
2010 );
2011 assert!(
2012 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted, &theme)
2013 .is_none()
2014 );
2015 assert!(
2016 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted, &theme)
19872017 .is_none()
19882018 );
1989 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown).is_none());
1990 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted).is_none());
19912019 assert!(
1992 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted)
2020 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown, &theme)
19932021 .is_none()
19942022 );
1995 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown).is_none());
19962023 }
19972024
19982025 #[test]
@@ -2005,24 +2032,37 @@ mod tests {
20052032 ..Default::default()
20062033 };
20072034 let enc = enc.values();
2035 let theme = theme::ThemeValues::default();
20082036
20092037 // Shows in the prompt when encrypted or unknown:
2010 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted).is_some());
2011 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown).is_some());
2038 assert!(
2039 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted, &theme)
2040 .is_some()
2041 );
2042 assert!(
2043 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown, &theme)
2044 .is_some()
2045 );
20122046
20132047 // But is hidden when unencrypted:
20142048 assert!(
2015 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted)
2049 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted, &theme)
20162050 .is_none()
20172051 );
20182052
20192053 // Doesn't show in the title:
2020 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_none());
20212054 assert!(
2022 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted)
2055 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted, &theme)
2056 .is_none()
2057 );
2058 assert!(
2059 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted, &theme)
2060 .is_none()
2061 );
2062 assert!(
2063 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown, &theme)
20232064 .is_none()
20242065 );
2025 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown).is_none());
20262066 }
20272067 #[test]
20282068 fn test_encryption_indicator_only_unencrypted() {
@@ -2034,21 +2074,34 @@ mod tests {
20342074 ..Default::default()
20352075 };
20362076 let enc = enc.values();
2077 let theme = theme::ThemeValues::default();
20372078
20382079 // Shows in both the prompt and title when unencrypted or unknown:
20392080 assert!(
2040 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted)
2081 enc.get_indicator(EncryptionIndicatorLocation::TITLE, NotEncrypted, &theme)
20412082 .is_some()
20422083 );
2043 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown).is_some());
20442084 assert!(
2045 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted)
2085 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Unknown, &theme)
2086 .is_some()
2087 );
2088 assert!(
2089 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, NotEncrypted, &theme)
2090 .is_some()
2091 );
2092 assert!(
2093 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown, &theme)
20462094 .is_some()
20472095 );
2048 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Unknown).is_some());
20492096
20502097 // But is hidden when encrypted:
2051 assert!(enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted).is_none());
2052 assert!(enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted).is_none());
2098 assert!(
2099 enc.get_indicator(EncryptionIndicatorLocation::TITLE, Encrypted, &theme)
2100 .is_none()
2101 );
2102 assert!(
2103 enc.get_indicator(EncryptionIndicatorLocation::PROMPT, Encrypted, &theme)
2104 .is_none()
2105 );
20532106 }
20542107}
src/config/theme.rs +380 −36
@@ -1,29 +1,160 @@
11//! # Logic for parsing styling configuration into [Style].
2use serde::Deserialize;
2use serde::de::Error as SerdeError;
3use serde::de::Visitor;
4use serde::{Deserialize, Deserializer};
35
46use crate::prelude::*;
57
68pub fn default_theme() -> Theme {
79 Theme {
810 messages: ThemeMessages {
9 code: Stylable { color: None, background: Some(Color::Indexed(236)) },
11 code: Stylable::bg(Color::Indexed(236)),
12 emphasis: Stylable::with_modifiers(StyleModifier::ITALIC),
13 strikethrough: Stylable::with_modifiers(StyleModifier::CROSSED_OUT),
14 strong: Stylable::with_modifiers(StyleModifier::BOLD),
15 underlined: Stylable::with_modifiers(StyleModifier::UNDERLINED),
16 ..Default::default()
17 },
18 encryption: ThemeEncryption {
19 icon_encrypted: Stylable::fg(Color::LightGreen),
20 icon_unencrypted: Stylable::fg(Color::Red),
21 icon_unknown: Stylable::fg(Color::Yellow),
22 ..Default::default()
23 },
24 tabs: ThemeTabs {
25 title: Stylable::with_modifiers(StyleModifier::DIM | StyleModifier::BOLD),
26 title_focused: Stylable::without_modifiers(StyleModifier::DIM),
27 },
28 windows: ThemeWindows {
29 border: Stylable::with_modifiers(StyleModifier::DIM),
30 border_focused: Stylable::without_modifiers(StyleModifier::DIM),
31 title: Stylable::with_modifiers(StyleModifier::BOLD),
32 ..Default::default()
33 },
34 timeline: ThemeTimeline {
35 date: Stylable::with_modifiers(StyleModifier::BOLD),
36 unread_marker: Stylable::with_modifiers(StyleModifier::DIM),
37 ..Default::default()
38 },
39 rooms: ThemeRooms {
40 unread: Stylable::with_modifiers(StyleModifier::BOLD),
1041 ..Default::default()
1142 },
1243 ..Default::default()
1344 }
1445}
1546
16#[derive(Clone, Copy, Debug, Default, Deserialize)]
17pub struct Stylable {
18 pub background: Option<Color>,
19 pub color: Option<Color>,
47#[derive(Clone, Copy, Debug)]
48enum ModifierChange {
49 Insert(StyleModifier),
50 Remove(StyleModifier),
51}
52
53impl ModifierChange {
54 fn apply(self, style: &mut Style) {
55 *style = match self {
56 Self::Insert(m) => style.add_modifier(m),
57 Self::Remove(m) => style.remove_modifier(m),
58 };
59 }
60}
61
62struct ModifierChangeVisitor;
63
64impl<'de> Deserialize<'de> for ModifierChange {
65 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
66 where
67 D: Deserializer<'de>,
68 {
69 deserializer.deserialize_str(ModifierChangeVisitor)
70 }
71}
72
73impl Visitor<'_> for ModifierChangeVisitor {
74 type Value = ModifierChange;
75
76 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
77 formatter.write_str("a valid style modifier (e.g. \"bold\" or \"~reversed\")")
78 }
79
80 fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
81 where
82 E: SerdeError,
83 {
84 let name = value.strip_prefix("~");
85 let remove = name.is_some();
86
87 let modifier = match name.unwrap_or(value) {
88 "bold" => StyleModifier::BOLD,
89 "crossed-out" => StyleModifier::CROSSED_OUT,
90 "dim" => StyleModifier::DIM,
91 "hidden" => StyleModifier::HIDDEN,
92 "italic" => StyleModifier::ITALIC,
93 "rapid-blink" => StyleModifier::RAPID_BLINK,
94 "reversed" => StyleModifier::REVERSED,
95 "slow-blink" => StyleModifier::SLOW_BLINK,
96 "underlined" => StyleModifier::UNDERLINED,
97 other => {
98 let msg = format!("{other:?} is not a valid style modifier");
99 let err = E::custom(msg);
100 return Err(err);
101 },
102 };
103
104 if remove {
105 Ok(ModifierChange::Remove(modifier))
106 } else {
107 Ok(ModifierChange::Insert(modifier))
108 }
109 }
110}
111
112#[derive(Clone, Debug, Default, Deserialize)]
113struct Stylable {
114 background: Option<Color>,
115 color: Option<Color>,
116 #[serde(default)]
117 modifiers: Vec<ModifierChange>,
20118}
21119
22120impl Stylable {
121 fn bg(c: Color) -> Self {
122 Self {
123 background: Some(c),
124 color: None,
125 modifiers: vec![],
126 }
127 }
128
129 fn fg(c: Color) -> Self {
130 Self {
131 background: None,
132 color: Some(c),
133 modifiers: vec![],
134 }
135 }
136
137 fn with_modifiers(m: StyleModifier) -> Self {
138 Self {
139 background: None,
140 color: None,
141 modifiers: vec![ModifierChange::Insert(m)],
142 }
143 }
144
145 fn without_modifiers(m: StyleModifier) -> Self {
146 Self {
147 background: None,
148 color: None,
149 modifiers: vec![ModifierChange::Remove(m)],
150 }
151 }
152
23153 fn merge(self, other: Self) -> Self {
24154 Self {
25155 background: self.background.or(other.background),
26156 color: self.color.or(other.color),
157 modifiers: other.modifiers.iter().chain(&self.modifiers).copied().collect(),
27158 }
28159 }
29160}
@@ -40,12 +171,32 @@ impl From<Stylable> for Style {
40171 style = style.fg(fg);
41172 }
42173
174 for m in styled.modifiers.iter() {
175 m.apply(&mut style);
176 }
177
43178 style
44179 }
45180}
46181
47182#[derive(Clone, Debug, Default, Deserialize)]
48183pub struct Theme {
184 /// Default styling when others aren't specified.
185 #[serde(default)]
186 default: Stylable,
187
188 /// Configuration for styling the command bar.
189 #[serde(default)]
190 cmdbar: ThemeCommandBar,
191
192 /// Configuration for styling the encryption indicators.
193 #[serde(default)]
194 encryption: ThemeEncryption,
195
196 /// Configuration for styling the message bar.
197 #[serde(default)]
198 msgbar: ThemeMessageBar,
199
49200 /// Configuration specificaly for messages shown within a room's timeline.
50201 #[serde(default)]
51202 messages: ThemeMessages,
@@ -70,6 +221,10 @@ pub struct Theme {
70221impl Theme {
71222 pub fn merge(self, other: Self) -> Self {
72223 Self {
224 default: self.default.merge(other.default),
225 cmdbar: self.cmdbar.merge(other.cmdbar),
226 encryption: self.encryption.merge(other.encryption),
227 msgbar: self.msgbar.merge(other.msgbar),
73228 messages: self.messages.merge(other.messages),
74229 tabs: self.tabs.merge(other.tabs),
75230 timeline: self.timeline.merge(other.timeline),
@@ -79,9 +234,13 @@ impl Theme {
79234 }
80235
81236 pub fn values(self) -> ThemeValues {
82 let base = Style::default();
237 let base = Style::from(self.default);
83238
84239 ThemeValues {
240 default: base,
241 cmdbar: self.cmdbar.values(base),
242 encryption: self.encryption.values(base),
243 msgbar: self.msgbar.values(base),
85244 messages: self.messages.values(base),
86245 timeline: self.timeline.values(base),
87246 rooms: self.rooms.values(base),
@@ -93,6 +252,18 @@ impl Theme {
93252
94253#[derive(Clone, Debug, Default)]
95254pub struct ThemeValues {
255 /// Styling to use when nothing more specific applies.
256 pub default: Style,
257
258 /// Styling for the command bar.
259 pub cmdbar: ThemeCommandBarValues,
260
261 /// Styling for the encryption indicators.
262 pub encryption: ThemeEncryptionValues,
263
264 /// Styling for the message bar.
265 pub msgbar: ThemeMessageBarValues,
266
96267 /// Styling specificaly for messages shown within a room's timeline.
97268 pub messages: ThemeMessagesValues,
98269
@@ -119,6 +290,18 @@ struct ThemeMessages {
119290
120291 #[serde(default)]
121292 code_block: Stylable,
293
294 #[serde(default)]
295 emphasis: Stylable,
296
297 #[serde(default)]
298 strikethrough: Stylable,
299
300 #[serde(default)]
301 strong: Stylable,
302
303 #[serde(default)]
304 underlined: Stylable,
122305}
123306
124307impl ThemeMessages {
@@ -127,17 +310,30 @@ impl ThemeMessages {
127310 default: self.default.merge(other.default),
128311 code: self.code.merge(other.code),
129312 code_block: self.code_block.merge(other.code_block),
313 emphasis: self.emphasis.merge(other.emphasis),
314 strong: self.strong.merge(other.strong),
315 strikethrough: self.strikethrough.merge(other.strikethrough),
316 underlined: self.underlined.merge(other.underlined),
130317 }
131318 }
132319
133320 fn values(self, base: Style) -> ThemeMessagesValues {
134 let code = self.code.merge(self.default);
135 let code_block = self.code_block.merge(code);
321 let default = base.patch(self.default);
322 let code = default.patch(self.code);
323 let code_block = code.patch(self.code_block);
324 let emphasis = default.patch(self.emphasis);
325 let strong = default.patch(self.strong);
326 let strikethrough = default.patch(self.strikethrough);
327 let underlined = default.patch(self.underlined);
136328
137329 ThemeMessagesValues {
138 default: base.patch(self.default),
139 code: base.patch(code),
140 code_block: base.patch(code_block),
330 default,
331 code,
332 code_block,
333 emphasis,
334 strong,
335 strikethrough,
336 underlined,
141337 }
142338 }
143339}
@@ -147,6 +343,10 @@ pub struct ThemeMessagesValues {
147343 pub default: Style,
148344 pub code: Style,
149345 pub code_block: Style,
346 pub emphasis: Style,
347 pub strong: Style,
348 pub strikethrough: Style,
349 pub underlined: Style,
150350}
151351
152352#[derive(Clone, Debug, Default, Deserialize)]
@@ -154,6 +354,10 @@ struct ThemeRooms {
154354 #[serde(default)]
155355 default: Stylable,
156356
357 #[serde(default)]
358 labels: Stylable,
359
360 // XXX: use different colors for "mention", "notification", "muted room"
157361 #[serde(default)]
158362 unread: Stylable,
159363}
@@ -162,23 +366,24 @@ impl ThemeRooms {
162366 fn merge(self, other: Self) -> Self {
163367 Self {
164368 default: self.default.merge(other.default),
369 labels: self.labels.merge(other.labels),
165370 unread: self.unread.merge(other.unread),
166371 }
167372 }
168373
169374 fn values(self, base: Style) -> ThemeRoomsValues {
170 let unread = self.unread.merge(self.default);
375 let default = base.patch(self.default);
376 let labels = default.patch(self.labels);
377 let unread = default.patch(self.unread);
171378
172 ThemeRoomsValues {
173 default: base.patch(self.default),
174 unread: base.patch(unread),
175 }
379 ThemeRoomsValues { default, labels, unread }
176380 }
177381}
178382
179383#[derive(Clone, Debug, Default)]
180384pub struct ThemeRoomsValues {
181385 pub default: Style,
386 pub labels: Style,
182387 pub unread: Style,
183388}
184389
@@ -200,12 +405,10 @@ impl ThemeTabs {
200405 }
201406
202407 fn values(self, base: Style) -> ThemeTabsValues {
203 let title_focused = self.title_focused.merge(self.title);
408 let title = base.patch(self.title);
409 let title_focused = title.patch(self.title_focused);
204410
205 ThemeTabsValues {
206 title: base.patch(self.title),
207 title_focused: base.patch(title_focused),
208 }
411 ThemeTabsValues { title, title_focused }
209412 }
210413}
211414
@@ -215,6 +418,99 @@ pub struct ThemeTabsValues {
215418 pub title_focused: Style,
216419}
217420
421#[derive(Clone, Debug, Default, Deserialize)]
422struct ThemeEncryption {
423 #[serde(default)]
424 default: Stylable,
425
426 #[serde(default)]
427 icon_encrypted: Stylable,
428
429 #[serde(default)]
430 icon_unencrypted: Stylable,
431
432 #[serde(default)]
433 icon_unknown: Stylable,
434}
435
436impl ThemeEncryption {
437 fn merge(self, other: Self) -> Self {
438 Self {
439 default: self.default.merge(other.default),
440 icon_encrypted: self.icon_encrypted.merge(other.icon_encrypted),
441 icon_unencrypted: self.icon_unencrypted.merge(other.icon_unencrypted),
442 icon_unknown: self.icon_unknown.merge(other.icon_unknown),
443 }
444 }
445
446 fn values(self, base: Style) -> ThemeEncryptionValues {
447 let default = base.patch(self.default);
448 let icon_encrypted = default.patch(self.icon_encrypted);
449 let icon_unencrypted = default.patch(self.icon_unencrypted);
450 let icon_unknown = default.patch(self.icon_unknown);
451
452 ThemeEncryptionValues {
453 default,
454 icon_encrypted,
455 icon_unencrypted,
456 icon_unknown,
457 }
458 }
459}
460
461#[derive(Clone, Debug, Default)]
462pub struct ThemeEncryptionValues {
463 pub default: Style,
464 pub icon_encrypted: Style,
465 pub icon_unencrypted: Style,
466 pub icon_unknown: Style,
467}
468
469#[derive(Clone, Debug, Default, Deserialize)]
470struct ThemeMessageBar {
471 #[serde(default)]
472 default: Stylable,
473}
474
475impl ThemeMessageBar {
476 fn merge(self, other: Self) -> Self {
477 Self { default: self.default.merge(other.default) }
478 }
479
480 fn values(self, base: Style) -> ThemeMessageBarValues {
481 let default = base.patch(self.default);
482
483 ThemeMessageBarValues { default }
484 }
485}
486
487#[derive(Clone, Debug, Default)]
488pub struct ThemeMessageBarValues {
489 pub default: Style,
490}
491
492#[derive(Clone, Debug, Default, Deserialize)]
493struct ThemeCommandBar {
494 #[serde(default)]
495 default: Stylable,
496}
497
498impl ThemeCommandBar {
499 fn merge(self, other: Self) -> Self {
500 Self { default: self.default.merge(other.default) }
501 }
502
503 fn values(self, base: Style) -> ThemeCommandBarValues {
504 let default = base.patch(self.default);
505 ThemeCommandBarValues { default }
506 }
507}
508
509#[derive(Clone, Debug, Default)]
510pub struct ThemeCommandBarValues {
511 pub default: Style,
512}
513
218514#[derive(Clone, Debug, Default, Deserialize)]
219515struct ThemeTimeline {
220516 #[serde(default)]
@@ -240,6 +536,9 @@ struct ThemeTimeline {
240536
241537 #[serde(default)]
242538 redacted: Stylable,
539
540 #[serde(default)]
541 unread_marker: Stylable,
243542}
244543
245544impl ThemeTimeline {
@@ -253,21 +552,31 @@ impl ThemeTimeline {
253552 poll: self.poll.merge(other.poll),
254553 notice: self.notice.merge(other.notice),
255554 redacted: self.redacted.merge(other.redacted),
555 unread_marker: self.unread_marker.merge(other.unread_marker),
256556 }
257557 }
258558
259559 fn values(self, base: Style) -> ThemeTimelineValues {
260 let base = base.patch(self.default);
560 let default = base.patch(self.default);
561 let date = default.patch(self.date);
562 let time = default.patch(self.time);
563 let state = default.patch(self.state);
564 let sticker = default.patch(self.sticker);
565 let poll = default.patch(self.poll);
566 let notice = default.patch(self.notice);
567 let redacted = default.patch(self.redacted);
568 let unread_marker = default.patch(self.unread_marker);
261569
262570 ThemeTimelineValues {
263 default: base,
264 date: base.patch(self.date),
265 time: base.patch(self.time),
266 state: base.patch(self.state),
267 sticker: base.patch(self.sticker),
268 poll: base.patch(self.poll),
269 notice: base.patch(self.notice),
270 redacted: base.patch(self.redacted),
571 default,
572 date,
573 time,
574 state,
575 sticker,
576 poll,
577 notice,
578 redacted,
579 unread_marker,
271580 }
272581 }
273582}
@@ -282,10 +591,14 @@ pub struct ThemeTimelineValues {
282591 pub poll: Style,
283592 pub notice: Style,
284593 pub redacted: Style,
594 pub unread_marker: Style,
285595}
286596
287597#[derive(Clone, Debug, Default, Deserialize)]
288598struct ThemeWindows {
599 #[serde(default)]
600 default: Stylable,
601
289602 #[serde(default)]
290603 border: Stylable,
291604
@@ -299,6 +612,7 @@ struct ThemeWindows {
299612impl ThemeWindows {
300613 fn merge(self, other: Self) -> Self {
301614 Self {
615 default: self.default.merge(other.default),
302616 border: self.border.merge(other.border),
303617 border_focused: self.border_focused.merge(other.border_focused),
304618 title: self.title.merge(other.title),
@@ -306,17 +620,47 @@ impl ThemeWindows {
306620 }
307621
308622 fn values(self, base: Style) -> ThemeWindowsValues {
309 ThemeWindowsValues {
310 border: base.patch(self.border),
311 border_focused: base.patch(self.border_focused.merge(self.border)),
312 title: base.patch(self.title),
313 }
623 let default = base.patch(self.default);
624 let border = default.patch(self.border);
625 let border_focused = border.patch(self.border_focused);
626 let title = default.patch(self.title);
627
628 ThemeWindowsValues { default, border, border_focused, title }
314629 }
315630}
316631
317632#[derive(Clone, Debug, Default)]
318633pub struct ThemeWindowsValues {
634 pub default: Style,
319635 pub border: Style,
320636 pub border_focused: Style,
321637 pub title: Style,
322638}
639
640#[cfg(test)]
641mod tests {
642 use super::*;
643
644 #[test]
645 fn test_remove_modifier() {
646 let res: Theme = serde_json::from_str(
647 r#"
648 {
649 "default": {
650 "color":"red",
651 "modifiers":["bold"]
652 },
653 "windows":{
654 "border": {"color":"green"},
655 "border_focused": {"modifiers":["~bold"]}
656 }
657 }"#,
658 )
659 .unwrap();
660 let values = res.values();
661 assert_eq!(values.default, Style::default().fg(Color::Red).bold());
662 assert_eq!(values.windows.border, Style::default().fg(Color::Green).bold());
663 assert_eq!(values.windows.border_focused, Style::default().fg(Color::Green).not_bold());
664 assert_eq!(values.windows.title, Style::default().fg(Color::Red).bold());
665 }
666}
src/main.rs +5 −6
@@ -349,12 +349,11 @@ impl Application {
349349 .show_dialog(dialogstr)
350350 .show_mode(modestr)
351351 .borders(true)
352 .border_style(theme.windows.border.add_modifier(StyleModifier::DIM))
353 .border_style_focused(
354 theme.windows.border_focused.remove_modifier(StyleModifier::DIM),
355 )
356 .tab_style(theme.tabs.title.add_modifier(StyleModifier::DIM))
357 .tab_style_focused(theme.tabs.title_focused.remove_modifier(StyleModifier::DIM))
352 .border_style(theme.windows.border)
353 .border_style_focused(theme.windows.border_focused)
354 .cmdbar_style(theme.cmdbar.default)
355 .tab_style(theme.tabs.title)
356 .tab_style_focused(theme.tabs.title_focused)
358357 .focus(focused);
359358 f.render_stateful_widget(screen, area, sstate);
360359
src/message/html.rs +32 −15
@@ -253,6 +253,25 @@ impl Table {
253253 }
254254}
255255
256#[derive(Debug, Clone)]
257pub enum ThemeSelector {
258 Strong,
259 Emphasis,
260 Strikethrough,
261 Underlined,
262}
263
264impl ThemeSelector {
265 fn style(&self, settings: &ApplicationSettings) -> Style {
266 match self {
267 Self::Strong => settings.theme.messages.strong,
268 Self::Emphasis => settings.theme.messages.emphasis,
269 Self::Strikethrough => settings.theme.messages.strikethrough,
270 Self::Underlined => settings.theme.messages.underlined,
271 }
272 }
273}
274
256275/// A processed HTML element that we can render to the terminal.
257276#[derive(Debug, Clone)]
258277pub enum StyleTreeNode {
@@ -267,6 +286,7 @@ pub enum StyleTreeNode {
267286 Paragraph(Box<StyleTreeNode>),
268287 Pre(Box<StyleTreeNode>),
269288 Ruler,
289 Themed(Box<StyleTreeNode>, ThemeSelector),
270290 Style(Box<StyleTreeNode>, Style),
271291 Table(Table),
272292 Text(Cow<'static, str>),
@@ -301,7 +321,8 @@ impl StyleTreeNode {
301321 StyleTreeNode::Header(child, _) |
302322 StyleTreeNode::Paragraph(child) |
303323 StyleTreeNode::Pre(child) |
304 StyleTreeNode::Style(child, _) => {
324 StyleTreeNode::Style(child, _) |
325 StyleTreeNode::Themed(child, _) => {
305326 child.gather_links(urls);
306327 },
307328
@@ -389,8 +410,8 @@ impl StyleTreeNode {
389410 StyleTreeNode::Image(None) => {},
390411 StyleTreeNode::Image(Some(alt)) => {
391412 printer.commit();
392 printer.push_str("Image Alt: ", Style::default());
393 printer.push_str(alt, Style::default());
413 printer.push_str("Image Alt: ", style);
414 printer.push_str(alt, style);
394415 printer.commit();
395416 },
396417 StyleTreeNode::List(children, lt) => {
@@ -470,6 +491,10 @@ impl StyleTreeNode {
470491 printer.push_str(s.as_ref(), style);
471492 },
472493
494 StyleTreeNode::Themed(child, patch) => {
495 let patch = patch.style(printer.settings());
496 child.print(printer, style.patch(patch))
497 },
473498 StyleTreeNode::Style(child, patch) => child.print(printer, style.patch(*patch)),
474499 StyleTreeNode::Sequence(children) => {
475500 for child in children {
@@ -773,9 +798,7 @@ fn h2t(hdl: &Handle, state: &mut TreeGenState) -> StyleTreeChildren {
773798 // Style change
774799 "b" | "strong" => {
775800 let c = c2t(&node.children.borrow(), state);
776 let s = Style::default().add_modifier(StyleModifier::BOLD);
777
778 StyleTreeNode::Style(c, s)
801 StyleTreeNode::Themed(c, ThemeSelector::Strong)
779802 },
780803 "font" => {
781804 let c = c2t(&node.children.borrow(), state);
@@ -785,9 +808,7 @@ fn h2t(hdl: &Handle, state: &mut TreeGenState) -> StyleTreeChildren {
785808 },
786809 "em" | "i" => {
787810 let c = c2t(&node.children.borrow(), state);
788 let s = Style::default().add_modifier(StyleModifier::ITALIC);
789
790 StyleTreeNode::Style(c, s)
811 StyleTreeNode::Themed(c, ThemeSelector::Emphasis)
791812 },
792813 "span" => {
793814 let c = c2t(&node.children.borrow(), state);
@@ -797,15 +818,11 @@ fn h2t(hdl: &Handle, state: &mut TreeGenState) -> StyleTreeChildren {
797818 },
798819 "del" | "s" | "strike" => {
799820 let c = c2t(&node.children.borrow(), state);
800 let s = Style::default().add_modifier(StyleModifier::CROSSED_OUT);
801
802 StyleTreeNode::Style(c, s)
821 StyleTreeNode::Themed(c, ThemeSelector::Strikethrough)
803822 },
804823 "u" => {
805824 let c = c2t(&node.children.borrow(), state);
806 let s = Style::default().add_modifier(StyleModifier::UNDERLINED);
807
808 StyleTreeNode::Style(c, s)
825 StyleTreeNode::Themed(c, ThemeSelector::Underlined)
809826 },
810827
811828 // Lists
src/message/mod.rs +2 −2
@@ -223,7 +223,7 @@ impl MessageTimeStamp {
223223 fn show_date(self, settings: &ApplicationSettings) -> Span<'static> {
224224 let time = self.as_datetime().format("%A, %B %d %Y").to_string();
225225
226 Span::styled(time, settings.theme.timeline.date.add_modifier(StyleModifier::BOLD))
226 Span::styled(time, settings.theme.timeline.date)
227227 }
228228
229229 /// A compact date and time, for places without a date separator line.
@@ -745,7 +745,7 @@ impl<'a> MessageFormatter<'a> {
745745 #[inline]
746746 fn push_spans(&mut self, prev_line: Line<'a>, style: Style, text: &mut Text<'a>) {
747747 if std::mem::take(&mut self.trackbar) {
748 let trackbar_style = Style::default().add_modifier(StyleModifier::DIM);
748 let trackbar_style = self.settings.theme.timeline.unread_marker;
749749 text.lines
750750 .push(Line::from(Span::styled(HORIZONTAL.repeat(self.orig), trackbar_style)));
751751 }
src/prelude.rs +1
@@ -89,6 +89,7 @@ pub use crate::base::{
8989 SpaceAction,
9090 TimelineAction,
9191};
92pub use crate::config::theme::ThemeValues;
9293pub use crate::config::{Aliases, ApplicationSettings};
9394pub use crate::message::{Message, MessageEvent, MessageKey, MessageTimeStamp, Messages};
9495pub use crate::preview::{PreviewKind, PreviewManager};
src/windows/mod.rs +59 −68
@@ -30,16 +30,6 @@ pub mod welcome;
3030
3131const MEMBER_FETCH_DEBOUNCE: Duration = Duration::from_secs(5);
3232
33#[inline]
34fn bold_span(s: &str, style: Style) -> Span<'_> {
35 Span::styled(s, style.bold())
36}
37
38#[inline]
39fn bold_spans(s: &str, style: Style) -> Line<'_> {
40 bold_span(s, style).into()
41}
42
4333#[inline]
4434pub fn selected_style(selected: bool, style: Style) -> Style {
4535 if selected {
@@ -53,31 +43,25 @@ fn name_and_labels<'a>(
5343 name: &'a str,
5444 unread: &UnreadInfo,
5545 room_membership: MatrixRoomState,
56 style: Style,
46 name_style: Style,
47 tags_style: Style,
5748) -> (Span<'a>, Vec<Vec<Span<'static>>>) {
58 // XXX: use different colors for "mention", "notification", "muted room"
59 let name_style = if unread.is_unread() {
60 style.add_modifier(StyleModifier::BOLD)
61 } else {
62 style
63 };
64
6549 let name = Span::styled(name, name_style);
6650
6751 let mut labels = vec![];
6852
6953 match room_membership {
7054 MatrixRoomState::Joined => {},
71 MatrixRoomState::Left => labels.push(vec![Span::styled("Left", style)]),
72 MatrixRoomState::Banned => labels.push(vec![Span::styled("Banned", style)]),
73 MatrixRoomState::Knocked => labels.push(vec![Span::styled("Knocked", style)]),
74 MatrixRoomState::Invited => labels.push(vec![Span::styled("Invited", style)]),
55 MatrixRoomState::Left => labels.push(vec![Span::styled("Left", tags_style)]),
56 MatrixRoomState::Banned => labels.push(vec![Span::styled("Banned", tags_style)]),
57 MatrixRoomState::Knocked => labels.push(vec![Span::styled("Knocked", tags_style)]),
58 MatrixRoomState::Invited => labels.push(vec![Span::styled("Invited", tags_style)]),
7559 }
7660
7761 if unread.unread_mentions > 0 {
78 labels.push(vec![Span::styled("Unread Mention", style)]);
62 labels.push(vec![Span::styled("Unread Mention", tags_style)]);
7963 } else if unread.is_unread() {
80 labels.push(vec![Span::styled("Unread", style)]);
64 labels.push(vec![Span::styled("Unread", tags_style)]);
8165 }
8266
8367 (name, labels)
@@ -781,25 +765,24 @@ impl Window<IambInfo> for IambWindow {
781765 }
782766
783767 fn get_tab_title(&self, store: &mut ProgramStore) -> Line<'_> {
784 let style = Default::default();
785768 match self {
786 IambWindow::DirectList(_) => bold_spans("Direct Messages", style),
787 IambWindow::RoomList(_) => bold_spans("Rooms", style),
788 IambWindow::SpaceList(_) => bold_spans("Spaces", style),
789 IambWindow::VerifyList(_) => bold_spans("Verifications", style),
790 IambWindow::Welcome(_) => bold_spans("Welcome to iamb", style),
791 IambWindow::ChatList(_) => bold_spans("DMs & Rooms", style),
792 IambWindow::UnreadList(_) => bold_spans("Unread Messages", style),
793 IambWindow::MentionsList(_) => bold_spans("Unread Mentions", style),
794 IambWindow::InvitesList(_) => bold_spans("Open Invites", style),
769 IambWindow::DirectList(_) => Line::from("Direct Messages"),
770 IambWindow::RoomList(_) => Line::from("Rooms"),
771 IambWindow::SpaceList(_) => Line::from("Spaces"),
772 IambWindow::VerifyList(_) => Line::from("Verifications"),
773 IambWindow::Welcome(_) => Line::from("Welcome to iamb"),
774 IambWindow::ChatList(_) => Line::from("DMs & Rooms"),
775 IambWindow::UnreadList(_) => Line::from("Unread Messages"),
776 IambWindow::MentionsList(_) => Line::from("Unread Mentions"),
777 IambWindow::InvitesList(_) => Line::from("Open Invites"),
795778
796779 IambWindow::Room(w) => w.get_tab_title(store),
797780 IambWindow::MemberList(state, room_id, _) => {
798781 let title = store.application.get_room_title(room_id.as_ref());
799782 let n = state.len();
800783 let v = vec![
801 bold_span("Room Members ", style),
802 Span::styled(format!("({n}): "), style.bold()),
784 Span::raw("Room Members "),
785 Span::raw(format!("({n}): ")),
803786 title.into(),
804787 ];
805788 Line::from(v)
@@ -808,9 +791,9 @@ impl Window<IambInfo> for IambWindow {
808791 let title = store.application.get_room_title(room_id.as_ref());
809792 let n = state.len();
810793 let v = vec![
811 bold_span("Pinned Messages ", style),
812 Span::styled(format!("({n}): "), style.bold()),
813 title.into(),
794 Span::raw("Pinned Messages "),
795 Span::raw(format!("({n}): ")),
796 Span::raw(title),
814797 ];
815798 Line::from(v)
816799 },
@@ -819,25 +802,27 @@ impl Window<IambInfo> for IambWindow {
819802
820803 fn get_win_title(&self, store: &mut ProgramStore) -> Line<'_> {
821804 let style = store.application.settings.theme.windows.title;
805 let default_style = store.application.settings.theme.windows.default;
806
822807 match self {
823 IambWindow::DirectList(_) => bold_spans("Direct Messages", style),
824 IambWindow::RoomList(_) => bold_spans("Rooms", style),
825 IambWindow::SpaceList(_) => bold_spans("Spaces", style),
826 IambWindow::VerifyList(_) => bold_spans("Verifications", style),
827 IambWindow::Welcome(_) => bold_spans("Welcome to iamb", style),
828 IambWindow::ChatList(_) => bold_spans("DMs & Rooms", style),
829 IambWindow::UnreadList(_) => bold_spans("Unread Messages", style),
830 IambWindow::MentionsList(_) => bold_spans("Unread Mentions", style),
831 IambWindow::InvitesList(_) => bold_spans("Open Invites", style),
832
833 IambWindow::Room(w) => w.get_title(store, style),
808 IambWindow::DirectList(_) => Line::styled("Direct Messages", style),
809 IambWindow::RoomList(_) => Line::styled("Rooms", style),
810 IambWindow::SpaceList(_) => Line::styled("Spaces", style),
811 IambWindow::VerifyList(_) => Line::styled("Verifications", style),
812 IambWindow::Welcome(_) => Line::styled("Welcome to iamb", style),
813 IambWindow::ChatList(_) => Line::styled("DMs & Rooms", style),
814 IambWindow::UnreadList(_) => Line::styled("Unread Messages", style),
815 IambWindow::MentionsList(_) => Line::styled("Unread Mentions", style),
816 IambWindow::InvitesList(_) => Line::styled("Open Invites", style),
817
818 IambWindow::Room(w) => w.get_title(store),
834819 IambWindow::MemberList(state, room_id, _) => {
835820 let title = store.application.get_room_title(room_id.as_ref());
836821 let n = state.len();
837822 let v = vec![
838 bold_span("Room Members ", style),
839 Span::styled(format!("({n}): "), style.bold()),
840 title.into(),
823 Span::styled("Room Members ", style),
824 Span::styled(format!("({n}): "), style),
825 Span::styled(title, default_style),
841826 ];
842827 Line::from(v)
843828 },
@@ -845,9 +830,9 @@ impl Window<IambInfo> for IambWindow {
845830 let title = store.application.get_room_title(room_id.as_ref());
846831 let n = state.len();
847832 let v = vec![
848 bold_span("Pinned Messages ", style),
849 Span::styled(format!("({n}): "), style.bold()),
850 title.into(),
833 Span::styled("Pinned Messages ", style),
834 Span::styled(format!("({n}): "), style),
835 Span::styled(title, default_style),
851836 ];
852837 Line::from(v)
853838 },
@@ -1086,25 +1071,29 @@ impl ListItem<IambInfo> for GenericRoomItem {
10861071 _: &ViewportContext<ListCursor>,
10871072 store: &mut ProgramStore,
10881073 ) -> Text<'_> {
1089 let style = if self.unread.is_unread() {
1090 store.application.settings.theme.rooms.unread
1074 let theme = &store.application.settings.theme;
1075
1076 let name_style = if self.unread.is_unread() {
1077 theme.rooms.unread
10911078 } else {
1092 store.application.settings.theme.rooms.default
1079 theme.rooms.default
10931080 };
10941081
1095 let style = selected_style(selected, style);
1096 let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.membership, style);
1082 let name_style = selected_style(selected, name_style);
1083 let tags_style = selected_style(selected, theme.rooms.labels);
1084 let (name, mut labels) =
1085 name_and_labels(&self.name, &self.unread, self.membership, name_style, tags_style);
10971086 let mut spans = vec![name];
10981087
10991088 if let Some(label) = self.room_type.text() {
1100 labels.push(vec![Span::styled(label, style)]);
1089 labels.push(vec![Span::styled(label, tags_style)]);
11011090 }
11021091
11031092 if let Some(tags) = &self.tags {
1104 labels.extend(tags.keys().map(|t| tag_to_span(t, style)));
1093 labels.extend(tags.keys().map(|t| tag_to_span(t, tags_style)));
11051094 }
11061095
1107 append_tags(labels, &mut spans, style);
1096 append_tags(labels, &mut spans, tags_style);
11081097 Text::from(Line::from(spans))
11091098 }
11101099
@@ -1166,11 +1155,12 @@ impl ListItem<IambInfo> for MemberItem {
11661155 let (color, name) = store.application.settings.get_user_overrides(self.member.user_id());
11671156 let color = color.unwrap_or_else(|| super::config::user_color(user_id.as_str()));
11681157
1158 let style = store.application.settings.theme.default;
11691159 let style = if selected {
11701160 // Ensure the whole item has the same color when it's selected:
1171 Style::default().fg(color).add_modifier(StyleModifier::REVERSED)
1161 style.fg(color).add_modifier(StyleModifier::REVERSED)
11721162 } else {
1173 Style::default()
1163 style
11741164 };
11751165 let user_style = style.patch(super::config::user_style_from_color(color));
11761166 let role_style = style.add_modifier(StyleModifier::BOLD);
@@ -1297,10 +1287,11 @@ impl ListItem<IambInfo> for PinnedItem {
12971287 let info = store.application.rooms.get_or_default(self.room_id.clone());
12981288 let settings = &store.application.settings;
12991289
1290 let style = store.application.settings.theme.default;
13001291 let style = if selected {
1301 Style::default().add_modifier(StyleModifier::REVERSED)
1292 style.add_modifier(StyleModifier::REVERSED)
13021293 } else {
1303 Style::default()
1294 style
13041295 };
13051296
13061297 let Some(msg) = info.get_pinned(&self.event_id) else {
src/windows/room/chat.rs +7 −3
@@ -1248,6 +1248,7 @@ impl StatefulWidget for Chat<'_> {
12481248 state.complete_pending_jump(self.store);
12491249
12501250 let settings = &self.store.application.settings;
1251 let theme = &settings.theme;
12511252
12521253 // Determine whether we have a description to show for the message bar.
12531254 let desc_spans = match (&state.editing, &state.reply_to, state.thread()) {
@@ -1308,8 +1309,11 @@ impl StatefulWidget for Chat<'_> {
13081309 }
13091310
13101311 let encryption_settings = &settings.tunables.encryption;
1311 let encryption_indicator = encryption_settings
1312 .get_indicator(EncryptionIndicatorLocation::PROMPT, state.room().encryption_state());
1312 let encryption_indicator = encryption_settings.get_indicator(
1313 EncryptionIndicatorLocation::PROMPT,
1314 state.room().encryption_state(),
1315 theme,
1316 );
13131317 let input_prompt = settings.tunables.input_prompt.as_deref();
13141318 let prompt = match (self.focused, encryption_indicator, input_prompt) {
13151319 // User has both encryption indicator and custom prompt, combine them:
@@ -1329,7 +1333,7 @@ impl StatefulWidget for Chat<'_> {
13291333 (true, None, None) => Line::from("> "),
13301334 };
13311335
1332 let tbox = TextBox::new().prompt(prompt);
1336 let tbox = TextBox::new().style(theme.msgbar.default).prompt(prompt);
13331337 state
13341338 .tbox
13351339 .set_ignorecase(self.store.application.settings.tunables.ignorecase);
src/windows/room/mod.rs +18 −12
@@ -891,38 +891,44 @@ impl RoomState {
891891 }
892892 }
893893
894 pub fn get_title(&self, store: &mut ProgramStore, style: Style) -> Line<'_> {
894 pub fn get_title(&self, store: &mut ProgramStore) -> Line<'_> {
895 let theme = &store.application.settings.theme;
896 let default_style = theme.windows.default;
897 let title_style = theme.windows.title;
898
895899 let Some(room) = self.room() else {
896 return Line::from("Unjoined Room");
900 return Line::styled("Unjoined Room", title_style);
897901 };
898902
899903 let room_id = room.room_id();
900904 let title = store.application.get_room_title(room_id);
901 let bold_style = style.add_modifier(StyleModifier::BOLD);
902905 let mut spans = vec![];
903906
904907 let encryption_settings = &store.application.settings.tunables.encryption;
905 let encryption_indicator = encryption_settings
906 .get_indicator(EncryptionIndicatorLocation::TITLE, room.encryption_state());
908 let encryption_indicator = encryption_settings.get_indicator(
909 EncryptionIndicatorLocation::TITLE,
910 room.encryption_state(),
911 theme,
912 );
907913 spans.extend(encryption_indicator);
908 spans.push(Span::raw(" "));
914 spans.push(Span::styled(" ", default_style));
909915
910916 if let RoomState::Chat(chat) = self &&
911917 chat.thread().is_some()
912918 {
913 spans.push(Span::styled("Thread in ", style));
919 spans.push(Span::styled("Thread in ", default_style));
914920 }
915921
916 spans.push(Span::styled(title, bold_style));
922 spans.push(Span::styled(title, title_style));
917923
918924 match room.topic() {
919925 Some(desc) if !desc.is_empty() => {
920 spans.push(Span::styled(" (", style));
921 spans.push(Span::styled(desc, style));
922 spans.push(Span::styled(")", style));
926 spans.push(Span::styled(" (", default_style));
927 spans.push(Span::styled(desc, default_style));
928 spans.push(Span::styled(")", default_style));
923929 },
924930 _ => {
925 spans.push(" ".into());
931 spans.push(Span::styled(" ", default_style));
926932 },
927933 }
928934
src/windows/verify.rs +49 −36
@@ -140,8 +140,9 @@ impl ListItem<IambInfo> for VerifyItem {
140140 store: &mut ProgramStore,
141141 ) -> Text<'_> {
142142 let mut lines = vec![];
143 let bold = Style::default().bold();
144 let selected = super::selected_style(selected, Default::default());
143 let style = store.application.settings.theme.default;
144 let bold = style.bold();
145 let selected = super::selected_style(selected, style);
145146
146147 let mut other_device = None;
147148 let state = match self.request.state() {
@@ -151,7 +152,7 @@ impl ListItem<IambInfo> for VerifyItem {
151152 other_device = Some(other_device_data);
152153
153154 if their_methods.contains(&VerificationMethod::SasV1) {
154 lines.push(Line::from(" To accept this request, run:"));
155 lines.push(Line::styled(" To accept this request, run:", style));
155156 "requested"
156157 } else {
157158 "no methods in common"
@@ -164,7 +165,7 @@ impl ListItem<IambInfo> for VerifyItem {
164165 other_device = Some(other_device_data);
165166
166167 if their_methods.contains(&VerificationMethod::SasV1) {
167 lines.push(Line::from(" To start interactive verification, run:"));
168 lines.push(Line::styled(" To start interactive verification, run:", style));
168169 }
169170
170171 "ready"
@@ -177,25 +178,27 @@ impl ListItem<IambInfo> for VerifyItem {
177178 SasState::Started { .. } |
178179 SasState::Accepted { .. } => "starting",
179180 SasState::KeysExchanged { emojis: Some(emojis), .. } => {
180 lines.push(Line::from(
181 " Both devices should see the following Emoji sequence:".to_string(),
181 lines.push(Line::styled(
182 " Both devices should see the following Emoji sequence:",
183 style,
182184 ));
183 lines.push(Line::from(""));
185 lines.push(Line::styled("", style));
184186
185187 for line in format_emojis(emojis.emojis).lines() {
186 lines.push(Line::from(format!(" {line}")));
188 lines.push(Line::styled(format!(" {line}"), style));
187189 }
188190
189 lines.push(Line::from(""));
190 lines.push(Line::from(" If they don't match, run:"));
191 lines.push(Line::from(""));
192 lines.push(Line::from(Span::styled(
191 lines.push(Line::styled("", style));
192 lines.push(Line::styled(" If they don't match, run:", style));
193 lines.push(Line::styled("", style));
194 lines.push(Line::styled(
193195 format!(" :verify mismatch {:?}", self.request.flow_id()),
194196 bold,
195 )));
196 lines.push(Line::from(""));
197 lines.push(Line::from(
197 ));
198 lines.push(Line::styled("", style));
199 lines.push(Line::styled(
198200 " If everything looks right, you can confirm with:",
201 style,
199202 ));
200203 "running"
201204 },
@@ -203,7 +206,8 @@ impl ListItem<IambInfo> for VerifyItem {
203206 SasState::Confirmed => "waiting for response",
204207 SasState::Done { .. } => "done",
205208 SasState::Cancelled(info) => {
206 lines.push(Line::from(format!(" Cancelled: {}", info.reason())));
209 lines
210 .push(Line::styled(format!(" Cancelled: {}", info.reason()), style));
207211 "cancelled"
208212 },
209213 }
@@ -221,31 +225,39 @@ impl ListItem<IambInfo> for VerifyItem {
221225 .map(|line| Line::styled(line.to_owned(), BLACK_ON_WHITE)),
222226 );
223227
224 lines.push(Line::from(" Scan this QR code with the other device."));
225 lines.push(Line::from(
228 lines.push(Line::styled(
229 " Scan this QR code with the other device.",
230 style,
231 ));
232 lines.push(Line::styled(
226233 " To alternativly start interactive verification, run:",
234 style,
227235 ));
228236 } else {
229 lines.push(Line::from(" To start interactive verification, run:"));
237 lines.push(Line::styled(
238 " To start interactive verification, run:",
239 style,
240 ));
230241 }
231242
232243 "ready"
233244 },
234245 QrVerificationState::Scanned => {
235 lines.push(Line::from(
236 " Check whether the other device shows a successful verification."
237 .to_string(),
246 lines.push(Line::styled(
247 " Check whether the other device shows a successful verification.",
248 style,
238249 ));
239 lines.push(Line::from(""));
240 lines.push(Line::from(" If it shows an error, run:"));
241 lines.push(Line::from(""));
242 lines.push(Line::from(Span::styled(
250 lines.push(Line::styled("", style));
251 lines.push(Line::styled(" If it shows an error, run:", style));
252 lines.push(Line::styled("", style));
253 lines.push(Line::styled(
243254 format!(" :verify mismatch {:?}", self.request.flow_id()),
244255 bold,
245 )));
246 lines.push(Line::from(""));
247 lines.push(Line::from(
256 ));
257 lines.push(Line::styled("", style));
258 lines.push(Line::styled(
248259 " If everything looks right, you can confirm with:",
260 style,
249261 ));
250262 "running"
251263 },
@@ -258,7 +270,8 @@ impl ListItem<IambInfo> for VerifyItem {
258270 },
259271 QrVerificationState::Done { .. } => "done",
260272 QrVerificationState::Cancelled(info) => {
261 lines.push(Line::from(format!(" Cancelled: {}", info.reason())));
273 lines
274 .push(Line::styled(format!(" Cancelled: {}", info.reason()), style));
262275 "cancelled"
263276 },
264277 }
@@ -266,7 +279,7 @@ impl ListItem<IambInfo> for VerifyItem {
266279 VerificationRequestState::Transitioned { .. } => "unsupported method",
267280 VerificationRequestState::Done => "done",
268281 VerificationRequestState::Cancelled(info) => {
269 lines.push(Line::from(format!(" Cancelled: {}", info.reason())));
282 lines.push(Line::styled(format!(" Cancelled: {}", info.reason()), style));
270283 "cancelled"
271284 },
272285 };
@@ -305,14 +318,14 @@ impl ListItem<IambInfo> for VerifyItem {
305318 let cmd = self.to_string();
306319
307320 if !cmd.is_empty() {
308 lines.push(Line::from(""));
309 lines.push(Line::from(vec![Span::from(" "), Span::styled(cmd, bold)]));
321 lines.push(Line::styled("", style));
322 lines.push(Line::from(vec![Span::styled(" ", style), Span::styled(cmd, bold)]));
310323 if self.show_help {
311 lines.push(Line::from(""));
324 lines.push(Line::styled("", style));
312325 lines.push(Line::from(vec![
313 Span::from("You can copy the above command with "),
326 Span::styled("You can copy the above command with ", style),
314327 Span::styled("yy", bold),
315 Span::from(" and then execute it with "),
328 Span::styled(" and then execute it with ", style),
316329 Span::styled("@\"", bold),
317330 ]));
318331 }