summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authormjarkk <mkopenga@gmail.com>2021-07-27 15:00:37 +0200
committermjarkk <mkopenga@gmail.com>2021-07-30 15:14:46 +0200
commit79848087bccd5c87af1dbb44a39753aad1346f8b (patch)
tree07e4b6eb4b7ed5fdcbde8d697a214b647ddd0536 /pkg
parenta3b820fb5f20f4a24028ecbf285d54bbaa7b6974 (diff)
Switch to github.com/gookit/color for terminal colors
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/loading_commits.go5
-rw-r--r--pkg/commands/patch/patch_parser.go37
-rw-r--r--pkg/gui/branches_panel.go2
-rw-r--r--pkg/gui/command_log_panel.go15
-rw-r--r--pkg/gui/confirmation_panel.go5
-rw-r--r--pkg/gui/custom_commands.go4
-rw-r--r--pkg/gui/gui.go6
-rw-r--r--pkg/gui/information_panel.go6
-rw-r--r--pkg/gui/list_context_config.go5
-rw-r--r--pkg/gui/mergeconflicts/rendering.go13
-rw-r--r--pkg/gui/modes.go37
-rw-r--r--pkg/gui/options_menu_panel.go9
-rw-r--r--pkg/gui/presentation/branches.go31
-rw-r--r--pkg/gui/presentation/commit_files.go31
-rw-r--r--pkg/gui/presentation/commits.go104
-rw-r--r--pkg/gui/presentation/files.go23
-rw-r--r--pkg/gui/presentation/reflog_commits.go16
-rw-r--r--pkg/gui/presentation/remote_branches.go5
-rw-r--r--pkg/gui/presentation/remotes.go7
-rw-r--r--pkg/gui/presentation/stash_entries.go3
-rw-r--r--pkg/gui/presentation/submodules.go3
-rw-r--r--pkg/gui/presentation/tags.go3
-rw-r--r--pkg/gui/recent_repos_panel.go6
-rw-r--r--pkg/gui/remotes_panel.go4
-rw-r--r--pkg/gui/reset_menu_panel.go6
-rw-r--r--pkg/gui/searching.go19
-rw-r--r--pkg/gui/status_panel.go10
-rw-r--r--pkg/gui/style/basic.go147
-rw-r--r--pkg/gui/style/rgb.go111
-rw-r--r--pkg/gui/style/style.go97
-rw-r--r--pkg/gui/style/style_test.go314
-rw-r--r--pkg/gui/submodules_panel.go17
-rw-r--r--pkg/gui/workspace_reset_options_panel.go4
-rw-r--r--pkg/theme/theme.go137
-rw-r--r--pkg/utils/color.go37
-rw-r--r--pkg/utils/color_test.go (renamed from pkg/theme/theme_test.go)4
36 files changed, 903 insertions, 380 deletions
diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go
index bf7e4cf56..28e9c5199 100644
--- a/pkg/commands/loading_commits.go
+++ b/pkg/commands/loading_commits.go
@@ -10,9 +10,9 @@ import (
"strconv"
"strings"
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/sirupsen/logrus"
)
@@ -165,8 +165,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit
if rebaseMode != "" {
currentCommit := commits[len(rebasingCommits)]
- blue := color.New(color.FgYellow)
- youAreHere := blue.Sprintf("<-- %s ---", c.Tr.YouAreHere)
+ youAreHere := style.FgYellow.Sprintf("<-- %s ---", c.Tr.YouAreHere)
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
}
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index a5a94964f..66e100ece 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -4,7 +4,7 @@ import (
"regexp"
"strings"
- "github.com/fatih/color"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/sirupsen/logrus"
@@ -95,45 +95,38 @@ func (l *PatchLine) render(selected bool, included bool) string {
if l.Kind == HUNK_HEADER {
re := regexp.MustCompile("(@@.*?@@)(.*)")
match := re.FindStringSubmatch(content)
- return coloredString(color.FgCyan, match[1], selected, included) + coloredString(theme.DefaultTextColor, match[2], selected, false)
+ return coloredString(style.FgCyan, match[1], selected, included) + coloredString(theme.DefaultTextColor, match[2], selected, false)
}
- var colorAttr color.Attribute
+ colorAttr := theme.DefaultTextColor
switch l.Kind {
case PATCH_HEADER:
- colorAttr = color.Bold
+ colorAttr = colorAttr.SetBold(true)
case ADDITION:
- colorAttr = color.FgGreen
+ colorAttr = colorAttr.SetColor(style.FgGreen)
case DELETION:
- colorAttr = color.FgRed
+ colorAttr = colorAttr.SetColor(style.FgRed)
case COMMIT_SHA:
- colorAttr = color.FgYellow
- default:
- colorAttr = theme.DefaultTextColor
+ colorAttr = colorAttr.SetColor(style.FgYellow)
}
return coloredString(colorAttr, content, selected, included)
}
-func coloredString(colorAttr color.Attribute, str string, selected bool, included bool) string {
- var cl *color.Color
- attributes := []color.Attribute{colorAttr}
+func coloredString(colorAttr style.TextStyle, str string, selected bool, included bool) string {
if selected {
- attributes = append(attributes, theme.SelectedRangeBgColor)
- }
- cl = color.New(attributes...)
- var clIncluded *color.Color
- if included {
- clIncluded = color.New(append(attributes, color.BgGreen)...)
- } else {
- clIncluded = color.New(attributes...)
+ colorAttr = colorAttr.SetColor(theme.SelectedRangeBgColor)
}
if len(str) < 2 {
- return utils.ColoredStringDirect(str, clIncluded)
+ return colorAttr.Sprint(str)
}
- return utils.ColoredStringDirect(str[:1], clIncluded) + utils.ColoredStringDirect(str[1:], cl)
+ res := colorAttr.Sprint(str[:1])
+ if included {
+ return res + colorAttr.SetColor(style.BgGreen).Sprint(str[1:])
+ }
+ return res + colorAttr.Sprint(str[1:])
}
func parsePatch(patch string) ([]int, []int, []*PatchLine) {
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 9e44a8a8c..0c5a2d7d2 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -554,7 +554,7 @@ func (gui *Gui) findBranchNameSuggestions(input string) []*types.Suggestion {
for i, branchName := range matchingBranchNames {
suggestions[i] = &types.Suggestion{
Value: branchName,
- Label: utils.ColoredString(branchName, presentation.GetBranchColor(branchName)),
+ Label: presentation.GetBranchColor(branchName).Sprint(branchName),
}
}
diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go
index 5cd632c17..6561f64cc 100644
--- a/pkg/gui/command_log_panel.go
+++ b/pkg/gui/command_log_panel.go
@@ -6,11 +6,10 @@ import (
"strings"
"time"
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/constants"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
@@ -25,17 +24,17 @@ func (gui *Gui) GetOnRunCommand() func(entry oscommands.CmdLogEntry) {
gui.Views.Extras.Autoscroll = true
if entry.GetSpan() != currentSpan {
- fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(entry.GetSpan(), color.FgYellow))
+ fmt.Fprint(gui.Views.Extras, "\n"+style.FgYellow.Sprint(entry.GetSpan()))
currentSpan = entry.GetSpan()
}
clrAttr := theme.DefaultTextColor
if !entry.GetCommandLine() {
- clrAttr = color.FgMagenta
+ clrAttr = clrAttr.SetColor(style.FgMagenta)
}
gui.CmdLog = append(gui.CmdLog, entry.GetCmdStr())
indentedCmdStr := " " + strings.Replace(entry.GetCmdStr(), "\n", "\n ", -1)
- fmt.Fprint(gui.Views.Extras, "\n"+utils.ColoredString(indentedCmdStr, clrAttr))
+ fmt.Fprint(gui.Views.Extras, "\n"+clrAttr.Sprint(indentedCmdStr))
}
}
@@ -44,14 +43,14 @@ func (gui *Gui) printCommandLogHeader() {
gui.Tr.CommandLogHeader,
gui.getKeyDisplay(gui.Config.GetUserConfig().Keybinding.Universal.ExtrasMenu),
)
- fmt.Fprintln(gui.Views.Extras, utils.ColoredString(introStr, color.FgCyan))
+ fmt.Fprintln(gui.Views.Extras, style.FgCyan.Sprint(introStr))
if gui.Config.GetUserConfig().Gui.ShowRandomTip {
fmt.Fprintf(
gui.Views.Extras,
"%s: %s",
- utils.ColoredString(gui.Tr.RandomTip, color.FgYellow),
- utils.ColoredString(gui.getRandomTip(), color.FgGreen),
+ style.FgYellow.Sprint(gui.Tr.RandomTip),
+ style.FgGreen.Sprint(gui.getRandomTip()),
)
}
}
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index f04cd43b3..edcde8821 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -9,8 +9,8 @@ package gui
import (
"strings"
- "github.com/fatih/color"
"github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
@@ -316,8 +316,7 @@ func (gui *Gui) wrappedHandler(f func() error) func(g *gocui.Gui, v *gocui.View)
}
func (gui *Gui) createErrorPanel(message string) error {
- colorFunction := color.New(color.FgRed).SprintFunc()
- coloredMessage := colorFunction(strings.TrimSpace(message))
+ coloredMessage := style.FgRed.Sprint(strings.TrimSpace(message))
if err := gui.refreshSidePanels(refreshOptions{mode: ASYNC}); err != nil {
return err
}
diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go
index 752587e69..2fb17049f 100644
--- a/pkg/gui/custom_commands.go
+++ b/pkg/gui/custom_commands.go
@@ -9,10 +9,10 @@ import (
"strings"
"text/template"
- "github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/config"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -102,7 +102,7 @@ func (gui *Gui) menuPrompt(prompt config.CustomCommandPrompt, promptResponses []
}
menuItems[i] = &menuItem{
- displayStrings: []string{name, utils.ColoredString(description, color.FgYellow)},
+ displayStrings: []string{name, style.FgYellow.Sprint(description)},
onPress: func() error {
promptResponses[responseIdx] = value
return wrappedF()
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 71b9702f2..975f0ad9e 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -12,7 +12,6 @@ import (
"strings"
"time"
- "github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
@@ -24,6 +23,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/gui/modes/cherrypicking"
"github.com/jesseduffield/lazygit/pkg/gui/modes/diffing"
"github.com/jesseduffield/lazygit/pkg/gui/modes/filtering"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/tasks"
@@ -611,7 +611,7 @@ func (gui *Gui) runSubprocess(subprocess *exec.Cmd) error {
subprocess.Stderr = os.Stdout
subprocess.Stdin = os.Stdin
- fmt.Fprintf(os.Stdout, "\n%s\n\n", utils.ColoredString("+ "+strings.Join(subprocess.Args, " "), color.FgBlue))
+ fmt.Fprintf(os.Stdout, "\n%s\n\n", style.FgBlue.Sprint("+ "+strings.Join(subprocess.Args, " ")))
if err := subprocess.Run(); err != nil {
// not handling the error explicitly because usually we're going to see it
@@ -623,7 +623,7 @@ func (gui *Gui) runSubprocess(subprocess *exec.Cmd) error {
subprocess.Stderr = ioutil.Discard
subprocess.Stdin = nil
- fmt.Fprintf(os.Stdout, "\n%s", utils.ColoredString(gui.Tr.PressEnterToReturn, color.FgGreen))
+ fmt.Fprintf(os.Stdout, "\n%s", style.FgGreen.Sprint(gui.Tr.PressEnterToReturn))
fmt.Scanln() // wait for enter press
return nil
diff --git a/pkg/gui/information_panel.go b/pkg/gui/information_panel.go
index ac46cdaf1..a58d2ddfb 100644
--- a/pkg/gui/information_panel.go
+++ b/pkg/gui/information_panel.go
@@ -3,8 +3,8 @@ package gui
import (
"fmt"
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/constants"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
)
func (gui *Gui) informationStr() string {
@@ -15,8 +15,8 @@ func (gui *Gui) informationStr() string {
}
if gui.g.Mouse {
- donate := color.New(color.FgMagenta, color.Underline).Sprint(gui.Tr.Donate)
- askQuestion := color.New(color.FgYellow, color.Underline).Sprint(gui.Tr.AskQuestion)
+ donate := style.FgMagenta.SetUnderline(true).Sprint(gui.Tr.Donate)
+ askQuestion := style.FgYellow.SetUnderline(true).Sprint(gui.Tr.AskQuestion)
return fmt.Sprintf("%s %s %s", donate, askQuestion, gui.Config.GetVersion())
} else {
return gui.Config.GetVersion()
diff --git a/pkg/gui/list_context_config.go b/pkg/gui/list_context_config.go
index 6e9563069..dab3c35e7 100644
--- a/pkg/gui/list_context_config.go
+++ b/pkg/gui/list_context_config.go
@@ -1,10 +1,9 @@
package gui
import (
- "github.com/fatih/color"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
- "github.com/jesseduffield/lazygit/pkg/utils"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
)
func (gui *Gui) menuListContext() *ListContext {
@@ -278,7 +277,7 @@ func (gui *Gui) commitFilesListContext() *ListContext {
ResetMainViewOriginOnFocus: true,
GetDisplayStrings: func() [][]string {
if gui.State.CommitFileManager.GetItemsLength() == 0 {
- return [][]string{{utils.ColoredString("(none)", color.FgRed)}}
+ return [][]string{{style.FgRed.Sprint("(none)")}}
}
lines := gui.State.CommitFileManager.Render(gui.State.Modes.Diffing.Ref, gui.GitCommand.PatchManager)
diff --git a/pkg/gui/mergeconflicts/rendering.go b/pkg/gui/mergeconflicts/rendering.go
index 5de6eda93..84708928f 100644
--- a/pkg/gui/mergeconflicts/rendering.go
+++ b/pkg/gui/mergeconflicts/rendering.go
@@ -3,7 +3,7 @@ package mergeconflicts
import (
"bytes"
- "github.com/fatih/color"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -15,19 +15,18 @@ func ColoredConflictFile(content string, state *State, hasFocus bool) string {
conflict, remainingConflicts := shiftConflict(state.conflicts)
var outputBuffer bytes.Buffer
for i, line := range utils.SplitLines(content) {
- colourAttr := theme.DefaultTextColor
+ colour := theme.DefaultTextColor
if i == conflict.start || i == conflict.middle || i == conflict.end {
- colourAttr = color.FgRed
+ colour.SetColor(style.FgRed)
}
- colour := color.New(colourAttr)
+
if hasFocus && state.conflictIndex < len(state.conflicts) && *state.conflicts[state.conflictIndex] == *conflict && shouldHighlightLine(i, conflict, state.conflictTop) {
- colour.Add(color.Bold)
- colour.Add(theme.SelectedRangeBgColor)
+ colour = theme.SelectedRangeBgColor.SetBold(true)
}
if i == conflict.end && len(remainingConflicts) > 0 {
conflict, remainingConflicts = shiftConflict(remainingConflicts)
}
- outputBuffer.WriteString(utils.ColoredStringDirect(line, colour) + "\n")
+ outputBuffer.WriteString(colour.Sprint(line) + "\n")
}
return outputBuffer.String()
}
diff --git a/pkg/gui/modes.go b/pkg/gui/modes.go
index f97e050cf..36843e998 100644
--- a/pkg/gui/modes.go
+++ b/pkg/gui/modes.go
@@ -1,10 +1,7 @@
package gui
import (
- "fmt"
-
- "github.com/fatih/color"
- "github.com/jesseduffield/lazygit/pkg/utils"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
)
type modeStatus struct {
@@ -18,9 +15,11 @@ func (gui *Gui) modeStatuses() []modeStatus {
{
isActive: gui.State.Modes.Diffing.Active,
description: func() string {
- return utils.ColoredString(
- fmt.Sprintf("%s %s %s", gui.Tr.LcShowingGitDiff, "git diff "+gui.diffStr(), utils.ColoredString(gui.Tr.ResetInParentheses, color.Underline)),
- color.FgMagenta,
+ return style.FgMagenta.Sprintf(
+ "%s %s %s",
+ gui.Tr.LcShowingGitDiff,
+ "git diff "+gui.diffStr(),
+ style.AttrUnderline.Sprint(gui.Tr.ResetInParentheses),
)
},
reset: gui.exitDiffMode,
@@ -28,10 +27,10 @@ func (gui *Gui) modeStatuses() []modeStatus {
{
isActive: gui.GitCommand.PatchManager.Active,
description: func() string {
- return utils.ColoredString(
- fmt.Sprintf("%s %s", gui.Tr.LcBuildingPatch, utils.ColoredString(gui.Tr.ResetInParentheses, color.Underline)),
- color.FgYellow,
- color.Bold,
+ return style.FgYellow.SetBold(true).Sprintf(
+ "%s %s",
+ gui.Tr.LcBuildingPatch,
+ style.AttrUnderline.Sprint(gui.Tr.ResetInParentheses),
)
},
reset: gui.handleResetPatch,
@@ -39,10 +38,11 @@ func (gui *Gui) modeStatuses() []modeStatus {
{
isActive: gui.State.Modes.Filtering.Active,
description: func() string {
- return utils.ColoredString(
- fmt.Sprintf("%s '%s' %s", gui.Tr.LcFilteringBy, gui.State.Modes.Filtering.GetPath(), utils.ColoredString(gui.Tr.ResetInParentheses, color.Underline)),
- color.FgRed,
- color.Bold,
+ return style.FgRed.SetBold(true).Sprintf(
+ "%s '%s' %s",
+ gui.Tr.LcFilteringBy,
+ gui.State.Modes.Filtering.GetPath(),
+ style.AttrUnderline.Sprint(gui.Tr.ResetInParentheses),
)
},
reset: gui.exitFilterMode,
@@ -50,9 +50,10 @@ func (gui *Gui) modeStatuses() []modeStatus {
{
isActive: gui.State.Modes.CherryPicking.Active,
description: func() string {
- return utils.ColoredString(
- fmt.Sprintf("%d commits copied %s", len(gui.State.Modes.CherryPicking.CherryPickedCommits), utils.ColoredString(gui.Tr.ResetInParentheses, color.Underline)),
- color.FgCyan,
+ return style.FgCyan.Sprintf(
+ "%d commits copied %s",
+ len(gui.State.Modes.CherryPicking.CherryPickedCommits),
+ style.AttrUnderline.Sprint(gui.Tr.ResetInParentheses),
)
},
reset: gui.exitCherryPickingMode,
diff --git a/pkg/gui/options_menu_panel.go b/pkg/gui/options_menu_panel.go
index 71e0e6685..172dd83c3 100644
--- a/pkg/gui/options_menu_panel.go
+++ b/pkg/gui/options_menu_panel.go
@@ -3,8 +3,8 @@ package gui
import (
"strings"
- "github.com/fatih/color"
"github.com/jesseduffield/gocui"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -35,14 +35,11 @@ func (gui *Gui) getBindings(v *gocui.View) []*Binding {
}
func (gui *Gui) displayDescription(binding *Binding) string {
- commandColor := color.New(color.FgCyan)
- menuColor := color.New(color.FgMagenta)
-
if binding.OpensMenu {
- return menuColor.Sprintf("%s...", binding.Description)
+ return style.FgMagenta.Sprintf("%s...", binding.Description)
}
- return commandColor.Sprint(binding.Description)
+ return style.FgCyan.Sprint(binding.Description)
}
func (gui *Gui) handleCreateOptionsMenu() error {
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index 3e51e3d66..548bd143c 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -4,10 +4,9 @@ import (
"fmt"
"strings"
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
- "github.com/jesseduffield/lazygit/pkg/utils"
)
func GetBranchListDisplayStrings(branches []*models.Branch, fullDescription bool, diffName string) [][]string {
@@ -32,48 +31,48 @@ func getBranchDisplayStrings(b *models.Branch, fullDescription bool, diffed bool
if diffed {
nameColorAttr = theme.DiffTerminalColor
}
- coloredName := utils.ColoredString(displayName, nameColorAttr)
+ coloredName := nameColorAttr.Sprint(displayName)
if b.IsTrackingRemote() {
coloredName = fmt.Sprintf("%s %s", coloredName, ColoredBranchStatus(b))
}
- recencyColor := color.FgCyan
+ recencyColor := style.FgCyan
if b.Recency == " *" {
- recencyColor = color.FgGreen
+ recencyColor = style.FgGreen
}
+ res := []string{recencyColor.Sprint(b.Recency), coloredName}
if fullDescription {
- return []string{utils.ColoredString(b.Recency, recencyColor), coloredName, utils.ColoredString(b.UpstreamName, color.FgYellow)}
+ return append(res, style.FgYellow.Sprint(b.UpstreamName))
}
-
- return []string{utils.ColoredString(b.Recency, recencyColor), coloredName}
+ return res
}
// GetBranchColor branch color
-func GetBranchColor(name string) color.Attribute {
+func GetBranchColor(name string) style.TextStyle {
branchType := strings.Split(name, "/")[0]
switch branchType {
case "feature":
- return color.FgGreen
+ return style.FgGreen
case "bugfix":
- return color.FgYellow
+ return style.FgYellow
case "hotfix":
- return color.FgRed
+ return style.FgRed
default:
return theme.DefaultTextColor
}
}
func ColoredBranchStatus(branch *models.Branch) string {
- colour := color.FgYellow
+ colour := style.FgYellow
if branch.MatchesUpstream() {
- colour = color.FgGreen
+ colour = style.FgGreen
} else if !branch.IsTrackingRemote() {
- colour = color.FgRed
+ colour = style.FgRed
}
- return utils.ColoredString(BranchStatus(branch), colour)
+ return colour.Sprint(BranchStatus(branch))
}
func BranchStatus(branch *models.Branch) string {
diff --git a/pkg/gui/presentation/commit_files.go b/pkg/gui/presentation/commit_files.go
index 7e9d4bdfa..3b68b9eeb 100644
--- a/pkg/gui/presentation/commit_files.go
+++ b/pkg/gui/presentation/commit_files.go
@@ -1,30 +1,23 @@
package presentation
import (
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, status patch.PatchStatus) string {
- yellow := color.New(color.FgYellow)
- green := color.New(color.FgGreen)
- defaultColor := color.New(theme.DefaultTextColor)
- diffTerminalColor := color.New(theme.DiffTerminalColor)
-
- colour := defaultColor
+ colour := theme.DefaultTextColor
if diffName == name {
- colour = diffTerminalColor
+ colour = theme.DiffTerminalColor
} else {
switch status {
- case patch.UNSELECTED:
- colour = defaultColor
case patch.WHOLE:
- colour = green
+ colour = style.FgGreen
case patch.PART:
- colour = yellow
+ colour = style.FgYellow
}
}
@@ -33,21 +26,21 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi
return colour.Sprint(name)
}
- return utils.ColoredString(commitFile.ChangeStatus, getColorForChangeStatus(commitFile.ChangeStatus)) + " " + colour.Sprint(name)
+ return getColorForChangeStatus(commitFile.ChangeStatus).Sprint(commitFile.ChangeStatus) + " " + colour.Sprint(name)
}
-func getColorForChangeStatus(changeStatus string) color.Attribute {
+func getColorForChangeStatus(changeStatus string) style.TextStyle {
switch changeStatus {
case "A":
- return color.FgGreen
+ return style.FgGreen
case "M", "R":
- return color.FgYellow
+ return style.FgYellow
case "D":
- return color.FgRed
+ return style.FgRed
case "C":
- return color.FgCyan
+ return style.FgCyan
case "T":
- return color.FgMagenta
+ return style.FgMagenta
default:
return theme.DefaultTextColor
}
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go
index a3fcdb834..b9b9a622e 100644
--- a/pkg/gui/presentation/commits.go
+++ b/pkg/gui/presentation/commits.go
@@ -3,8 +3,8 @@ package presentation
import (
"strings"
- "github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/kyokomi/emoji/v2"
@@ -29,47 +29,35 @@ func GetCommitListDisplayStrings(commits []*mode