Respect use_color conf value as well as NO_COLOR
parent
a496de2794
commit
14b0ef8f37
|
@ -1041,10 +1041,7 @@ impl Listing {
|
|||
crate::conf::value(context, "mail.sidebar_highlighted_unread_count"),
|
||||
);
|
||||
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
ret.0.attrs |= Attr::Reverse;
|
||||
ret.1.attrs |= Attr::Reverse;
|
||||
ret.2.attrs |= Attr::Reverse;
|
||||
|
|
|
@ -125,10 +125,7 @@ impl MailListingTrait for CompactListing {
|
|||
theme_default: crate::conf::value(context, "theme_default"),
|
||||
..self.color_cache
|
||||
};
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
self.color_cache.highlighted.attrs |= Attr::Reverse;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,10 +111,7 @@ impl MailListingTrait for ConversationsListing {
|
|||
..self.color_cache
|
||||
};
|
||||
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
self.color_cache.highlighted.attrs |= Attr::Reverse;
|
||||
}
|
||||
// Get mailbox as a reference.
|
||||
|
|
|
@ -125,10 +125,7 @@ impl MailListingTrait for PlainListing {
|
|||
thread_snooze_flag: crate::conf::value(context, "mail.listing.thread_snooze_flag"),
|
||||
..self.color_cache
|
||||
};
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
self.color_cache.highlighted.attrs |= Attr::Reverse;
|
||||
}
|
||||
|
||||
|
|
|
@ -82,10 +82,7 @@ impl MailListingTrait for ThreadListing {
|
|||
thread_snooze_flag: crate::conf::value(context, "mail.listing.thread_snooze_flag"),
|
||||
..self.color_cache
|
||||
};
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
self.color_cache.highlighted.attrs |= Attr::Reverse;
|
||||
}
|
||||
|
||||
|
|
|
@ -769,10 +769,7 @@ impl StatusBar {
|
|||
}
|
||||
fn draw_status_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||
let mut attribute = crate::conf::value(context, "status.bar");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
attribute.attrs |= Attr::Reverse;
|
||||
}
|
||||
let (x, y) = write_string_to_grid(
|
||||
|
@ -1347,10 +1344,7 @@ impl Tabbed {
|
|||
}
|
||||
let tab_unfocused_attribute = crate::conf::value(context, "tab.unfocused");
|
||||
let mut tab_focused_attribute = crate::conf::value(context, "tab.focused");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
tab_focused_attribute.attrs |= Attr::Reverse;
|
||||
}
|
||||
|
||||
|
@ -1836,10 +1830,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Component for Selector<T> {
|
|||
let (width, height) = self.content.size();
|
||||
let shortcuts = self.get_shortcuts(context);
|
||||
let mut highlighted_attrs = crate::conf::value(context, "widgets.options.highlighted");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
highlighted_attrs.attrs |= Attr::Reverse;
|
||||
}
|
||||
match (event, self.cursor) {
|
||||
|
@ -1947,10 +1938,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Component for Selector<T> {
|
|||
self.cursor = SelectorCursor::Entry(c);
|
||||
let mut highlighted_attrs =
|
||||
crate::conf::value(context, "widgets.options.highlighted");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
highlighted_attrs.attrs |= Attr::Reverse;
|
||||
}
|
||||
for c in self.content.row_iter(2..4, c + 2) {
|
||||
|
@ -2227,10 +2215,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send> Selector<T> {
|
|||
);
|
||||
}
|
||||
let mut highlighted_attrs = crate::conf::value(context, "widgets.options.highlighted");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
highlighted_attrs.attrs |= Attr::Reverse;
|
||||
}
|
||||
if single_only {
|
||||
|
|
|
@ -430,10 +430,7 @@ impl Component for FormWidget {
|
|||
if self.focus == FormFocus::Fields {
|
||||
let mut field_attrs =
|
||||
crate::conf::value(context, "widgets.form.highlighted");
|
||||
if std::env::var("NO_COLOR").is_ok()
|
||||
&& (context.settings.terminal.use_color.is_false()
|
||||
|| context.settings.terminal.use_color.is_internal())
|
||||
{
|
||||
if !context.settings.terminal.use_color() {
|
||||
field_attrs.attrs |= Attr::Reverse;
|
||||
}
|
||||
for row in grid.bounds_iter((
|
||||
|
|
|
@ -49,3 +49,15 @@ impl Default for TerminalSettings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TerminalSettings {
|
||||
pub fn use_color(&self) -> bool {
|
||||
/* Don't use color if
|
||||
* - Either NO_COLOR is set and user hasn't explicitly set use_colors or
|
||||
* - User has explicitly set use_colors to false
|
||||
*/
|
||||
!((std::env::var("NO_COLOR").is_ok()
|
||||
&& (self.use_color.is_false() || self.use_color.is_internal()))
|
||||
|| (self.use_color.is_false() && !self.use_color.is_internal()))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -296,13 +296,10 @@ impl State {
|
|||
components: Vec::with_capacity(1),
|
||||
timer,
|
||||
draw_rate_limit: RateLimit::new(1, 3),
|
||||
draw_horizontal_segment_fn: if env::var("NO_COLOR").is_ok()
|
||||
&& (settings.terminal.use_color.is_false()
|
||||
|| settings.terminal.use_color.is_internal())
|
||||
{
|
||||
State::draw_horizontal_segment_no_color
|
||||
} else {
|
||||
draw_horizontal_segment_fn: if settings.terminal.use_color() {
|
||||
State::draw_horizontal_segment
|
||||
} else {
|
||||
State::draw_horizontal_segment_no_color
|
||||
},
|
||||
display_messages: SmallVec::new(),
|
||||
display_messages_expiration_start: None,
|
||||
|
|
Loading…
Reference in New Issue