mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-20 05:39:52 -07:00
Support coloring entire message with the user color (#193)
This commit is contained in:
parent
1325295d2b
commit
3ed87aae05
4 changed files with 15 additions and 2 deletions
|
@ -82,6 +82,9 @@ overridden as described in *PROFILES*.
|
||||||
**default_room** (type: string)
|
**default_room** (type: string)
|
||||||
> The room to show by default instead of a welcome-screen.
|
> The room to show by default instead of a welcome-screen.
|
||||||
|
|
||||||
|
**message_user_color** (type: boolean)
|
||||||
|
> Defines whether or not the message body is colored like the username.
|
||||||
|
|
||||||
**image_preview** (type: image_preview object)
|
**image_preview** (type: image_preview object)
|
||||||
> Enable image previews and configure it. An empty object will enable the
|
> Enable image previews and configure it. An empty object will enable the
|
||||||
> feature with default settings, omitting it will disable the feature.
|
> feature with default settings, omitting it will disable the feature.
|
||||||
|
|
|
@ -347,6 +347,7 @@ pub struct TunableValues {
|
||||||
pub typing_notice_display: bool,
|
pub typing_notice_display: bool,
|
||||||
pub users: UserOverrides,
|
pub users: UserOverrides,
|
||||||
pub username_display: UserDisplayStyle,
|
pub username_display: UserDisplayStyle,
|
||||||
|
pub message_user_color: bool,
|
||||||
pub default_room: Option<String>,
|
pub default_room: Option<String>,
|
||||||
pub open_command: Option<Vec<String>>,
|
pub open_command: Option<Vec<String>>,
|
||||||
pub image_preview: Option<ImagePreviewValues>,
|
pub image_preview: Option<ImagePreviewValues>,
|
||||||
|
@ -366,6 +367,7 @@ pub struct Tunables {
|
||||||
pub typing_notice_display: Option<bool>,
|
pub typing_notice_display: Option<bool>,
|
||||||
pub users: Option<UserOverrides>,
|
pub users: Option<UserOverrides>,
|
||||||
pub username_display: Option<UserDisplayStyle>,
|
pub username_display: Option<UserDisplayStyle>,
|
||||||
|
pub message_user_color: Option<bool>,
|
||||||
pub default_room: Option<String>,
|
pub default_room: Option<String>,
|
||||||
pub open_command: Option<Vec<String>>,
|
pub open_command: Option<Vec<String>>,
|
||||||
pub image_preview: Option<ImagePreview>,
|
pub image_preview: Option<ImagePreview>,
|
||||||
|
@ -387,6 +389,7 @@ impl Tunables {
|
||||||
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
|
typing_notice_display: self.typing_notice_display.or(other.typing_notice_display),
|
||||||
users: merge_users(self.users, other.users),
|
users: merge_users(self.users, other.users),
|
||||||
username_display: self.username_display.or(other.username_display),
|
username_display: self.username_display.or(other.username_display),
|
||||||
|
message_user_color: self.message_user_color.or(other.message_user_color),
|
||||||
default_room: self.default_room.or(other.default_room),
|
default_room: self.default_room.or(other.default_room),
|
||||||
open_command: self.open_command.or(other.open_command),
|
open_command: self.open_command.or(other.open_command),
|
||||||
image_preview: self.image_preview.or(other.image_preview),
|
image_preview: self.image_preview.or(other.image_preview),
|
||||||
|
@ -406,6 +409,7 @@ impl Tunables {
|
||||||
typing_notice_display: self.typing_notice_display.unwrap_or(true),
|
typing_notice_display: self.typing_notice_display.unwrap_or(true),
|
||||||
users: self.users.unwrap_or_default(),
|
users: self.users.unwrap_or_default(),
|
||||||
username_display: self.username_display.unwrap_or_default(),
|
username_display: self.username_display.unwrap_or_default(),
|
||||||
|
message_user_color: self.message_user_color.unwrap_or(false),
|
||||||
default_room: self.default_room,
|
default_room: self.default_room,
|
||||||
open_command: self.open_command,
|
open_command: self.open_command,
|
||||||
image_preview: self.image_preview.map(ImagePreview::values),
|
image_preview: self.image_preview.map(ImagePreview::values),
|
||||||
|
|
|
@ -635,7 +635,7 @@ impl Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_render_style(&self, selected: bool) -> Style {
|
fn get_render_style(&self, selected: bool, settings: &ApplicationSettings) -> Style {
|
||||||
let mut style = Style::default();
|
let mut style = Style::default();
|
||||||
|
|
||||||
if selected {
|
if selected {
|
||||||
|
@ -646,6 +646,11 @@ impl Message {
|
||||||
style = style.add_modifier(StyleModifier::ITALIC);
|
style = style.add_modifier(StyleModifier::ITALIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if settings.tunables.message_user_color {
|
||||||
|
let color = crate::config::user_color(self.sender.as_str());
|
||||||
|
style = style.fg(color);
|
||||||
|
}
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +744,7 @@ impl Message {
|
||||||
) -> Text<'a> {
|
) -> Text<'a> {
|
||||||
let width = vwctx.get_width();
|
let width = vwctx.get_width();
|
||||||
|
|
||||||
let style = self.get_render_style(selected);
|
let style = self.get_render_style(selected, settings);
|
||||||
let mut fmt = self.get_render_format(prev, width, info, settings);
|
let mut fmt = self.get_render_format(prev, width, info, settings);
|
||||||
let mut text = Text { lines: vec![] };
|
let mut text = Text { lines: vec![] };
|
||||||
let width = fmt.width();
|
let width = fmt.width();
|
||||||
|
|
|
@ -196,6 +196,7 @@ pub fn mock_tunables() -> TunableValues {
|
||||||
.collect::<HashMap<_, _>>(),
|
.collect::<HashMap<_, _>>(),
|
||||||
open_command: None,
|
open_command: None,
|
||||||
username_display: UserDisplayStyle::Username,
|
username_display: UserDisplayStyle::Username,
|
||||||
|
message_user_color: false,
|
||||||
image_preview: None,
|
image_preview: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue