Commit 3ed87aae05

3ed87aae0570e5de89687a48a68d070a7691a613

parent: 1325295d2b

Unregistered key

Benjamin Grosse <ste3ls@gmail.com> · 2024-02-28 06:52 UTC
committer: <noreply@github.com>

Support coloring entire message with the user color (#193)

Layout: unified · split

docs/iamb.5.md +3
@@ -82,6 +82,9 @@ overridden as described in *PROFILES*.
8282**default_room** (type: string)
8383> The room to show by default instead of a welcome-screen.
8484
85**message_user_color** (type: boolean)
86> Defines whether or not the message body is colored like the username.
87
8588**image_preview** (type: image_preview object)
8689> Enable image previews and configure it. An empty object will enable the
8790> feature with default settings, omitting it will disable the feature.
src/config.rs +4
@@ -347,6 +347,7 @@ pub struct TunableValues {
347347 pub typing_notice_display: bool,
348348 pub users: UserOverrides,
349349 pub username_display: UserDisplayStyle,
350 pub message_user_color: bool,
350351 pub default_room: Option<String>,
351352 pub open_command: Option<Vec<String>>,
352353 pub image_preview: Option<ImagePreviewValues>,
@@ -366,6 +367,7 @@ pub struct Tunables {
366367 pub typing_notice_display: Option<bool>,
367368 pub users: Option<UserOverrides>,
368369 pub username_display: Option<UserDisplayStyle>,
370 pub message_user_color: Option<bool>,
369371 pub default_room: Option<String>,
370372 pub open_command: Option<Vec<String>>,
371373 pub image_preview: Option<ImagePreview>,
@@ -387,6 +389,7 @@ impl Tunables {
387389 typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
388390 users: merge_users(self.users, other.users),
389391 username_display: self.username_display.or(other.username_display),
392 message_user_color: self.message_user_color.or(other.message_user_color),
390393 default_room: self.default_room.or(other.default_room),
391394 open_command: self.open_command.or(other.open_command),
392395 image_preview: self.image_preview.or(other.image_preview),
@@ -406,6 +409,7 @@ impl Tunables {
406409 typing_notice_display: self.typing_notice_display.unwrap_or(true),
407410 users: self.users.unwrap_or_default(),
408411 username_display: self.username_display.unwrap_or_default(),
412 message_user_color: self.message_user_color.unwrap_or(false),
409413 default_room: self.default_room,
410414 open_command: self.open_command,
411415 image_preview: self.image_preview.map(ImagePreview::values),
src/message/mod.rs +7 −2
@@ -635,7 +635,7 @@ impl Message {
635635 }
636636 }
637637
638 fn get_render_style(&self, selected: bool) -> Style {
638 fn get_render_style(&self, selected: bool, settings: &ApplicationSettings) -> Style {
639639 let mut style = Style::default();
640640
641641 if selected {
@@ -646,6 +646,11 @@ impl Message {
646646 style = style.add_modifier(StyleModifier::ITALIC);
647647 }
648648
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
649654 return style;
650655 }
651656
@@ -739,7 +744,7 @@ impl Message {
739744 ) -> Text<'a> {
740745 let width = vwctx.get_width();
741746
742 let style = self.get_render_style(selected);
747 let style = self.get_render_style(selected, settings);
743748 let mut fmt = self.get_render_format(prev, width, info, settings);
744749 let mut text = Text { lines: vec![] };
745750 let width = fmt.width();
src/tests.rs +1
@@ -196,6 +196,7 @@ pub fn mock_tunables() -> TunableValues {
196196 .collect::<HashMap<_, _>>(),
197197 open_command: None,
198198 username_display: UserDisplayStyle::Username,
199 message_user_color: false,
199200 image_preview: None,
200201 }
201202}