Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ list_hash_fg = "yellow"
list_date_fg = "magenta"
list_match_fg = "black"
list_match_bg = "yellow"
detail_label_fg = "reset"
detail_name_fg = "reset"
detail_date_fg = "reset"
detail_email_fg = "blue"
detail_hash_fg = "reset"
detail_ref_branch_fg = "green"
detail_ref_remote_branch_fg = "red"
detail_ref_tag_fg = "yellow"
Expand Down
22 changes: 21 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,31 @@
"description": "Background color for a search match in the commit list.",
"default": "yellow"
},
"detail_label_fg": {
"type": "string",
"description": "Color for labels in the commit detail view.",
"default": "reset"
},
"detail_name_fg": {
"type": "string",
"description": "Color for author/committer names in the commit detail view.",
"default": "reset"
},
"detail_date_fg": {
"type": "string",
"description": "Color for author/committer dates in the commit detail view.",
"default": "reset"
},
"detail_email_fg": {
"type": "string",
"description": "Color for email addresses in the commit detail view.",
"description": "Color for author/committer email addresses in the commit detail view.",
"default": "blue"
},
"detail_hash_fg": {
"type": "string",
"description": "Color for the commit hash in the commit detail view.",
"default": "reset"
},
"detail_ref_branch_fg": {
"type": "string",
"description": "Color for local branches in the commit detail view.",
Expand Down
8 changes: 8 additions & 0 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ pub struct ColorTheme {
#[default(RatatuiColor::Yellow)]
pub list_match_bg: RatatuiColor,

#[default(RatatuiColor::Reset)]
pub detail_label_fg: RatatuiColor,
#[default(RatatuiColor::Reset)]
pub detail_name_fg: RatatuiColor,
#[default(RatatuiColor::Reset)]
pub detail_date_fg: RatatuiColor,
#[default(RatatuiColor::Blue)]
pub detail_email_fg: RatatuiColor,
#[default(RatatuiColor::Reset)]
pub detail_hash_fg: RatatuiColor,
#[default(RatatuiColor::Green)]
pub detail_ref_branch_fg: RatatuiColor,
#[default(RatatuiColor::Red)]
Expand Down
23 changes: 14 additions & 9 deletions src/widget/commit_detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,26 @@ impl CommitDetail<'_> {
let mut label_lines: Vec<Line> = Vec::new();
let mut value_lines: Vec<Line> = Vec::new();

label_lines.push(Line::raw(" Author: "));
label_lines.push(Line::from(" Author: ").fg(self.color_theme.detail_label_fg));
label_lines.push(self.empty_line());
value_lines.extend(self.author_lines());

if is_author_committer_different(self.commit) {
label_lines.push(Line::raw("Committer: "));
label_lines.push(Line::from("Committer: ").fg(self.color_theme.detail_label_fg));
label_lines.push(self.empty_line());
value_lines.extend(self.committer_lines());
}

label_lines.push(Line::raw(" SHA: "));
label_lines.push(Line::from(" SHA: ").fg(self.color_theme.detail_label_fg));
value_lines.push(self.sha_line());

if has_parent(self.commit) {
label_lines.push(Line::raw(" Parents: "));
label_lines.push(Line::from(" Parents: ").fg(self.color_theme.detail_label_fg));
value_lines.push(self.parents_line());
}

if has_refs(self.refs) {
label_lines.push(Line::raw(" Refs: "));
label_lines.push(Line::from(" Refs: ").fg(self.color_theme.detail_label_fg));
value_lines.push(self.refs_line());
}

Expand Down Expand Up @@ -190,25 +190,30 @@ impl CommitDetail<'_> {
};
vec![
Line::from(vec![
name.into(),
name.fg(self.color_theme.detail_name_fg),
" <".into(),
email.fg(self.color_theme.detail_email_fg),
"> ".into(),
]),
Line::raw(date_str),
Line::from(date_str.fg(self.color_theme.detail_date_fg)),
]
}

fn sha_line(&self) -> Line<'_> {
Line::raw(self.commit.commit_hash.as_str())
Line::from(
self.commit
.commit_hash
.as_str()
.fg(self.color_theme.detail_hash_fg),
)
}

fn parents_line(&self) -> Line<'_> {
let mut spans = Vec::new();
let parents = &self.commit.parent_commit_hashes;
for (i, hash) in parents
.iter()
.map(|hash| Span::raw(hash.as_short_hash()))
.map(|hash| hash.as_short_hash().fg(self.color_theme.detail_hash_fg))
.enumerate()
{
spans.push(hash);
Expand Down