diff hunk marker returns

revert to old style
renames
some more style adjustments to the old
This commit is contained in:
Stephan Dilly 2020-05-19 23:30:58 +02:00
parent 1c03458de7
commit 0d1e709abf
3 changed files with 32 additions and 31 deletions

View file

@ -13,7 +13,6 @@ use strings::commands;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Alignment, Rect}, layout::{Alignment, Rect},
style::Modifier,
symbols, symbols,
widgets::{Block, Borders, Paragraph, Text}, widgets::{Block, Borders, Paragraph, Text},
Frame, Frame,
@ -198,7 +197,7 @@ impl DiffComponent {
theme: Theme, theme: Theme,
) { ) {
{ {
let style = theme.text(false, selected || selected_hunk); let style = theme.diff_hunk_marker(selected_hunk);
if end_of_hunk { if end_of_hunk {
text.push(Text::Styled( text.push(Text::Styled(
@ -283,11 +282,7 @@ impl DrawableComponent for DiffComponent {
.title(title.as_str()) .title(title.as_str())
.borders(Borders::ALL) .borders(Borders::ALL)
.border_style(self.theme.block(self.focused)) .border_style(self.theme.block(self.focused))
.title_style( .title_style(self.theme.title(self.focused)),
self.theme
.text(self.focused, false)
.modifier(Modifier::BOLD),
),
) )
.alignment(Alignment::Left), .alignment(Alignment::Left),
r, r,

View file

@ -5,7 +5,6 @@ use scrolllist::ScrollableList;
use tui::{ use tui::{
backend::Backend, backend::Backend,
layout::{Constraint, Direction, Layout, Rect}, layout::{Constraint, Direction, Layout, Rect},
style::Modifier,
widgets::{Block, Borders, Text}, widgets::{Block, Borders, Text},
Frame, Frame,
}; };
@ -81,18 +80,12 @@ pub fn draw_list<'b, B: Backend, L>(
) where ) where
L: Iterator<Item = Text<'b>>, L: Iterator<Item = Text<'b>>,
{ {
let style = if selected {
theme.block(selected).modifier(Modifier::BOLD)
} else {
theme.block(selected)
};
let list = ScrollableList::new(items) let list = ScrollableList::new(items)
.block( .block(
Block::default() Block::default()
.title(title) .title(title)
.borders(Borders::ALL) .borders(Borders::ALL)
.title_style(style) .title_style(theme.title(selected))
.border_style(theme.block(selected)), .border_style(theme.block(selected)),
) )
.scroll(select.unwrap_or_default()); .scroll(select.unwrap_or_default());

View file

@ -17,11 +17,11 @@ pub struct Theme {
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
selected_tab: Color, selected_tab: Color,
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
command_foreground: Color, command_fg: Color,
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
command_background: Color, selection_bg: Color,
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
command_disabled: Color, disabled_fg: Color,
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
diff_line_add: Color, diff_line_add: Color,
#[serde(with = "ColorDef")] #[serde(with = "ColorDef")]
@ -47,7 +47,15 @@ impl Theme {
if focus { if focus {
Style::default() Style::default()
} else { } else {
Style::default().fg(self.command_disabled) Style::default().fg(self.disabled_fg)
}
}
pub fn title(&self, focused: bool) -> Style {
if focused {
Style::default().modifier(Modifier::BOLD)
} else {
Style::default().fg(self.disabled_fg)
} }
} }
@ -61,11 +69,9 @@ impl Theme {
pub fn text(&self, enabled: bool, selected: bool) -> Style { pub fn text(&self, enabled: bool, selected: bool) -> Style {
match (enabled, selected) { match (enabled, selected) {
(false, _) => Style::default().fg(self.command_disabled), (false, _) => Style::default().fg(self.disabled_fg),
(true, false) => Style::default(), (true, false) => Style::default(),
(true, true) => { (true, true) => Style::default().bg(self.selection_bg),
Style::default().bg(self.command_background)
}
} }
} }
@ -91,12 +97,19 @@ impl Theme {
fn apply_select(&self, style: Style, selected: bool) -> Style { fn apply_select(&self, style: Style, selected: bool) -> Style {
if selected { if selected {
style.bg(self.command_background) style.bg(self.selection_bg)
} else { } else {
style style
} }
} }
pub fn diff_hunk_marker(&self, selected: bool) -> Style {
match selected {
false => Style::default().fg(self.disabled_fg),
true => Style::default().bg(self.selection_bg),
}
}
pub fn diff_line( pub fn diff_line(
&self, &self,
typ: DiffLineType, typ: DiffLineType,
@ -124,11 +137,11 @@ impl Theme {
pub fn toolbar(&self, enabled: bool) -> Style { pub fn toolbar(&self, enabled: bool) -> Style {
if enabled { if enabled {
Style::default().fg(self.command_foreground) Style::default().fg(self.command_fg)
} else { } else {
Style::default().fg(self.command_disabled) Style::default().fg(self.disabled_fg)
} }
.bg(self.command_background) .bg(self.selection_bg)
} }
pub fn commit_hash(&self, selected: bool) -> Style { pub fn commit_hash(&self, selected: bool) -> Style {
@ -195,15 +208,15 @@ impl Default for Theme {
fn default() -> Self { fn default() -> Self {
Self { Self {
selected_tab: Color::Yellow, selected_tab: Color::Yellow,
command_foreground: Color::White, command_fg: Color::White,
command_background: Color::Rgb(0, 0, 100), selection_bg: Color::Rgb(0, 0, 100),
command_disabled: Color::DarkGray, disabled_fg: Color::DarkGray,
diff_line_add: Color::Green, diff_line_add: Color::Green,
diff_line_delete: Color::Red, diff_line_delete: Color::Red,
diff_file_added: Color::LightGreen, diff_file_added: Color::LightGreen,
diff_file_removed: Color::LightRed, diff_file_removed: Color::LightRed,
diff_file_moved: Color::LightMagenta, diff_file_moved: Color::LightMagenta,
diff_file_modified: Color::Yellow, diff_file_modified: Color::LightYellow,
commit_hash: Color::Magenta, commit_hash: Color::Magenta,
commit_time: Color::Blue, commit_time: Color::Blue,
commit_author: Color::Green, commit_author: Color::Green,