Skip to content

Commit

Permalink
add coloring in diff
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshihideShirai committed Apr 3, 2022
1 parent 3e9fd27 commit faf5e24
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tui/tui_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ func (t *Tui) NewTuiDiff(repos string, path string, rev string) {
main := tview.NewTable().SetSelectable(true, false)

for i, v := range strings.Split(diff_output, "\n") {
color := "white"
if strings.HasPrefix(v, "+") {
color = "green"
} else if strings.HasPrefix(v, "-") {
color = "red"
} else if strings.HasPrefix(v, "@") {
color = "purple"
}
output := fmt.Sprintf("[%s]%s[white]", color, tview.Escape(v))
main.SetCell(i, 0,
tview.NewTableCell(tview.Escape(v)).SetExpansion(1))
tview.NewTableCell(output).SetExpansion(1))
}

s.prim.
Expand Down

0 comments on commit faf5e24

Please sign in to comment.