Browse Source

Add Italics, Blink, Dim and Hidden text attributes

Text attributes have been rewritten as bit flags, so for example instead of
"BoldUnderline" you'd have to define "Bold | Underline" in your theme
settings.

Requested in #21
master
Manos Pitsidianakis 2 years ago
parent
commit
4930d1b46c
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 1
      Cargo.toml
  2. 12
      meli-themes.5
  3. 2
      src/bin.rs
  4. 10
      src/components/contacts/contact_list.rs
  5. 2
      src/components/mail/compose.rs
  6. 12
      src/components/mail/listing.rs
  7. 12
      src/components/mail/listing/compact.rs
  8. 18
      src/components/mail/listing/conversations.rs
  9. 4
      src/components/mail/listing/plain.rs
  10. 4
      src/components/mail/listing/thread.rs
  11. 20
      src/components/mail/status.rs
  12. 10
      src/components/mail/view.rs
  13. 10
      src/components/mail/view/envelope.rs
  14. 8
      src/components/mail/view/thread.rs
  15. 104
      src/components/utilities.rs
  16. 12
      src/components/utilities/widgets.rs
  17. 23
      src/conf/themes.rs
  18. 4
      src/state.rs
  19. 291
      src/terminal/cells.rs

1
Cargo.toml

@ -50,6 +50,7 @@ rmp = "^0.8"
rmpv = { version = "^0.4.2", features=["with-serde",] }
rmp-serde = "^0.14.0"
smallvec = { version = "1.1.0", features = ["serde", ] }
bitflags = "1.0"
[profile.release]

12
meli-themes.5

@ -104,17 +104,19 @@ Case-sensitive.
.It
"Bold"
.It
"Dim"
.It
"Italics"
.It
"Underline"
.It
"BoldUnderline"
"Blink"
.It
"Reverse"
.It
"BoldReverse"
.It
"UnderlineReverse"
"Hidden"
.It
"BoldReverseUnderline"
Any combo of the above separated by a bitwise XOR "\&|" eg "Dim | Italics"
.El
.Sh VALID COLOR VALUES
Color values are of type String with the following valid contents:

2
src/bin.rs

@ -45,6 +45,8 @@ extern crate nom;
extern crate serde_json;
extern crate smallvec;
#[macro_use]
extern crate bitflags;
#[global_allocator]
static GLOBAL: System = System;

10
src/components/contacts/contact_list.rs

@ -287,13 +287,13 @@ impl ContactList {
if a.name.grapheme_len() + s.len() > width + 1 {
/* Print account name */
let (x, y) =
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, None);
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
write_string_to_grid(
&s,
grid,
fg_color,
bg_color,
Attr::Bold,
Attr::BOLD,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
@ -308,7 +308,7 @@ impl ContactList {
grid,
fg_color,
bg_color,
Attr::Bold,
Attr::BOLD,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),
@ -327,13 +327,13 @@ impl ContactList {
/* Print account name */
let (x, y) =
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::Bold, area, None);
write_string_to_grid(&a.name, grid, fg_color, bg_color, Attr::BOLD, area, None);
write_string_to_grid(
&s,
grid,
fg_color,
bg_color,
Attr::Bold,
Attr::BOLD,
(
pos_dec(
(get_x(bottom_right!(area)), get_y(upper_left!(area))),

2
src/components/mail/compose.rs

@ -457,7 +457,7 @@ impl Component for Composer {
grid,
Color::Byte(189),
Color::Byte(167),
Attr::Default,
Attr::DEFAULT,
(
pos_dec(upper_left!(header_area), (0, 1)),
bottom_right!(header_area),

12
src/components/mail/listing.rs

@ -1226,7 +1226,7 @@ impl Listing {
grid,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
area,
None,
);
@ -1262,9 +1262,9 @@ impl Listing {
);
if !context.settings.terminal.use_color() {
ret.0.attrs |= Attr::Reverse;
ret.1.attrs |= Attr::Reverse;
ret.2.attrs |= Attr::Reverse;
ret.0.attrs |= Attr::REVERSE;
ret.1.attrs |= Attr::REVERSE;
ret.2.attrs |= Attr::REVERSE;
}
ret
} else {
@ -1349,9 +1349,9 @@ impl Listing {
unread_count_att.bg,
unread_count_att.attrs
| if count.unwrap_or(0) > 0 {
Attr::Bold
Attr::BOLD
} else {
Attr::Default
Attr::DEFAULT
},
(
(

12
src/components/mail/listing/compact.rs

@ -127,7 +127,7 @@ impl MailListingTrait for CompactListing {
..self.color_cache
};
if !context.settings.terminal.use_color() {
self.color_cache.highlighted.attrs |= Attr::Reverse;
self.color_cache.highlighted.attrs |= Attr::REVERSE;
}
// Get mailbox as a reference.
@ -1040,7 +1040,7 @@ impl CompactListing {
&mut columns[0],
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (min_width.0, idx)),
None,
);
@ -1052,7 +1052,7 @@ impl CompactListing {
&mut columns[1],
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (min_width.1.saturating_sub(1), idx)),
None,
);
@ -1064,7 +1064,7 @@ impl CompactListing {
&mut columns[2],
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (min_width.2, idx)),
None,
);
@ -1076,7 +1076,7 @@ impl CompactListing {
&mut columns[3],
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (min_width.3, idx)),
None,
);
@ -1088,7 +1088,7 @@ impl CompactListing {
&mut columns[4],
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (min_width.4, idx)),
None,
);

18
src/components/mail/listing/conversations.rs

@ -114,7 +114,7 @@ impl MailListingTrait for ConversationsListing {
};
if !context.settings.terminal.use_color() {
self.color_cache.highlighted.attrs |= Attr::Reverse;
self.color_cache.highlighted.attrs |= Attr::REVERSE;
}
// Get mailbox as a reference.
//
@ -765,7 +765,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, 3 * idx), (width - 1, 3 * idx)),
None,
);
@ -778,7 +778,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Bold,
Attr::BOLD,
((x, 3 * idx), (width - 1, 3 * idx)),
None,
);
@ -817,7 +817,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, 3 * idx + 1), (width - 1, 3 * idx + 1)),
None,
);
@ -833,7 +833,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((x + 4, 3 * idx + 1), (width - 1, 3 * idx + 1)),
None,
);
@ -971,7 +971,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, 3 * idx), (width - 1, 3 * idx)),
None,
);
@ -984,7 +984,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Bold,
Attr::BOLD,
((x, 3 * idx), (width - 1, 3 * idx)),
None,
);
@ -1029,7 +1029,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, 3 * idx + 1), (width - 1, 3 * idx + 1)),
None,
);
@ -1043,7 +1043,7 @@ impl ConversationsListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((x + 4, 3 * idx + 1), (width - 1, 3 * idx + 1)),
None,
);

4
src/components/mail/listing/plain.rs

@ -127,7 +127,7 @@ impl MailListingTrait for PlainListing {
..self.color_cache
};
if !context.settings.terminal.use_color() {
self.color_cache.highlighted.attrs |= Attr::Reverse;
self.color_cache.highlighted.attrs |= Attr::REVERSE;
}
// Get mailbox as a reference.
@ -982,7 +982,7 @@ impl Component for PlainListing {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
area,
Some(get_x(upper_left)),
);

4
src/components/mail/listing/thread.rs

@ -83,7 +83,7 @@ impl MailListingTrait for ThreadListing {
..self.color_cache
};
if !context.settings.terminal.use_color() {
self.color_cache.highlighted.attrs |= Attr::Reverse;
self.color_cache.highlighted.attrs |= Attr::REVERSE;
}
// Get mailbox as a reference.
@ -191,7 +191,7 @@ impl MailListingTrait for ThreadListing {
&mut self.content,
fg_color,
bg_color,
Attr::Default,
Attr::DEFAULT,
((0, idx), (MAX_COLS - 1, idx)),
None,
);

20
src/components/mail/status.rs

@ -53,7 +53,7 @@ impl Component for StatusPanel {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, 1), (width - 1, height - 1)),
Some(1),
);
@ -91,7 +91,7 @@ impl Component for StatusPanel {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, y + 1), (width - 1, height - 1)),
Some(1),
);
@ -276,7 +276,7 @@ impl StatusPanel {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((3, 12 + i * 10), (120 - 2, 12 + i * 10)),
Some(3),
);
@ -356,7 +356,7 @@ impl StatusPanel {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((5 + column_width, y + 2), (120 - 2, y + 2)),
None,
);
@ -395,7 +395,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, 0), (width - 1, height - 1)),
None,
);
@ -406,7 +406,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, line), (width - 1, height - 1)),
None,
);
@ -429,7 +429,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, line), (width - 1, height - 1)),
None,
);
@ -474,7 +474,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, line), (width - 1, height - 1)),
None,
);
@ -501,7 +501,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, line), (width - 1, height - 1)),
None,
);
@ -531,7 +531,7 @@ impl Component for AccountStatus {
&mut self.content,
self.theme_default.fg,
self.theme_default.bg,
Attr::Bold,
Attr::BOLD,
((1, line), (width - 1, height - 1)),
None,
);

10
src/components/mail/view.rs

@ -492,7 +492,7 @@ impl Component for MailView {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((_x, y), bottom_right),
None,
);
@ -524,7 +524,7 @@ impl Component for MailView {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x, y), bottom_right),
Some(get_x(upper_left)),
);
@ -537,7 +537,7 @@ impl Component for MailView {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x, y), bottom_right),
Some(get_x(upper_left)),
);
@ -550,7 +550,7 @@ impl Component for MailView {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x, y), bottom_right),
Some(get_x(upper_left)),
);
@ -743,7 +743,7 @@ impl Component for MailView {
grid,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
(set_y(upper_left, y), bottom_right),
Some(get_x(upper_left)),
);

10
src/components/mail/view/envelope.rs

@ -241,7 +241,7 @@ impl Component for EnvelopeView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
area,
Some(get_x(upper_left)),
);
@ -255,7 +255,7 @@ impl Component for EnvelopeView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
(set_y(upper_left, y + 1), bottom_right),
Some(get_x(upper_left)),
);
@ -269,7 +269,7 @@ impl Component for EnvelopeView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
(set_y(upper_left, y + 1), bottom_right),
Some(get_x(upper_left)),
);
@ -283,7 +283,7 @@ impl Component for EnvelopeView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
(set_y(upper_left, y + 1), bottom_right),
Some(get_x(upper_left)),
);
@ -297,7 +297,7 @@ impl Component for EnvelopeView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
(set_y(upper_left, y + 1), bottom_right),
Some(get_x(upper_left)),
);

8
src/components/mail/view/thread.rs

@ -266,7 +266,7 @@ impl ThreadView {
} else {
Color::Byte(251)
},
Attr::Default,
Attr::DEFAULT,
(
(e.index.0 * 4 + 1, 2 * y),
(e.index.0 * 4 + e.heading.grapheme_width() + 1, height - 1),
@ -348,7 +348,7 @@ impl ThreadView {
} else {
Color::Byte(251)
},
Attr::Default,
Attr::DEFAULT,
(
(e.index.0 * 4 + 1, 2 * y),
(e.index.0 * 4 + e.heading.grapheme_width() + 1, height - 1),
@ -668,7 +668,7 @@ impl ThreadView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
area,
Some(get_x(upper_left)),
);
@ -771,7 +771,7 @@ impl ThreadView {
grid,
Color::Byte(33),
Color::Default,
Attr::Default,
Attr::DEFAULT,
area,
Some(get_x(upper_left)),
);

104
src/components/utilities.rs

@ -495,13 +495,13 @@ impl Pager {
content,
colors.fg,
colors.bg,
Attr::Default,
Attr::DEFAULT,
((0, i), (width.saturating_sub(1), i)),
None,
);
if l.starts_with("⤷") {
content[(0, i)].set_fg(Color::Byte(240));
content[(0, i)].set_attrs(Attr::Bold);
content[(0, i)].set_attrs(Attr::BOLD);
}
}
}
@ -874,7 +874,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 !context.settings.terminal.use_color() {
attribute.attrs |= Attr::Reverse;
attribute.attrs |= Attr::REVERSE;
}
let (x, y) = write_string_to_grid(
&self.status,
@ -900,7 +900,7 @@ impl StatusBar {
get_x(bottom_right!(area)),
)
{
grid[(x, y)].set_attrs(attribute.attrs | Attr::Bold);
grid[(x, y)].set_attrs(attribute.attrs | Attr::BOLD);
}
}
@ -923,7 +923,7 @@ impl StatusBar {
grid,
Color::Byte(219),
Color::Byte(88),
Attr::Default,
Attr::DEFAULT,
area,
None,
);
@ -931,7 +931,7 @@ impl StatusBar {
pos_inc(upper_left!(area), (self.ex_buffer.cursor(), 0)).0,
y,
) {
cell.set_attrs(Attr::Underline);
cell.set_attrs(Attr::UNDERLINE);
}
change_colors(grid, area, Color::Byte(219), Color::Byte(88));
context.dirty_areas.push_back(area);
@ -1125,7 +1125,7 @@ impl Component for StatusBar {
grid,
Color::Byte(88), // DarkRed,
Color::Byte(174), //LightPink3
Attr::Default,
Attr::DEFAULT,
(
set_y(
upper_left!(hist_area),
@ -1140,7 +1140,7 @@ impl Component for StatusBar {
grid,
Color::White,
Color::Byte(174),
Attr::Default,
Attr::DEFAULT,
((x + 2, y), bottom_right!(hist_area)),
None,
);
@ -1165,7 +1165,7 @@ impl Component for StatusBar {
grid,
Color::Byte(97), // MediumPurple3,
Color::Byte(88), //LightPink3
Attr::Default,
Attr::DEFAULT,
(
(
get_x(upper_left)
@ -1482,7 +1482,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 !context.settings.terminal.use_color() {
tab_focused_attribute.attrs |= Attr::Reverse;
tab_focused_attribute.attrs |= Attr::REVERSE;
}
let mut x = get_x(upper_left);
@ -1683,7 +1683,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Bold,
Attr::BOLD,
((2, 0), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1692,7 +1692,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x + 1, y), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1701,7 +1701,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((2, 1), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1712,7 +1712,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((2, 2), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1724,7 +1724,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((2, 2 + idx), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1738,7 +1738,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Bold,
Attr::BOLD,
((2, 2 + idx), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -1747,7 +1747,7 @@ impl Component for Tabbed {
&mut self.help_content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x + 2, y), (max_width.saturating_sub(2), max_length - 1)),
None,
);
@ -2167,7 +2167,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
let shortcuts = self.get_shortcuts(context);
let mut highlighted_attrs = crate::conf::value(context, "widgets.options.highlighted");
if !context.settings.terminal.use_color() {
highlighted_attrs.attrs |= Attr::Reverse;
highlighted_attrs.attrs |= Attr::REVERSE;
}
match (event, self.cursor) {
(UIEvent::Input(Key::Char('\n')), _) if self.single_only => {
@ -2188,7 +2188,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
&mut self.content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((3, c + 2), (width - 2, c + 2)),
None,
);
@ -2198,7 +2198,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
&mut self.content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((3, c + 2), (width - 2, c + 2)),
None,
);
@ -2240,7 +2240,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..(width - 2), c + 1) {
self.content[c]
@ -2256,7 +2256,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..4, c + 1) {
self.content[c]
@ -2280,14 +2280,14 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
let c = self.entries.len().saturating_sub(1);
self.cursor = SelectorCursor::Entry(c);
let mut highlighted_attrs =
crate::conf::value(context, "widgets.options.highlighted");
if !context.settings.terminal.use_color() {
highlighted_attrs.attrs |= Attr::Reverse;
highlighted_attrs.attrs |= Attr::REVERSE;
}
for c in self.content.row_iter(2..4, c + 2) {
self.content[c]
@ -2308,7 +2308,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..(width - 2), c + 3) {
self.content[c]
@ -2324,7 +2324,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..4, c + 3) {
self.content[c]
@ -2345,7 +2345,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(
((width - "OK Cancel".len()) / 2)..((width - "OK Cancel".len()) / 2 + 1),
@ -2370,7 +2370,7 @@ impl<T: 'static + PartialEq + Debug + Clone + Sync + Send> Component for UIDialo
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(
((width - "OK Cancel".len()) / 2 + 6)
@ -2455,7 +2455,7 @@ impl Component for UIConfirmationDialog {
let shortcuts = self.get_shortcuts(context);
let mut highlighted_attrs = crate::conf::value(context, "widgets.options.highlighted");
if !context.settings.terminal.use_color() {
highlighted_attrs.attrs |= Attr::Reverse;
highlighted_attrs.attrs |= Attr::REVERSE;
}
match (event, self.cursor) {
(UIEvent::Input(Key::Char('\n')), _) if self.single_only => {
@ -2476,7 +2476,7 @@ impl Component for UIConfirmationDialog {
&mut self.content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((3, c + 2), (width - 2, c + 2)),
None,
);
@ -2486,7 +2486,7 @@ impl Component for UIConfirmationDialog {
&mut self.content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((3, c + 2), (width - 2, c + 2)),
None,
);
@ -2528,7 +2528,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..(width - 2), c + 1) {
self.content[c]
@ -2544,7 +2544,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..4, c + 1) {
self.content[c]
@ -2568,14 +2568,14 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
let c = self.entries.len().saturating_sub(1);
self.cursor = SelectorCursor::Entry(c);
let mut highlighted_attrs =
crate::conf::value(context, "widgets.options.highlighted");
if !context.settings.terminal.use_color() {
highlighted_attrs.attrs |= Attr::Reverse;
highlighted_attrs.attrs |= Attr::REVERSE;
}
for c in self.content.row_iter(2..4, c + 2) {
self.content[c]
@ -2596,7 +2596,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..(width - 2), c + 3) {
self.content[c]
@ -2612,7 +2612,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(2..4, c + 3) {
self.content[c]
@ -2633,7 +2633,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(
((width - "OK Cancel".len()) / 2)..((width - "OK Cancel".len()) / 2 + 1),
@ -2658,7 +2658,7 @@ impl Component for UIConfirmationDialog {
self.content[c]
.set_fg(Color::Default)
.set_bg(Color::Default)
.set_attrs(Attr::Default);
.set_attrs(Attr::DEFAULT);
}
for c in self.content.row_iter(
((width - "OK Cancel".len()) / 2 + 6)
@ -2767,7 +2767,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((0, 0), (width - 1, 0)),
None,
);
@ -2776,7 +2776,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((2, 0), (width - 1, 0)),
None,
);
@ -2786,7 +2786,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((x + i, 0), (width - 1, 0)),
None,
);
@ -2796,7 +2796,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((width - 1, 0), (width - 1, 0)),
None,
);
@ -2805,7 +2805,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((0, height - 1), (width - 1, height - 1)),
None,
);
@ -2818,7 +2818,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((1, height - 1), (width - 2, height - 1)),
None,
);
@ -2827,7 +2827,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((width - 1, height - 1), (width - 1, height - 1)),
None,
);
@ -2837,7 +2837,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((0, i), (width - 1, i)),
None,
);
@ -2846,14 +2846,14 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Byte(8),
Color::Default,
Attr::Default,
Attr::DEFAULT,
((width - 1, i), (width - 1, i)),
None,
);
}
let mut highlighted_attrs = crate::conf::value(context, "widgets.options.highlighted");
if !context.settings.terminal.use_color() {
highlighted_attrs.attrs |= Attr::Reverse;
highlighted_attrs.attrs |= Attr::REVERSE;
}
if single_only {
for (i, e) in entries.iter().enumerate() {
@ -2869,7 +2869,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
if i == 0 {
highlighted_attrs.attrs
} else {
Attr::Default
Attr::DEFAULT
},
((2, i + 2), (width - 1, i + 2)),
None,
@ -2882,7 +2882,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Default,
Color::Default,
Attr::Default,
Attr::DEFAULT,
((2, i + 2), (width - 1, i + 2)),
None,
);
@ -2903,7 +2903,7 @@ impl<T: PartialEq + Debug + Clone + Sync + Send, F: 'static + Sync + Send> Selec
&mut content,
Color::Default,
Color::Default,
Attr::Bold,
Attr::BOLD,
(
((width - "OK Cancel".len()) / 2, height - 3),
(width - 1, height - 3),

12
src/components/utilities/widgets.rs

@ -439,7 +439,7 @@ impl Component for FormWidget {
let mut field_attrs =
crate::conf::value(context, "widgets.form.highlighted");
if !context.settings.terminal.use_color() {
field_attrs.attrs |= Attr::Reverse;
field_attrs.attrs |= Attr::REVERSE;
}
for row in grid.bounds_iter((
pos_inc(upper_left, (0, i)),
@ -670,7 +670,7 @@ where
} else {
theme_default.bg
},
Attr::Bold,
Attr::BOLD,
(
pos_inc(upper_left, (len, 0)),
pos_inc(upper_left, (cur_len + len, 0)),
@ -847,7 +847,7 @@ impl AutoComplete {
.unwrap_or(0)
+ 1,
entries.len(),
Cell::with_style(Color::Byte(23), Color::Byte(7), Attr::Default),
Cell::with_style(Color::Byte(23), Color::Byte(7), Attr::DEFAULT),
);
let width = content.cols();
for (i, e) in entries.iter().enumerate() {
@ -856,7 +856,7 @@ impl AutoComplete {
&mut content,
Color::Byte(23),
Color::Byte(7),
Attr::Default,
Attr::DEFAULT,
((0, i), (width - 1, i)),
None,
);
@ -865,7 +865,7 @@ impl AutoComplete {
&mut content,
Color::Byte(23),
Color::Byte(7),
Attr::Default,
Attr::DEFAULT,
((x + 2, i), (width - 1, i)),
None,
);
@ -874,7 +874,7 @@ impl AutoComplete {
&mut content,
Color::Byte(23),
Color::Byte(7),
Attr::Default,
Attr::DEFAULT,
((width - 1, i), (width - 1, i)),
None,
);

23
src/conf/themes.rs

@ -262,7 +262,7 @@ impl Default for ThemeValue<Color> {
impl Default for ThemeValue<Attr> {
fn default() -> Self {
ThemeValue::Value(Attr::Default)
ThemeValue::Value(Attr::DEFAULT)
}
}
@ -272,7 +272,7 @@ impl<'de> Deserialize<'de> for ThemeValue<Attr> {
D: Deserializer<'de>,
{
if let Ok(s) = <String>::deserialize(deserializer) {
if let Ok(c) = Attr::from_string_de::<'de, D>(s.clone()) {
if let Ok(c) = Attr::from_string_de::<'de, D, String>(s.clone()) {
Ok(ThemeValue::Value(c))
} else {
Ok(ThemeValue::Link(s.into()))
@ -473,7 +473,7 @@ impl Default for Theme {
dark.insert($key.into(), ThemeAttributeInner::default());
};
}
add!("theme_default", dark = { fg: Color::Default, bg: Color::Default, attrs: Attr::Default }, light = { fg: Color::Default, bg: Color::Default, attrs: Attr::Default });
add!("theme_default", dark = { fg: Color::Default, bg: Color::Default, attrs: Attr::DEFAULT }, light = { fg: Color::Default, bg: Color::Default, attrs: Attr::DEFAULT });
add!("status.bar", dark = { fg: Color::Byte(123), bg: Color::Byte(26) }, light = { fg: Color::Byte(123), bg: Color::Byte(26) });
add!("status.notification", dark = { fg: Color::Byte(219), bg: Color::Byte(88) }, light = { fg: Color::Byte(219), bg: Color::Byte(88) });
@ -482,13 +482,13 @@ impl Default for Theme {
add!("tab.bar");
add!(
"widgets.list.header",
dark = { fg: Color::Black, bg: Color::White, attrs: Attr::Bold },
light = {fg: Color::White, bg: Color::Black, attrs: Attr::Bold }
dark = { fg: Color::Black, bg: Color::White, attrs: Attr::BOLD },
light = {fg: Color::White, bg: Color::Black, attrs: Attr::BOLD }
);
add!(
"widgets.form.label",
dark = { attrs: Attr::Bold },
light = { attrs: Attr::Bold }
dark = { attrs: Attr::BOLD },
light = { attrs: Attr::BOLD }
);
add!("widgets.form.field");
add!("widgets.form.highlighted", light = { bg: Color::Byte(246) }, dark = { bg: Color::Byte(246) });
@ -567,7 +567,6 @@ impl Default for Theme {
dark = {
fg: Color::Byte(0),
bg: Color::Byte(251)
},
light = {
fg: Color::Byte(0),
@ -725,17 +724,17 @@ impl Default for Theme {
light = {
fg: Color::White,
bg: Color::Byte(8),
attrs: Attr::Bold
attrs: Attr::BOLD
},
dark = {
fg: Color::White,
bg: Color::Byte(8),
attrs: Attr::Bold
attrs: Attr::BOLD
}
);
add!("pager.highlight_search", light = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::Bold }, dark = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::Bold });
add!("pager.highlight_search_current", light = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::Bold }, dark = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::Bold });
add!("pager.highlight_search", light = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(6) /* Teal */, attrs: Attr::BOLD });
add!("pager.highlight_search_current", light = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD }, dark = { fg: Color::White, bg: Color::Byte(17) /* NavyBlue */, attrs: Attr::BOLD });
Theme {
light,
dark,

4
src/state.rs

@ -695,7 +695,7 @@ impl State {
.unwrap();
let mut current_fg = Color::Default;
let mut current_bg = Color::Default;
let mut current_attrs = Attr::Default;
let mut current_attrs = Attr::DEFAULT;
write!(stdout, "\x1B[m").unwrap();