Commit 3ed87aae05
Unregistered key
Layout: unified · split
docs/iamb.5.md +3
| @@ -82,6 +82,9 @@ overridden as described in *PROFILES*. | ||
| 82 | 82 | **default_room** (type: string) |
| 83 | 83 | > The room to show by default instead of a welcome-screen. |
| 84 | 84 | |
| 85 | **message_user_color** (type: boolean) | |
| 86 | > Defines whether or not the message body is colored like the username. | |
| 87 | ||
| 85 | 88 | **image_preview** (type: image_preview object) |
| 86 | 89 | > Enable image previews and configure it. An empty object will enable the |
| 87 | 90 | > feature with default settings, omitting it will disable the feature. |
src/config.rs +4
| @@ -347,6 +347,7 @@ pub struct TunableValues { | ||
| 347 | 347 | pub typing_notice_display: bool, |
| 348 | 348 | pub users: UserOverrides, |
| 349 | 349 | pub username_display: UserDisplayStyle, |
| 350 | pub message_user_color: bool, | |
| 350 | 351 | pub default_room: Option<String>, |
| 351 | 352 | pub open_command: Option<Vec<String>>, |
| 352 | 353 | pub image_preview: Option<ImagePreviewValues>, |
| @@ -366,6 +367,7 @@ pub struct Tunables { | ||
| 366 | 367 | pub typing_notice_display: Option<bool>, |
| 367 | 368 | pub users: Option<UserOverrides>, |
| 368 | 369 | pub username_display: Option<UserDisplayStyle>, |
| 370 | pub message_user_color: Option<bool>, | |
| 369 | 371 | pub default_room: Option<String>, |
| 370 | 372 | pub open_command: Option<Vec<String>>, |
| 371 | 373 | pub image_preview: Option<ImagePreview>, |
| @@ -387,6 +389,7 @@ impl Tunables { | ||
| 387 | 389 | typing_notice_display: self.typing_notice_display.or(other.typing_notice_display), |
| 388 | 390 | users: merge_users(self.users, other.users), |
| 389 | 391 | username_display: self.username_display.or(other.username_display), |
| 392 | message_user_color: self.message_user_color.or(other.message_user_color), | |
| 390 | 393 | default_room: self.default_room.or(other.default_room), |
| 391 | 394 | open_command: self.open_command.or(other.open_command), |
| 392 | 395 | image_preview: self.image_preview.or(other.image_preview), |
| @@ -406,6 +409,7 @@ impl Tunables { | ||
| 406 | 409 | typing_notice_display: self.typing_notice_display.unwrap_or(true), |
| 407 | 410 | users: self.users.unwrap_or_default(), |
| 408 | 411 | username_display: self.username_display.unwrap_or_default(), |
| 412 | message_user_color: self.message_user_color.unwrap_or(false), | |
| 409 | 413 | default_room: self.default_room, |
| 410 | 414 | open_command: self.open_command, |
| 411 | 415 | image_preview: self.image_preview.map(ImagePreview::values), |
src/message/mod.rs +7 −2
| @@ -635,7 +635,7 @@ impl Message { | ||
| 635 | 635 | } |
| 636 | 636 | } |
| 637 | 637 | |
| 638 | fn get_render_style(&self, selected: bool) -> Style { | |
| 638 | fn get_render_style(&self, selected: bool, settings: &ApplicationSettings) -> Style { | |
| 639 | 639 | let mut style = Style::default(); |
| 640 | 640 | |
| 641 | 641 | if selected { |
| @@ -646,6 +646,11 @@ impl Message { | ||
| 646 | 646 | style = style.add_modifier(StyleModifier::ITALIC); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | if settings.tunables.message_user_color { | |
| 650 | let color = crate::config::user_color(self.sender.as_str()); | |
| 651 | style = style.fg(color); | |
| 652 | } | |
| 653 | ||
| 649 | 654 | return style; |
| 650 | 655 | } |
| 651 | 656 | |
| @@ -739,7 +744,7 @@ impl Message { | ||
| 739 | 744 | ) -> Text<'a> { |
| 740 | 745 | let width = vwctx.get_width(); |
| 741 | 746 | |
| 742 | let style = self.get_render_style(selected); | |
| 747 | let style = self.get_render_style(selected, settings); | |
| 743 | 748 | let mut fmt = self.get_render_format(prev, width, info, settings); |
| 744 | 749 | let mut text = Text { lines: vec![] }; |
| 745 | 750 | let width = fmt.width(); |
src/tests.rs +1
| @@ -196,6 +196,7 @@ pub fn mock_tunables() -> TunableValues { | ||
| 196 | 196 | .collect::<HashMap<_, _>>(), |
| 197 | 197 | open_command: None, |
| 198 | 198 | username_display: UserDisplayStyle::Username, |
| 199 | message_user_color: false, | |
| 199 | 200 | image_preview: None, |
| 200 | 201 | } |
| 201 | 202 | } |