Commit ff4d92e890

ff4d92e890d8d44b75ba98dfedb0dda74ea2ae05

parent: f605eeae85

Unregistered key

vaw <git@nlih.de> · 2026-09-24 02:01 UTC
committer: <noreply@github.com>

Support styling user interface (#472)

Co-authored-by: Ulyssa <git@ulyssa.dev>

Layout: unified · split

config.example.toml +6
@@ -88,3 +88,9 @@ split = [
88cache = "/home/user/.cache/iamb/" 88cache = "/home/user/.cache/iamb/"
89logs = "/home/user/.local/share/iamb/logs/" 89logs = "/home/user/.local/share/iamb/logs/"
90downloads = "/home/user/Downloads/" 90downloads = "/home/user/Downloads/"
91
92[theme]
93timeline.state.color = "cyan"
94timeline.redacted.color = "245" # light gray
95# How to use truecolor for terminals that support it:
96# rooms.unread.color = "#ff55bb" # pink
docs/iamb.5 +133 −19
@@ -374,6 +374,38 @@ and
374Both can be used via 374Both can be used via
375.Dq Sy title|prompt . 375.Dq Sy title|prompt .
376.El 376.El
377.Sh COLORS
378The
379.Sy settings.users
380and
381.Sy theme
382subsections allows configuring the appearance of many elements.
383For settings that take a color value, you can use either a named color, an 8-bit color value or a hex value.
384.Pp
385The named colors are:
386.Dq Sy black ,
387.Dq Sy red ,
388.Dq Sy green ,
389.Dq Sy yellow ,
390.Dq Sy blue ,
391.Dq Sy magenta ,
392.Dq Sy cyan ,
393.Dq Sy gray ,
394.Dq Sy dark-gray ,
395.Dq Sy light-red ,
396.Dq Sy light-green ,
397.Dq Sy light-yellow ,
398.Dq Sy light-blue ,
399.Dq Sy light-magenta ,
400.Dq Sy light-cyan ,
401.Dq Sy white ,
402and
403.Dq Sy reset ,
404The 8-bit ANSI color must in the range of 0 to 255 where the first 16 colors correspond to the named colors.
405The hex value is given as
406.Dq Sy #RRGGBB .
407If the terminal does not support truecolor, all hex colors will fall back to the default text color.
408All values must be given as a string.
377.Sh IMAGE PREVIEWS 409.Sh IMAGE PREVIEWS
378The 410The
379.Sy settings.image_preview 411.Sy settings.image_preview
@@ -639,6 +671,104 @@ Whether to set the title of the terminal window to
639.Dq Sy iamb (<user_id>) . 671.Dq Sy iamb (<user_id>) .
640Defaults to true. 672Defaults to true.
641.El 673.El
674.Sh "THEME OVERRIDES"
675The
676.Sy theme
677subsection allows you to override the colors used for different parts of the user interface.
678Individual, stylable UI elements have the following properties:
679.Bl -tag -width Ds
680.It Sy color
681Configure the foreground color for text.
682See the
683.Sx "COLORS"
684section for the supported color format.
685.It Sy background
686Configure the background color for text.
687See the
688.Sx "COLORS"
689section for the supported color format.
690.El
691Within
692.Sy theme ,
693there are several subsections for specific UI areas:
694.Bl -tag -width Ds
695.It Sy messages
696For controlling how the bodies of messages are styled.
697UI elements you can set within this subsection are:
698.Bl -tag -width Ds
699.It Sy default
700Configure the default styling for messages.
701.It Sy code
702Configure the styling for
703.Sy "<code>"
704elements in formatted message bodies.
705.It Sy "code_block"
706Configure the styling for
707.Sy "<pre>"
708elements in formatted message bodies.
709.El
710.It Sy timeline
711For controlling how other elements within the timeline are styled.
712UI elements you can set within this subsection are:
713.Bl -tag -width Ds
714.It Sy default
715Configure the default styling for text in the timeline.
716.It Sy date
717Configure the how the dates for messages are styled.
718.It Sy time
719Configure the how the time a message was sent is styled.
720.It Sy state
721Configure how the text shown for state events is styled.
722.It Sy sticker
723Configure how any text shown for stickers is styled.
724.It Sy poll
725Configure how the text in polls is styled.
726.It Sy notice
727Configure how server notices is styled.
728.It Sy redacted
729Configure how redacted events in the timeline is styled.
730.El
731.It Sy windows
732For controlling how the windows are styled.
733.Bl -tag -width Ds
734.It Sy border
735Configure how the border characters are styled.
736.It Sy border_focused
737Configure how the border characters for focused window are styled.
738.It Sy title
739Configure how the window titles are styled.
740.El
741.It Sy tabs
742For controlling how tabs are styled.
743UI elements you can set within this subsection are:
744.Bl -tag -width Ds
745.It Sy title
746Configure how tab titles are styled.
747.It Sy title_focused
748Configure how the title of the focused tab is styled.
749.El
750.It Sy rooms
751For controlling how lists of rooms like
752.Sy :unreads
753or
754.Sy :chats
755are styled.
756UI elements you can set within this subsection are:
757.Bl -tag -width Ds
758.It Sy default
759Configure the default style for text in room lists.
760.It Sy unread
761Configure the text for unread rooms in lists is styled.
762.El
763.El
764.Ss Example: Make code blocks a lighter gray background and state events red
765.Bd -literal -offset indent
766[theme.messages]
767code_block.background = "245"
768
769[theme.timeline]
770state.color = "cyan"
771.Ed
642.Sh "USER OVERRIDES" 772.Sh "USER OVERRIDES"
643The 773The
644.Sy settings.users 774.Sy settings.users
@@ -651,25 +781,9 @@ and are typically written as inline tables containing the following keys:
651Change the display name of the user. 781Change the display name of the user.
652.It Sy color 782.It Sy color
653Change the color the user is shown as. 783Change the color the user is shown as.
654Possible values are: 784See the
655.Dq Sy black , 785.Sx "COLORS"
656.Dq Sy blue , 786section for the supported color format.
657.Dq Sy cyan ,
658.Dq Sy dark-gray ,
659.Dq Sy gray ,
660.Dq Sy green ,
661.Dq Sy light-blue ,
662.Dq Sy light-cyan ,
663.Dq Sy light-green ,
664.Dq Sy light-magenta ,
665.Dq Sy light-red ,
666.Dq Sy light-yellow ,
667.Dq Sy magenta ,
668.Dq Sy none ,
669.Dq Sy red ,
670.Dq Sy white ,
671and
672.Dq Sy yellow .
673.El 787.El
674.Ss Example 1: Override how @ada:example.com appears in chat 788.Ss Example 1: Override how @ada:example.com appears in chat
675.Bd -literal -offset indent 789.Bd -literal -offset indent
src/config.rs → src/config/mod.rs renamed +59 −54
@@ -6,6 +6,7 @@ use std::fs::File;
6use std::hash::{Hash, Hasher}; 6use std::hash::{Hash, Hasher};
7use std::io::{BufReader, BufWriter, Write as _}; 7use std::io::{BufReader, BufWriter, Write as _};
8use std::process; 8use std::process;
9use std::sync::Arc;
9 10
10use clap::Parser; 11use clap::Parser;
11use indexmap::IndexMap; 12use indexmap::IndexMap;
@@ -27,6 +28,8 @@ use serde::{Deserialize, Deserializer, Serialize};
27use crate::base::{SortColumn, SortFieldRoom, SortFieldUser, SortOrder}; 28use crate::base::{SortColumn, SortFieldRoom, SortFieldUser, SortOrder};
28use crate::prelude::*; 29use crate::prelude::*;
29 30
31pub mod theme;
32
30pub type Aliases = IndexMap<String, String>; 33pub type Aliases = IndexMap<String, String>;
31type Macros = HashMap<VimModes, HashMap<Keys, Keys>>; 34type Macros = HashMap<VimModes, HashMap<Keys, Keys>>;
32 35
@@ -228,7 +231,6 @@ macro_rules! deserialize_str_with_visitor {
228 231
229deserialize_str_with_visitor!(Keys, KeysVisitor); 232deserialize_str_with_visitor!(Keys, KeysVisitor);
230deserialize_str_with_visitor!(VimModes, VimModesVisitor); 233deserialize_str_with_visitor!(VimModes, VimModesVisitor);
231deserialize_str_with_visitor!(UserColor, UserColorVisitor);
232deserialize_str_with_visitor!(EncryptionIndicatorLocation, EncryptionIndicatorLocationVisitor); 234deserialize_str_with_visitor!(EncryptionIndicatorLocation, EncryptionIndicatorLocationVisitor);
233deserialize_str_with_visitor!(NotifyVia, NotifyViaVisitor); 235deserialize_str_with_visitor!(NotifyVia, NotifyViaVisitor);
234deserialize_str_with_visitor!(ProxyUrl, ProxyUrlVisitor); 236deserialize_str_with_visitor!(ProxyUrl, ProxyUrlVisitor);
@@ -290,44 +292,6 @@ impl Visitor<'_> for VimModesVisitor {
290 } 292 }
291} 293}
292 294
293#[derive(Clone, Debug, Eq, PartialEq)]
294pub struct UserColor(pub Color);
295pub struct UserColorVisitor;
296
297impl Visitor<'_> for UserColorVisitor {
298 type Value = UserColor;
299
300 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
301 formatter.write_str("a valid color")
302 }
303
304 fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
305 where
306 E: SerdeError,
307 {
308 match value {
309 "none" => Ok(UserColor(Color::Reset)),
310 "red" => Ok(UserColor(Color::Red)),
311 "black" => Ok(UserColor(Color::Black)),
312 "green" => Ok(UserColor(Color::Green)),
313 "yellow" => Ok(UserColor(Color::Yellow)),
314 "blue" => Ok(UserColor(Color::Blue)),
315 "magenta" => Ok(UserColor(Color::Magenta)),
316 "cyan" => Ok(UserColor(Color::Cyan)),
317 "gray" => Ok(UserColor(Color::Gray)),
318 "dark-gray" => Ok(UserColor(Color::DarkGray)),
319 "light-red" => Ok(UserColor(Color::LightRed)),
320 "light-green" => Ok(UserColor(Color::LightGreen)),
321 "light-yellow" => Ok(UserColor(Color::LightYellow)),
322 "light-blue" => Ok(UserColor(Color::LightBlue)),
323 "light-magenta" => Ok(UserColor(Color::LightMagenta)),
324 "light-cyan" => Ok(UserColor(Color::LightCyan)),
325 "white" => Ok(UserColor(Color::White)),
326 _ => Err(E::custom("Could not parse color")),
327 }
328 }
329}
330
331#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] 295#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
332pub struct Session { 296pub struct Session {
333 access_token: String, 297 access_token: String,
@@ -364,7 +328,7 @@ impl From<MatrixSession> for Session {
364 328
365#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] 329#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
366pub struct UserDisplayTunables { 330pub struct UserDisplayTunables {
367 pub color: Option<UserColor>, 331 pub color: Option<Color>,
368 pub name: Option<String>, 332 pub name: Option<String>,
369} 333}
370 334
@@ -1207,6 +1171,7 @@ pub struct ProfileConfig {
1207 pub password_file: Option<PathBuf>, 1171 pub password_file: Option<PathBuf>,
1208 pub url: Option<Url>, 1172 pub url: Option<Url>,
1209 pub settings: Option<Tunables>, 1173 pub settings: Option<Tunables>,
1174 pub theme: Option<theme::Theme>,
1210 pub dirs: Option<Directories>, 1175 pub dirs: Option<Directories>,
1211 pub layout: Option<Layout>, 1176 pub layout: Option<Layout>,
1212 pub macros: Option<Macros>, 1177 pub macros: Option<Macros>,
@@ -1222,6 +1187,7 @@ pub struct IambConfig {
1222 pub layout: Option<Layout>, 1187 pub layout: Option<Layout>,
1223 pub macros: Option<Macros>, 1188 pub macros: Option<Macros>,
1224 pub aliases: Option<Aliases>, 1189 pub aliases: Option<Aliases>,
1190 pub theme: Option<theme::Theme>,
1225} 1191}
1226 1192
1227impl IambConfig { 1193impl IambConfig {
@@ -1250,6 +1216,7 @@ pub struct ApplicationSettings {
1250 pub sqlite_cache_dir: PathBuf, 1216 pub sqlite_cache_dir: PathBuf,
1251 pub profile_name: String, 1217 pub profile_name: String,
1252 pub profile: ProfileConfig, 1218 pub profile: ProfileConfig,
1219 pub theme: Arc<theme::ThemeValues>,
1253 pub tunables: TunableValues, 1220 pub tunables: TunableValues,
1254 pub dirs: DirectoryValues, 1221 pub dirs: DirectoryValues,
1255 pub layout: Layout, 1222 pub layout: Layout,
@@ -1304,6 +1271,7 @@ impl ApplicationSettings {
1304 layout, 1271 layout,
1305 macros, 1272 macros,
1306 aliases, 1273 aliases,
1274 theme,
1307 } = config; 1275 } = config;
1308 1276
1309 validate_profile_names(&profiles); 1277 validate_profile_names(&profiles);
@@ -1357,6 +1325,10 @@ impl ApplicationSettings {
1357 let dirs = profile.dirs.take().unwrap_or_default().merge(dirs); 1325 let dirs = profile.dirs.take().unwrap_or_default().merge(dirs);
1358 let dirs = dirs.values(); 1326 let dirs = dirs.values();
1359 1327
1328 let theme = theme.unwrap_or_default().merge(theme::default_theme());
1329 let theme = profile.theme.take().unwrap_or_default().merge(theme);
1330 let theme = Arc::new(theme.values());
1331
1360 // Create directories 1332 // Create directories
1361 dirs.create_dir_all()?; 1333 dirs.create_dir_all()?;
1362 1334
@@ -1401,6 +1373,7 @@ impl ApplicationSettings {
1401 sqlite_cache_dir, 1373 sqlite_cache_dir,
1402 profile_name, 1374 profile_name,
1403 profile, 1375 profile,
1376 theme,
1404 tunables, 1377 tunables,
1405 dirs, 1378 dirs,
1406 layout, 1379 layout,
@@ -1451,12 +1424,7 @@ impl ApplicationSettings {
1451 .tunables 1424 .tunables
1452 .users 1425 .users
1453 .get(user_id) 1426 .get(user_id)
1454 .map(|user| { 1427 .map(|user| (user.color, user.name.as_ref().and_then(|s| s.chars().next())))
1455 (
1456 user.color.as_ref().map(|c| c.0),
1457 user.name.as_ref().and_then(|s| s.chars().next()),
1458 )
1459 })
1460 .unwrap_or_default(); 1428 .unwrap_or_default();
1461 1429
1462 let color = color.unwrap_or_else(|| user_color(user_id.as_str())); 1430 let color = color.unwrap_or_else(|| user_color(user_id.as_str()));
@@ -1474,7 +1442,7 @@ impl ApplicationSettings {
1474 self.tunables 1442 self.tunables
1475 .users 1443 .users
1476 .get(user_id) 1444 .get(user_id)
1477 .map(|user| (user.color.as_ref().map(|c| c.0), user.name.clone().map(Cow::Owned))) 1445 .map(|user| (user.color, user.name.clone().map(Cow::Owned)))
1478 .unwrap_or_default() 1446 .unwrap_or_default()
1479 } 1447 }
1480 1448
@@ -1482,7 +1450,7 @@ impl ApplicationSettings {
1482 self.tunables 1450 self.tunables
1483 .users 1451 .users
1484 .get(user_id) 1452 .get(user_id)
1485 .and_then(|user| user.color.as_ref().map(|c| c.0)) 1453 .and_then(|user| user.color)
1486 .unwrap_or_else(|| user_color(user_id.as_str())) 1454 .unwrap_or_else(|| user_color(user_id.as_str()))
1487 } 1455 }
1488 1456
@@ -1559,13 +1527,13 @@ mod tests {
1559 fn test_merge_users() { 1527 fn test_merge_users() {
1560 let a = None; 1528 let a = None;
1561 let b = vec![(user_id!("@a:b.c").to_owned(), UserDisplayTunables { 1529 let b = vec![(user_id!("@a:b.c").to_owned(), UserDisplayTunables {
1562 color: Some(UserColor(Color::Red)), 1530 color: Some(Color::Red),
1563 name: Some("Hello".into()), 1531 name: Some("Hello".into()),
1564 })] 1532 })]
1565 .into_iter() 1533 .into_iter()
1566 .collect::<HashMap<_, _>>(); 1534 .collect::<HashMap<_, _>>();
1567 let c = vec![(user_id!("@a:b.c").to_owned(), UserDisplayTunables { 1535 let c = vec![(user_id!("@a:b.c").to_owned(), UserDisplayTunables {
1568 color: Some(UserColor(Color::Green)), 1536 color: Some(Color::Green),
1569 name: Some("World".into()), 1537 name: Some("World".into()),
1570 })] 1538 })]
1571 .into_iter() 1539 .into_iter()
@@ -1611,17 +1579,52 @@ mod tests {
1611 assert_eq!(res.typing_notice_send, None); 1579 assert_eq!(res.typing_notice_send, None);
1612 assert_eq!(res.typing_notice_display, None); 1580 assert_eq!(res.typing_notice_display, None);
1613 assert_eq!(res.users, Some(HashMap::new())); 1581 assert_eq!(res.users, Some(HashMap::new()));
1582 }
1614 1583
1584 #[test]
1585 fn test_parse_user_colors() {
1586 let expect = |color| UserDisplayTunables { color: Some(color), name: Some("Tim".into()) };
1587
1588 // Unprefixed color:
1615 let res: Tunables = serde_json::from_str( 1589 let res: Tunables = serde_json::from_str(
1616 "{\"users\": {\"@a:b.c\": {\"color\": \"black\", \"name\": \"Tim\"}}}", 1590 "{\"users\": {\"@a:b.c\": {\"color\": \"black\", \"name\": \"Tim\"}}}",
1617 ) 1591 )
1618 .unwrap(); 1592 .unwrap();
1619 assert_eq!(res.typing_notice_send, None); 1593 assert_eq!(res.typing_notice_send, None);
1620 assert_eq!(res.typing_notice_display, None); 1594 assert_eq!(res.typing_notice_display, None);
1621 let users = vec![(user_id!("@a:b.c").to_owned(), UserDisplayTunables { 1595 let users = vec![(user_id!("@a:b.c").to_owned(), expect(Color::Black))];
1622 color: Some(UserColor(Color::Black)), 1596 assert_eq!(res.users, Some(users.into_iter().collect()));
1623 name: Some("Tim".into()), 1597
1624 })]; 1598 // Color with `light-` prefix:
1599 let res: Tunables = serde_json::from_str(
1600 "{\"users\": {\"@a:b.c\": {\"color\": \"light-red\", \"name\": \"Tim\"}}}",
1601 )
1602 .unwrap();
1603 let users = vec![(user_id!("@a:b.c").to_owned(), expect(Color::LightRed))];
1604 assert_eq!(res.users, Some(users.into_iter().collect()));
1605
1606 // Color name with `light-` prefix:
1607 let res: Tunables = serde_json::from_str(
1608 "{\"users\": {\"@a:b.c\": {\"color\": \"light-red\", \"name\": \"Tim\"}}}",
1609 )
1610 .unwrap();
1611 let users = vec![(user_id!("@a:b.c").to_owned(), expect(Color::LightRed))];
1612 assert_eq!(res.users, Some(users.into_iter().collect()));
1613
1614 // Color name with `light` prefix, no hyphen:
1615 let res: Tunables = serde_json::from_str(
1616 "{\"users\": {\"@a:b.c\": {\"color\": \"lightblue\", \"name\": \"Tim\"}}}",
1617 )
1618 .unwrap();
1619 let users = vec![(user_id!("@a:b.c").to_owned(), expect(Color::LightBlue))];
1620 assert_eq!(res.users, Some(users.into_iter().collect()));
1621
1622 // Hex color name:
1623 let res: Tunables = serde_json::from_str(
1624 "{\"users\": {\"@a:b.c\": {\"color\": \"#ff55bb\", \"name\": \"Tim\"}}}",
1625 )
1626 .unwrap();
1627 let users = vec![(user_id!("@a:b.c").to_owned(), expect(Color::Rgb(0xff, 0x55, 0xbb)))];
1625 assert_eq!(res.users, Some(users.into_iter().collect())); 1628 assert_eq!(res.users, Some(users.into_iter().collect()));
1626 } 1629 }
1627 1630
@@ -1924,6 +1927,7 @@ mod tests {
1924 layout, 1927 layout,
1925 macros, 1928 macros,
1926 aliases, 1929 aliases,
1930 theme,
1927 } = &config; 1931 } = &config;
1928 1932
1929 // There should be an example object for each top-level field. 1933 // There should be an example object for each top-level field.
@@ -1934,6 +1938,7 @@ mod tests {
1934 assert!(layout.is_some()); 1938 assert!(layout.is_some());
1935 assert!(macros.is_some()); 1939 assert!(macros.is_some());
1936 assert!(aliases.is_some()); 1940 assert!(aliases.is_some());
1941 assert!(theme.is_some());
1937 } 1942 }
1938 1943
1939 #[test] 1944 #[test]
src/config/theme.rs added +322
@@ -0,0 +1,322 @@
1//! # Logic for parsing styling configuration into [Style].
2use serde::Deserialize;
3
4use crate::prelude::*;
5
6pub fn default_theme() -> Theme {
7 Theme {
8 messages: ThemeMessages {
9 code: Stylable { color: None, background: Some(Color::Indexed(236)) },
10 ..Default::default()
11 },
12 ..Default::default()
13 }
14}
15
16#[derive(Clone, Copy, Debug, Default, Deserialize)]
17pub struct Stylable {
18 pub background: Option<Color>,
19 pub color: Option<Color>,
20}
21
22impl Stylable {
23 fn merge(self, other: Self) -> Self {
24 Self {
25 background: self.background.or(other.background),
26 color: self.color.or(other.color),
27 }
28 }
29}
30
31impl From<Stylable> for Style {
32 fn from(styled: Stylable) -> Self {
33 let mut style = Style::default();
34
35 if let Some(bg) = styled.background {
36 style = style.bg(bg);
37 }
38
39 if let Some(fg) = styled.color {
40 style = style.fg(fg);
41 }
42
43 style
44 }
45}
46
47#[derive(Clone, Debug, Default, Deserialize)]
48pub struct Theme {
49 /// Configuration specificaly for messages shown within a room's timeline.
50 #[serde(default)]
51 messages: ThemeMessages,
52
53 /// Configuration for styling a room's timeline.
54 #[serde(default)]
55 timeline: ThemeTimeline,
56
57 /// Configuration for styling items within room lists.
58 #[serde(default)]
59 rooms: ThemeRooms,
60
61 /// Configuration for styling tabs.
62 #[serde(default)]
63 tabs: ThemeTabs,
64
65 /// Configuration for styling windows.
66 #[serde(default)]
67 windows: ThemeWindows,
68}
69
70impl Theme {
71 pub fn merge(self, other: Self) -> Self {
72 Self {
73 messages: self.messages.merge(other.messages),
74 tabs: self.tabs.merge(other.tabs),
75 timeline: self.timeline.merge(other.timeline),
76 rooms: self.rooms.merge(other.rooms),
77 windows: self.windows.merge(other.windows),
78 }
79 }
80
81 pub fn values(self) -> ThemeValues {
82 let base = Style::default();
83
84 ThemeValues {
85 messages: self.messages.values(base),
86 timeline: self.timeline.values(base),
87 rooms: self.rooms.values(base),
88 tabs: self.tabs.values(base),
89 windows: self.windows.values(base),
90 }
91 }
92}
93
94#[derive(Clone, Debug, Default)]
95pub struct ThemeValues {
96 /// Styling specificaly for messages shown within a room's timeline.
97 pub messages: ThemeMessagesValues,
98
99 /// Styling for a room's timeline.
100 pub timeline: ThemeTimelineValues,
101
102 /// Styling for items within room lists.
103 pub rooms: ThemeRoomsValues,
104
105 /// Styling for rendering tabs.
106 pub tabs: ThemeTabsValues,
107
108 /// Styling for rendering windows.
109 pub windows: ThemeWindowsValues,
110}
111
112#[derive(Clone, Debug, Default, Deserialize)]
113struct ThemeMessages {
114 #[serde(default)]
115 default: Stylable,
116
117 #[serde(default)]
118 code: Stylable,
119
120 #[serde(default)]
121 code_block: Stylable,
122}
123
124impl ThemeMessages {
125 fn merge(self, other: Self) -> Self {
126 Self {
127 default: self.default.merge(other.default),
128 code: self.code.merge(other.code),
129 code_block: self.code_block.merge(other.code_block),
130 }
131 }
132
133 fn values(self, base: Style) -> ThemeMessagesValues {
134 let code = self.code.merge(self.default);
135 let code_block = self.code_block.merge(code);
136
137 ThemeMessagesValues {
138 default: base.patch(self.default),
139 code: base.patch(code),
140 code_block: base.patch(code_block),
141 }
142 }
143}
144
145#[derive(Clone, Debug, Default)]
146pub struct ThemeMessagesValues {
147 pub default: Style,
148 pub code: Style,
149 pub code_block: Style,
150}
151
152#[derive(Clone, Debug, Default, Deserialize)]
153struct ThemeRooms {
154 #[serde(default)]
155 default: Stylable,
156
157 #[serde(default)]
158 unread: Stylable,
159}
160
161impl ThemeRooms {
162 fn merge(self, other: Self) -> Self {
163 Self {
164 default: self.default.merge(other.default),
165 unread: self.unread.merge(other.unread),
166 }
167 }
168
169 fn values(self, base: Style) -> ThemeRoomsValues {
170 let unread = self.unread.merge(self.default);
171
172 ThemeRoomsValues {
173 default: base.patch(self.default),
174 unread: base.patch(unread),
175 }
176 }
177}
178
179#[derive(Clone, Debug, Default)]
180pub struct ThemeRoomsValues {
181 pub default: Style,
182 pub unread: Style,
183}
184
185#[derive(Clone, Debug, Default, Deserialize)]
186struct ThemeTabs {
187 #[serde(default)]
188 title: Stylable,
189
190 #[serde(default)]
191 title_focused: Stylable,
192}
193
194impl ThemeTabs {
195 fn merge(self, other: Self) -> Self {
196 Self {
197 title: self.title.merge(other.title),
198 title_focused: self.title_focused.merge(other.title_focused),
199 }
200 }
201
202 fn values(self, base: Style) -> ThemeTabsValues {
203 let title_focused = self.title_focused.merge(self.title);
204
205 ThemeTabsValues {
206 title: base.patch(self.title),
207 title_focused: base.patch(title_focused),
208 }
209 }
210}
211
212#[derive(Clone, Debug, Default)]
213pub struct ThemeTabsValues {
214 pub title: Style,
215 pub title_focused: Style,
216}
217
218#[derive(Clone, Debug, Default, Deserialize)]
219struct ThemeTimeline {
220 #[serde(default)]
221 default: Stylable,
222
223 #[serde(default)]
224 date: Stylable,
225
226 #[serde(default)]
227 time: Stylable,
228
229 #[serde(default)]
230 state: Stylable,
231
232 #[serde(default)]
233 sticker: Stylable,
234
235 #[serde(default)]
236 poll: Stylable,
237
238 #[serde(default)]
239 notice: Stylable,
240
241 #[serde(default)]
242 redacted: Stylable,
243}
244
245impl ThemeTimeline {
246 fn merge(self, other: Self) -> Self {
247 Self {
248 default: self.default.merge(other.default),
249 date: self.date.merge(other.date),
250 time: self.time.merge(other.time),
251 state: self.state.merge(other.state),
252 sticker: self.sticker.merge(other.sticker),
253 poll: self.poll.merge(other.poll),
254 notice: self.notice.merge(other.notice),
255 redacted: self.redacted.merge(other.redacted),
256 }
257 }
258
259 fn values(self, base: Style) -> ThemeTimelineValues {
260 let base = base.patch(self.default);
261
262 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),
271 }
272 }
273}
274
275#[derive(Clone, Debug, Default)]
276pub struct ThemeTimelineValues {
277 pub default: Style,
278 pub date: Style,
279 pub time: Style,
280 pub state: Style,
281 pub sticker: Style,
282 pub poll: Style,
283 pub notice: Style,
284 pub redacted: Style,
285}
286
287#[derive(Clone, Debug, Default, Deserialize)]
288struct ThemeWindows {
289 #[serde(default)]
290 border: Stylable,
291
292 #[serde(default)]
293 border_focused: Stylable,
294
295 #[serde(default)]
296 title: Stylable,
297}
298
299impl ThemeWindows {
300 fn merge(self, other: Self) -> Self {
301 Self {
302 border: self.border.merge(other.border),
303 border_focused: self.border_focused.merge(other.border_focused),
304 title: self.title.merge(other.title),
305 }
306 }
307
308 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 }
314 }
315}
316
317#[derive(Clone, Debug, Default)]
318pub struct ThemeWindowsValues {
319 pub border: Style,
320 pub border_focused: Style,
321 pub title: Style,
322}
src/main.rs +8 −3
@@ -332,6 +332,8 @@ impl Application {
332 term.clear()?; 332 term.clear()?;
333 } 333 }
334 334
335 let theme = store.application.settings.theme.clone();
336
335 term.draw(|f| { 337 term.draw(|f| {
336 let area = f.area(); 338 let area = f.area();
337 339
@@ -347,9 +349,12 @@ impl Application {
347 .show_dialog(dialogstr) 349 .show_dialog(dialogstr)
348 .show_mode(modestr) 350 .show_mode(modestr)
349 .borders(true) 351 .borders(true)
350 .border_style(Style::default().add_modifier(StyleModifier::DIM)) 352 .border_style(theme.windows.border.add_modifier(StyleModifier::DIM))
351 .tab_style(Style::default().add_modifier(StyleModifier::DIM)) 353 .border_style_focused(
352 .tab_style_focused(Style::default().remove_modifier(StyleModifier::DIM)) 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))
353 .focus(focused); 358 .focus(focused);
354 f.render_stateful_widget(screen, area, sstate); 359 f.render_stateful_widget(screen, area, sstate);
355 360
src/message/html.rs +38 −29
@@ -368,7 +368,13 @@ impl StyleTreeNode {
368 } 368 }
369 }, 369 },
370 StyleTreeNode::Code(child, _) => { 370 StyleTreeNode::Code(child, _) => {
371 let style = style.patch(printer.settings().theme.messages.code);
372
373 let old_style = printer.replace_base_style(style);
374
371 child.print(printer, style); 375 child.print(printer, style);
376
377 printer.replace_base_style(old_style);
372 }, 378 },
373 StyleTreeNode::Header(child, level) => { 379 StyleTreeNode::Header(child, level) => {
374 let style = style.add_modifier(StyleModifier::BOLD); 380 let style = style.add_modifier(StyleModifier::BOLD);
@@ -415,9 +421,11 @@ impl StyleTreeNode {
415 }, 421 },
416 StyleTreeNode::Pre(child) => { 422 StyleTreeNode::Pre(child) => {
417 let mut subp = printer.sub(2).literal(true); 423 let mut subp = printer.sub(2).literal(true);
424 let code_style = style.patch(subp.settings().theme.messages.code_block);
425 let _ = subp.replace_base_style(code_style);
418 let subw = subp.width(); 426 let subw = subp.width();
419 427
420 child.print(&mut subp, style); 428 child.print(&mut subp, code_style);
421 429
422 printer.commit(); 430 printer.commit();
423 printer.push_line( 431 printer.push_line(
@@ -1446,6 +1454,7 @@ pub mod tests {
1446 fn test_pre_tag() { 1454 fn test_pre_tag() {
1447 let info = mock_room(); 1455 let info = mock_room();
1448 let settings = mock_settings(); 1456 let settings = mock_settings();
1457 let code_style = settings.theme.messages.code_block;
1449 let s = concat!( 1458 let s = concat!(
1450 "<pre><code class=\"language-rust\">", 1459 "<pre><code class=\"language-rust\">",
1451 "fn hello() -&gt; usize {\n", 1460 "fn hello() -&gt; usize {\n",
@@ -1469,19 +1478,19 @@ pub mod tests {
1469 text.lines[1], 1478 text.lines[1],
1470 Line::from(vec![ 1479 Line::from(vec![
1471 Span::raw(line::VERTICAL), 1480 Span::raw(line::VERTICAL),
1472 Span::raw("fn"), 1481 Span::styled("fn", code_style),
1473 Span::raw(" "), 1482 Span::styled(" ", code_style),
1474 Span::raw("hello"), 1483 Span::styled("hello", code_style),
1475 Span::raw("("), 1484 Span::styled("(", code_style),
1476 Span::raw(")"), 1485 Span::styled(")", code_style),
1477 Span::raw(" "), 1486 Span::styled(" ", code_style),
1478 Span::raw("-"), 1487 Span::styled("-", code_style),
1479 Span::raw(">"), 1488 Span::styled(">", code_style),
1480 Span::raw(" "), 1489 Span::styled(" ", code_style),
1481 Span::raw("usize"), 1490 Span::styled("usize", code_style),
1482 Span::raw(" "), 1491 Span::styled(" ", code_style),
1483 Span::raw("{"), 1492 Span::styled("{", code_style),
1484 Span::raw(" "), 1493 Span::styled(" ", code_style),
1485 Span::raw(line::VERTICAL) 1494 Span::raw(line::VERTICAL)
1486 ]) 1495 ])
1487 ); 1496 );
@@ -1489,13 +1498,13 @@ pub mod tests {
1489 text.lines[2], 1498 text.lines[2],
1490 Line::from(vec![ 1499 Line::from(vec![
1491 Span::raw(line::VERTICAL), 1500 Span::raw(line::VERTICAL),
1492 Span::raw(" "), 1501 Span::styled(" ", code_style),
1493 Span::raw(" "), 1502 Span::styled(" ", code_style),
1494 Span::raw("/"), 1503 Span::styled("/", code_style),
1495 Span::raw("/"), 1504 Span::styled("/", code_style),
1496 Span::raw(" "), 1505 Span::styled(" ", code_style),
1497 Span::raw("weired"), 1506 Span::styled("weired", code_style),
1498 Span::raw(" "), 1507 Span::styled(" ", code_style),
1499 Span::raw(line::VERTICAL) 1508 Span::raw(line::VERTICAL)
1500 ]) 1509 ])
1501 ); 1510 );
@@ -1503,12 +1512,12 @@ pub mod tests {
1503 text.lines[3], 1512 text.lines[3],
1504 Line::from(vec![ 1513 Line::from(vec![
1505 Span::raw(line::VERTICAL), 1514 Span::raw(line::VERTICAL),
1506 Span::raw(" "), 1515 Span::styled(" ", code_style),
1507 Span::raw("return"), 1516 Span::styled("return", code_style),
1508 Span::raw(" "), 1517 Span::styled(" ", code_style),
1509 Span::raw("5"), 1518 Span::styled("5", code_style),
1510 Span::raw(";"), 1519 Span::styled(";", code_style),
1511 Span::raw(" "), 1520 Span::styled(" ", code_style),
1512 Span::raw(line::VERTICAL) 1521 Span::raw(line::VERTICAL)
1513 ]) 1522 ])
1514 ); 1523 );
@@ -1516,8 +1525,8 @@ pub mod tests {
1516 text.lines[4], 1525 text.lines[4],
1517 Line::from(vec![ 1526 Line::from(vec![
1518 Span::raw(line::VERTICAL), 1527 Span::raw(line::VERTICAL),
1519 Span::raw("}"), 1528 Span::styled("}", code_style),
1520 Span::raw(" ".repeat(22)), 1529 Span::styled(" ".repeat(22), code_style),
1521 Span::raw(line::VERTICAL) 1530 Span::raw(line::VERTICAL)
1522 ]) 1531 ])
1523 ); 1532 );
src/message/mod.rs +38 −20
@@ -117,14 +117,6 @@ const fn span_static(s: &'static str) -> Span<'static> {
117 } 117 }
118} 118}
119 119
120const BOLD_STYLE: Style = Style {
121 fg: None,
122 bg: None,
123 add_modifier: StyleModifier::BOLD,
124 sub_modifier: StyleModifier::empty(),
125 underline_color: None,
126};
127
128const TIME_GUTTER: usize = 12; 120const TIME_GUTTER: usize = 12;
129const READ_GUTTER: usize = 5; 121const READ_GUTTER: usize = 5;
130const MIN_MSG_LEN: usize = 30; 122const MIN_MSG_LEN: usize = 30;
@@ -228,10 +220,10 @@ impl MessageTimeStamp {
228 dt1.date_naive() == dt2.date_naive() 220 dt1.date_naive() == dt2.date_naive()
229 } 221 }
230 222
231 fn show_date(self) -> Span<'static> { 223 fn show_date(self, settings: &ApplicationSettings) -> Span<'static> {
232 let time = self.as_datetime().format("%A, %B %d %Y").to_string(); 224 let time = self.as_datetime().format("%A, %B %d %Y").to_string();
233 225
234 Span::styled(time, BOLD_STYLE) 226 Span::styled(time, settings.theme.timeline.date.add_modifier(StyleModifier::BOLD))
235 } 227 }
236 228
237 /// A compact date and time, for places without a date separator line. 229 /// A compact date and time, for places without a date separator line.
@@ -239,11 +231,11 @@ impl MessageTimeStamp {
239 self.as_datetime().format("%Y-%m-%d %H:%M").to_string() 231 self.as_datetime().format("%Y-%m-%d %H:%M").to_string()
240 } 232 }
241 233
242 fn show_time(self) -> Span<'static> { 234 fn show_time(self, settings: &ApplicationSettings) -> Span<'static> {
243 let time = self.as_datetime().format("%T"); 235 let time = self.as_datetime().format("%T");
244 let time = format!(" [{time}]"); 236 let time = format!(" [{time}]");
245 237
246 Span::raw(time) 238 Span::styled(time, settings.theme.timeline.time)
247 } 239 }
248} 240}
249 241
@@ -492,6 +484,33 @@ impl MessageEvent {
492 self.msgtype().and_then(content_filename) 484 self.msgtype().and_then(content_filename)
493 } 485 }
494 486
487 fn message_style(&self, settings: &ApplicationSettings) -> Style {
488 let content = match self {
489 MessageEvent::EncryptedOriginal(_) | MessageEvent::EncryptedRedacted(_) => {
490 return settings.theme.timeline.default;
491 },
492 MessageEvent::Redacted(..) => return settings.theme.timeline.redacted,
493 MessageEvent::State(_) => return settings.theme.timeline.state,
494 MessageEvent::Original(ev, _) => &ev.content,
495 MessageEvent::Local(_, _, content) => content,
496 MessageEvent::Sticker(..) => return settings.theme.timeline.sticker,
497 MessageEvent::Poll(..) | MessageEvent::UnstablePoll(..) => {
498 return settings.theme.timeline.poll;
499 },
500 };
501
502 match &content.msgtype {
503 MessageType::Text(_) |
504 MessageType::Audio(_) |
505 MessageType::Emote(_) |
506 MessageType::File(_) |
507 MessageType::Image(_) |
508 MessageType::Video(_) => settings.theme.messages.default,
509 MessageType::Notice(_) | MessageType::ServerNotice(_) => settings.theme.timeline.notice,
510 _ => settings.theme.messages.default,
511 }
512 }
513
495 fn redact(&mut self, redaction: SyncRoomRedactionEvent) { 514 fn redact(&mut self, redaction: SyncRoomRedactionEvent) {
496 match self { 515 match self {
497 MessageEvent::EncryptedOriginal(_) => return, 516 MessageEvent::EncryptedOriginal(_) => return,
@@ -819,7 +838,7 @@ impl<'a> MessageFormatter<'a> {
819 let reply_style = if settings.tunables.message_user_color { 838 let reply_style = if settings.tunables.message_user_color {
820 style.patch(settings.get_user_color(&msg.sender)) 839 style.patch(settings.get_user_color(&msg.sender))
821 } else { 840 } else {
822 style 841 style.patch(msg.event.message_style(settings))
823 }; 842 };
824 843
825 let width = self.width(); 844 let width = self.width();
@@ -932,14 +951,13 @@ impl<'a> MessageFormatter<'a> {
932 protos 951 protos
933 } 952 }
934 953
935 fn push_thread_reply_count(&mut self, len: usize, text: &mut Text<'a>) { 954 fn push_thread_reply_count(&mut self, len: usize, text: &mut Text<'a>, style: Style) {
936 if len == 0 { 955 if len == 0 {
937 return; 956 return;
938 } 957 }
939 958
940 // If we have threaded replies to this message, show how many. 959 // If we have threaded replies to this message, show how many.
941 let plural = len != 1; 960 let plural = len != 1;
942 let style = Style::default();
943 let mut threaded = 961 let mut threaded =
944 printer::TextPrinter::new(self.width(), style, self.settings, self.info).literal(true); 962 printer::TextPrinter::new(self.width(), style, self.settings, self.info).literal(true);
945 let len = Span::styled(len.to_string(), style.add_modifier(StyleModifier::BOLD)); 963 let len = Span::styled(len.to_string(), style.add_modifier(StyleModifier::BOLD));
@@ -1055,7 +1073,7 @@ impl Message {
1055 } 1073 }
1056 1074
1057 fn get_render_style(&self, selected: bool, settings: &ApplicationSettings) -> Style { 1075 fn get_render_style(&self, selected: bool, settings: &ApplicationSettings) -> Style {
1058 let mut style = Style::default(); 1076 let mut style = self.event.message_style(settings);
1059 1077
1060 if selected { 1078 if selected {
1061 style = style.add_modifier(StyleModifier::REVERSED) 1079 style = style.add_modifier(StyleModifier::REVERSED)
@@ -1133,7 +1151,7 @@ impl Message {
1133 settings: &'a ApplicationSettings, 1151 settings: &'a ApplicationSettings,
1134 ) -> MessageFormatter<'a> { 1152 ) -> MessageFormatter<'a> {
1135 let orig = width; 1153 let orig = width;
1136 let date = self.show_date(prev).then(|| self.timestamp.show_date()); 1154 let date = self.show_date(prev).then(|| self.timestamp.show_date(settings));
1137 let trackbar = self.show_trackbar(prev, info, settings); 1155 let trackbar = self.show_trackbar(prev, info, settings);
1138 let user_gutter = settings.tunables.user_gutter_width; 1156 let user_gutter = settings.tunables.user_gutter_width;
1139 1157
@@ -1143,7 +1161,7 @@ impl Message {
1143 let cols = MessageColumns::Four; 1161 let cols = MessageColumns::Four;
1144 let fill = width - user_gutter - TIME_GUTTER - READ_GUTTER; 1162 let fill = width - user_gutter - TIME_GUTTER - READ_GUTTER;
1145 let user = self.show_sender(prev, true, info, settings, width); 1163 let user = self.show_sender(prev, true, info, settings, width);
1146 let time = Some(self.timestamp.show_time()); 1164 let time = Some(self.timestamp.show_time(settings));
1147 1165
1148 let read = self 1166 let read = self
1149 .event 1167 .event
@@ -1176,7 +1194,7 @@ impl Message {
1176 let cols = MessageColumns::Three; 1194 let cols = MessageColumns::Three;
1177 let fill = width - user_gutter - TIME_GUTTER; 1195 let fill = width - user_gutter - TIME_GUTTER;
1178 let user = self.show_sender(prev, true, info, settings, width); 1196 let user = self.show_sender(prev, true, info, settings, width);
1179 let time = Some(self.timestamp.show_time()); 1197 let time = Some(self.timestamp.show_time(settings));
1180 let read = Vec::new(); 1198 let read = Vec::new();
1181 1199
1182 MessageFormatter { 1200 MessageFormatter {
@@ -1323,7 +1341,7 @@ impl Message {
1323 } 1341 }
1324 1342
1325 if let Some(thread) = self.event.event_id().and_then(|id| info.get_thread(Some(id))) { 1343 if let Some(thread) = self.event.event_id().and_then(|id| info.get_thread(Some(id))) {
1326 fmt.push_thread_reply_count(thread.len(), &mut text); 1344 fmt.push_thread_reply_count(thread.len(), &mut text, style);
1327 } 1345 }
1328 1346
1329 (text, protos) 1347 (text, protos)
src/message/printer.rs +5
@@ -69,6 +69,11 @@ impl<'a> TextPrinter<'a> {
69 self 69 self
70 } 70 }
71 71
72 /// Set the base style and return the old style.
73 pub fn replace_base_style(&mut self, style: Style) -> Style {
74 std::mem::replace(&mut self.base_style, style)
75 }
76
72 /// Indicates whether emojis should be replaced by shortcodes 77 /// Indicates whether emojis should be replaced by shortcodes
73 pub fn emoji_shortcodes(&self) -> bool { 78 pub fn emoji_shortcodes(&self) -> bool {
74 self.tunables().message_shortcode_display 79 self.tunables().message_shortcode_display
src/tests.rs +3 −1
@@ -178,7 +178,7 @@ pub fn mock_tunables() -> TunableValues {
178 typing_notice_send: true, 178 typing_notice_send: true,
179 typing_notice_display: true, 179 typing_notice_display: true,
180 users: vec![(TEST_USER5.clone(), UserDisplayTunables { 180 users: vec![(TEST_USER5.clone(), UserDisplayTunables {
181 color: Some(UserColor(Color::Black)), 181 color: Some(Color::Black),
182 name: Some("USER 5".into()), 182 name: Some("USER 5".into()),
183 })] 183 })]
184 .into_iter() 184 .into_iter()
@@ -224,12 +224,14 @@ pub fn mock_settings() -> ApplicationSettings {
224 layout: None, 224 layout: None,
225 macros: None, 225 macros: None,
226 aliases: None, 226 aliases: None,
227 theme: None,
227 }, 228 },
228 tunables: mock_tunables(), 229 tunables: mock_tunables(),
229 dirs: mock_dirs(), 230 dirs: mock_dirs(),
230 layout: Default::default(), 231 layout: Default::default(),
231 macros: HashMap::default(), 232 macros: HashMap::default(),
232 aliases: Aliases::default(), 233 aliases: Aliases::default(),
234 theme: crate::config::theme::default_theme().values().into(),
233 enable_enhanced_keys: false, 235 enable_enhanced_keys: false,
234 } 236 }
235} 237}
src/windows/mod.rs +48 −42
@@ -31,26 +31,21 @@ pub mod welcome;
31const MEMBER_FETCH_DEBOUNCE: Duration = Duration::from_secs(5); 31const MEMBER_FETCH_DEBOUNCE: Duration = Duration::from_secs(5);
32 32
33#[inline] 33#[inline]
34fn bold_style() -> Style { 34fn bold_span(s: &str, style: Style) -> Span<'_> {
35 Style::default().add_modifier(StyleModifier::BOLD) 35 Span::styled(s, style.bold())
36} 36}
37 37
38#[inline] 38#[inline]
39fn bold_span(s: &str) -> Span<'_> { 39fn bold_spans(s: &str, style: Style) -> Line<'_> {
40 Span::styled(s, bold_style()) 40 bold_span(s, style).into()
41} 41}
42 42
43#[inline] 43#[inline]
44fn bold_spans(s: &str) -> Line<'_> { 44pub fn selected_style(selected: bool, style: Style) -> Style {
45 bold_span(s).into()
46}
47
48#[inline]
49pub fn selected_style(selected: bool) -> Style {
50 if selected { 45 if selected {
51 Style::default().add_modifier(StyleModifier::REVERSED) 46 style.add_modifier(StyleModifier::REVERSED)
52 } else { 47 } else {
53 Style::default() 48 style
54 } 49 }
55} 50}
56 51
@@ -409,8 +404,11 @@ impl IambWindow {
409} 404}
410 405
411pub type MemberListState = ListState<MemberItem, IambInfo>; 406pub type MemberListState = ListState<MemberItem, IambInfo>;
407
412pub type PinnedListState = ListState<PinnedItem, IambInfo>; 408pub type PinnedListState = ListState<PinnedItem, IambInfo>;
409
413pub type RoomListState = ListState<GenericRoomItem, IambInfo>; 410pub type RoomListState = ListState<GenericRoomItem, IambInfo>;
411
414pub type VerifyListState = ListState<VerifyItem, IambInfo>; 412pub type VerifyListState = ListState<VerifyItem, IambInfo>;
415 413
416impl From<RoomState> for IambWindow { 414impl From<RoomState> for IambWindow {
@@ -783,24 +781,25 @@ impl Window<IambInfo> for IambWindow {
783 } 781 }
784 782
785 fn get_tab_title(&self, store: &mut ProgramStore) -> Line<'_> { 783 fn get_tab_title(&self, store: &mut ProgramStore) -> Line<'_> {
784 let style = Default::default();
786 match self { 785 match self {
787 IambWindow::DirectList(_) => bold_spans("Direct Messages"), 786 IambWindow::DirectList(_) => bold_spans("Direct Messages", style),
788 IambWindow::RoomList(_) => bold_spans("Rooms"), 787 IambWindow::RoomList(_) => bold_spans("Rooms", style),
789 IambWindow::SpaceList(_) => bold_spans("Spaces"), 788 IambWindow::SpaceList(_) => bold_spans("Spaces", style),
790 IambWindow::VerifyList(_) => bold_spans("Verifications"), 789 IambWindow::VerifyList(_) => bold_spans("Verifications", style),
791 IambWindow::Welcome(_) => bold_spans("Welcome to iamb"), 790 IambWindow::Welcome(_) => bold_spans("Welcome to iamb", style),
792 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"), 791 IambWindow::ChatList(_) => bold_spans("DMs & Rooms", style),
793 IambWindow::UnreadList(_) => bold_spans("Unread Messages"), 792 IambWindow::UnreadList(_) => bold_spans("Unread Messages", style),
794 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"), 793 IambWindow::MentionsList(_) => bold_spans("Unread Mentions", style),
795 IambWindow::InvitesList(_) => bold_spans("Open Invites"), 794 IambWindow::InvitesList(_) => bold_spans("Open Invites", style),
796 795
797 IambWindow::Room(w) => w.get_tab_title(store), 796 IambWindow::Room(w) => w.get_tab_title(store),
798 IambWindow::MemberList(state, room_id, _) => { 797 IambWindow::MemberList(state, room_id, _) => {
799 let title = store.application.get_room_title(room_id.as_ref()); 798 let title = store.application.get_room_title(room_id.as_ref());
800 let n = state.len(); 799 let n = state.len();
801 let v = vec![ 800 let v = vec![
802 bold_span("Room Members "), 801 bold_span("Room Members ", style),
803 Span::styled(format!("({n}): "), bold_style()), 802 Span::styled(format!("({n}): "), style.bold()),
804 title.into(), 803 title.into(),
805 ]; 804 ];
806 Line::from(v) 805 Line::from(v)
@@ -809,8 +808,8 @@ impl Window<IambInfo> for IambWindow {
809 let title = store.application.get_room_title(room_id.as_ref()); 808 let title = store.application.get_room_title(room_id.as_ref());
810 let n = state.len(); 809 let n = state.len();
811 let v = vec![ 810 let v = vec![
812 bold_span("Pinned Messages "), 811 bold_span("Pinned Messages ", style),
813 Span::styled(format!("({n}): "), bold_style()), 812 Span::styled(format!("({n}): "), style.bold()),
814 title.into(), 813 title.into(),
815 ]; 814 ];
816 Line::from(v) 815 Line::from(v)
@@ -819,24 +818,25 @@ impl Window<IambInfo> for IambWindow {
819 } 818 }
820 819
821 fn get_win_title(&self, store: &mut ProgramStore) -> Line<'_> { 820 fn get_win_title(&self, store: &mut ProgramStore) -> Line<'_> {
821 let style = store.application.settings.theme.windows.title;
822 match self { 822 match self {
823 IambWindow::DirectList(_) => bold_spans("Direct Messages"), 823 IambWindow::DirectList(_) => bold_spans("Direct Messages", style),
824 IambWindow::RoomList(_) => bold_spans("Rooms"), 824 IambWindow::RoomList(_) => bold_spans("Rooms", style),
825 IambWindow::SpaceList(_) => bold_spans("Spaces"), 825 IambWindow::SpaceList(_) => bold_spans("Spaces", style),
826 IambWindow::VerifyList(_) => bold_spans("Verifications"), 826 IambWindow::VerifyList(_) => bold_spans("Verifications", style),
827 IambWindow::Welcome(_) => bold_spans("Welcome to iamb"), 827 IambWindow::Welcome(_) => bold_spans("Welcome to iamb", style),
828 IambWindow::ChatList(_) => bold_spans("DMs & Rooms"), 828 IambWindow::ChatList(_) => bold_spans("DMs & Rooms", style),
829 IambWindow::UnreadList(_) => bold_spans("Unread Messages"), 829 IambWindow::UnreadList(_) => bold_spans("Unread Messages", style),
830 IambWindow::MentionsList(_) => bold_spans("Unread Mentions"), 830 IambWindow::MentionsList(_) => bold_spans("Unread Mentions", style),
831 IambWindow::InvitesList(_) => bold_spans("Open Invites"), 831 IambWindow::InvitesList(_) => bold_spans("Open Invites", style),
832 832
833 IambWindow::Room(w) => w.get_title(store), 833 IambWindow::Room(w) => w.get_title(store, style),
834 IambWindow::MemberList(state, room_id, _) => { 834 IambWindow::MemberList(state, room_id, _) => {
835 let title = store.application.get_room_title(room_id.as_ref()); 835 let title = store.application.get_room_title(room_id.as_ref());
836 let n = state.len(); 836 let n = state.len();
837 let v = vec![ 837 let v = vec![
838 bold_span("Room Members "), 838 bold_span("Room Members ", style),
839 Span::styled(format!("({n}): "), bold_style()), 839 Span::styled(format!("({n}): "), style.bold()),
840 title.into(), 840 title.into(),
841 ]; 841 ];
842 Line::from(v) 842 Line::from(v)
@@ -845,8 +845,8 @@ impl Window<IambInfo> for IambWindow {
845 let title = store.application.get_room_title(room_id.as_ref()); 845 let title = store.application.get_room_title(room_id.as_ref());
846 let n = state.len(); 846 let n = state.len();
847 let v = vec![ 847 let v = vec![
848 bold_span("Pinned Messages "), 848 bold_span("Pinned Messages ", style),
849 Span::styled(format!("({n}): "), bold_style()), 849 Span::styled(format!("({n}): "), style.bold()),
850 title.into(), 850 title.into(),
851 ]; 851 ];
852 Line::from(v) 852 Line::from(v)
@@ -1084,9 +1084,15 @@ impl ListItem<IambInfo> for GenericRoomItem {
1084 &self, 1084 &self,
1085 selected: bool, 1085 selected: bool,
1086 _: &ViewportContext<ListCursor>, 1086 _: &ViewportContext<ListCursor>,
1087 _: &mut ProgramStore, 1087 store: &mut ProgramStore,
1088 ) -> Text<'_> { 1088 ) -> Text<'_> {
1089 let style = selected_style(selected); 1089 let style = if self.unread.is_unread() {
1090 store.application.settings.theme.rooms.unread
1091 } else {
1092 store.application.settings.theme.rooms.default
1093 };
1094
1095 let style = selected_style(selected, style);
1090 let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.membership, style); 1096 let (name, mut labels) = name_and_labels(&self.name, &self.unread, self.membership, style);
1091 let mut spans = vec![name]; 1097 let mut spans = vec![name];
1092 1098
src/windows/room/mod.rs +7 −7
@@ -891,14 +891,14 @@ impl RoomState {
891 } 891 }
892 } 892 }
893 893
894 pub fn get_title(&self, store: &mut ProgramStore) -> Line<'_> { 894 pub fn get_title(&self, store: &mut ProgramStore, style: Style) -> Line<'_> {
895 let Some(room) = self.room() else { 895 let Some(room) = self.room() else {
896 return Line::from("Unjoined Room"); 896 return Line::from("Unjoined Room");
897 }; 897 };
898 898
899 let room_id = room.room_id(); 899 let room_id = room.room_id();
900 let title = store.application.get_room_title(room_id); 900 let title = store.application.get_room_title(room_id);
901 let style = Style::default().add_modifier(StyleModifier::BOLD); 901 let bold_style = style.add_modifier(StyleModifier::BOLD);
902 let mut spans = vec![]; 902 let mut spans = vec![];
903 903
904 let encryption_settings = &store.application.settings.tunables.encryption; 904 let encryption_settings = &store.application.settings.tunables.encryption;
@@ -910,16 +910,16 @@ impl RoomState {
910 if let RoomState::Chat(chat) = self && 910 if let RoomState::Chat(chat) = self &&
911 chat.thread().is_some() 911 chat.thread().is_some()
912 { 912 {
913 spans.push("Thread in ".into()); 913 spans.push(Span::styled("Thread in ", style));
914 } 914 }
915 915
916 spans.push(Span::styled(title, style)); 916 spans.push(Span::styled(title, bold_style));
917 917
918 match room.topic() { 918 match room.topic() {
919 Some(desc) if !desc.is_empty() => { 919 Some(desc) if !desc.is_empty() => {
920 spans.push(" (".into()); 920 spans.push(Span::styled(" (", style));
921 spans.push(desc.into()); 921 spans.push(Span::styled(desc, style));
922 spans.push(")".into()); 922 spans.push(Span::styled(")", style));
923 }, 923 },
924 _ => { 924 _ => {
925 spans.push(" ".into()); 925 spans.push(" ".into());
src/windows/verify.rs +5 −6
@@ -140,9 +140,8 @@ impl ListItem<IambInfo> for VerifyItem {
140 store: &mut ProgramStore, 140 store: &mut ProgramStore,
141 ) -> Text<'_> { 141 ) -> Text<'_> {
142 let mut lines = vec![]; 142 let mut lines = vec![];
143 let bold = Style::default().add_modifier(StyleModifier::BOLD); 143 let bold = Style::default().bold();
144 let selected_bold = super::selected_style(selected).add_modifier(StyleModifier::BOLD); 144 let selected = super::selected_style(selected, Default::default());
145 let selected = super::selected_style(selected);
146 145
147 let mut other_device = None; 146 let mut other_device = None;
148 let state = match self.request.state() { 147 let state = match self.request.state() {
@@ -277,13 +276,13 @@ impl ListItem<IambInfo> for VerifyItem {
277 if let Some(display_name) = device.display_name() { 276 if let Some(display_name) = device.display_name() {
278 vec![ 277 vec![
279 Span::styled("Device verification with ", selected), 278 Span::styled("Device verification with ", selected),
280 Span::styled(display_name.to_owned(), selected_bold), 279 Span::styled(display_name.to_owned(), selected.bold()),
281 Span::styled(format!(" ({state})"), selected), 280 Span::styled(format!(" ({state})"), selected),
282 ] 281 ]
283 } else { 282 } else {
284 vec![ 283 vec![
285 Span::styled("Device verification with ", selected), 284 Span::styled("Device verification with ", selected),
286 Span::styled(device.device_id().to_string(), selected_bold), 285 Span::styled(device.device_id().to_string(), selected.bold()),
287 Span::styled(format!(" ({state})"), selected), 286 Span::styled(format!(" ({state})"), selected),
288 ] 287 ]
289 } 288 }
@@ -297,7 +296,7 @@ impl ListItem<IambInfo> for VerifyItem {
297 let color = store.application.settings.get_user_color(self.request.other_user_id()); 296 let color = store.application.settings.get_user_color(self.request.other_user_id());
298 vec![ 297 vec![
299 Span::styled("User verification with ", selected), 298 Span::styled("User verification with ", selected),
300 Span::styled(self.request.other_user_id().as_str(), selected_bold.patch(color)), 299 Span::styled(self.request.other_user_id().as_str(), selected.bold().patch(color)),
301 Span::styled(format!(" ({state})"), selected), 300 Span::styled(format!(" ({state})"), selected),
302 ] 301 ]
303 }; 302 };