summaryrefslogtreecommitdiffstats
path: root/pkg/gui/presentation
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-29 14:34:17 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-29 18:26:24 +1100
commit40fbce91ce636eb037c2221946261ce4f4bf4317 (patch)
tree9c31eb84b24e6e742ef519a4dad89218cca8092e /pkg/gui/presentation
parent33d287d2f0c6335559ac75c1b9a4705dfaa9ad7b (diff)
add new diff mode
WIP WIP WIP WIP WIP WIP WIP
Diffstat (limited to 'pkg/gui/presentation')
-rw-r--r--pkg/gui/presentation/branches.go14
-rw-r--r--pkg/gui/presentation/commit_files.go15
-rw-r--r--pkg/gui/presentation/commits.go35
-rw-r--r--pkg/gui/presentation/files.go20
-rw-r--r--pkg/gui/presentation/reflog_commits.go18
-rw-r--r--pkg/gui/presentation/remote_branches.go15
-rw-r--r--pkg/gui/presentation/remotes.go15
-rw-r--r--pkg/gui/presentation/stash_entries.go15
-rw-r--r--pkg/gui/presentation/tags.go15
9 files changed, 103 insertions, 59 deletions
diff --git a/pkg/gui/presentation/branches.go b/pkg/gui/presentation/branches.go
index b12ed8ca2..3e5c2d625 100644
--- a/pkg/gui/presentation/branches.go
+++ b/pkg/gui/presentation/branches.go
@@ -10,23 +10,29 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetBranchListDisplayStrings(branches []*commands.Branch, fullDescription bool) [][]string {
+func GetBranchListDisplayStrings(branches []*commands.Branch, fullDescription bool, diffName string) [][]string {
lines := make([][]string, len(branches))
for i := range branches {
- lines[i] = getBranchDisplayStrings(branches[i], fullDescription)
+ diffed := branches[i].Name == diffName
+ lines[i] = getBranchDisplayStrings(branches[i], fullDescription, diffed)
}
return lines
}
// getBranchDisplayStrings returns the display string of branch
-func getBranchDisplayStrings(b *commands.Branch, fullDescription bool) []string {
+func getBranchDisplayStrings(b *commands.Branch, fullDescription bool, diffed bool) []string {
displayName := b.Name
if b.DisplayName != "" {
displayName = b.DisplayName
}
- coloredName := utils.ColoredString(displayName, GetBranchColor(b.Name))
+
+ nameColorAttr := GetBranchColor(b.Name)
+ if diffed {
+ nameColorAttr = theme.DiffTerminalColor
+ }
+ coloredName := utils.ColoredString(displayName, nameColorAttr)
if b.Pushables != "" && b.Pullables != "" && b.Pushables != "?" && b.Pullables != "?" {
trackColor := color.FgYellow
if b.Pushables == "0" && b.Pullables == "0" {
diff --git a/pkg/gui/presentation/commit_files.go b/pkg/gui/presentation/commit_files.go
index 4ea0f85db..3f16da965 100644
--- a/pkg/gui/presentation/commit_files.go
+++ b/pkg/gui/presentation/commit_files.go
@@ -6,21 +6,23 @@ import (
"github.com/jesseduffield/lazygit/pkg/theme"
)
-func GetCommitFileListDisplayStrings(branches []*commands.CommitFile) [][]string {
- lines := make([][]string, len(branches))
+func GetCommitFileListDisplayStrings(commitFiles []*commands.CommitFile, diffName string) [][]string {
+ lines := make([][]string, len(commitFiles))
- for i := range branches {
- lines[i] = getCommitFileDisplayStrings(branches[i])
+ for i := range commitFiles {
+ diffed := commitFiles[i].Name == diffName
+ lines[i] = getCommitFileDisplayStrings(commitFiles[i], diffed)
}
return lines
}
// getCommitFileDisplayStrings returns the display string of branch
-func getCommitFileDisplayStrings(f *commands.CommitFile) []string {
+func getCommitFileDisplayStrings(f *commands.CommitFile, diffed bool) []string {
yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen)
defaultColor := color.New(theme.DefaultTextColor)
+ diffTerminalColor := color.New(theme.DiffTerminalColor)
var colour *color.Color
switch f.Status {
@@ -31,5 +33,8 @@ func getCommitFileDisplayStrings(f *commands.CommitFile) []string {
case commands.PART:
colour = yellow
}
+ if diffed {
+ colour = diffTerminalColor
+ }
return []string{colour.Sprint(f.DisplayString)}
}
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go
index 5463cd531..6e54e9b3a 100644
--- a/pkg/gui/presentation/commits.go
+++ b/pkg/gui/presentation/commits.go
@@ -9,10 +9,10 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool) [][]string {
+func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, cherryPickedCommitShaMap map[string]bool, diffName string) [][]string {
lines := make([][]string, len(commits))
- var displayFunc func(*commands.Commit, map[string]bool) []string
+ var displayFunc func(*commands.Commit, map[string]bool, bool) []string
if fullDescription {
displayFunc = getFullDescriptionDisplayStringsForCommit
} else {
@@ -20,20 +20,21 @@ func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription boo
}
for i := range commits {
- lines[i] = displayFunc(commits[i], cherryPickedCommitShaMap)
+ diffed := commits[i].Sha == diffName
+ lines[i] = displayFunc(commits[i], cherryPickedCommitShaMap, diffed)
}
return lines
}
-func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool) []string {
+func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string {
red := color.New(color.FgRed)
yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen)
blue := color.New(color.FgBlue)
cyan := color.New(color.FgCyan)
defaultColor := color.New(theme.DefaultTextColor)
- // magenta := color.New(color.FgMagenta)
+ diffedColor := color.New(theme.DiffTerminalColor)
// for some reason, setting the background to blue pads out the other commits
// horizontally. For the sake of accessibility I'm considering this a feature,
@@ -56,16 +57,12 @@ func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedC
shaColor = defaultColor
}
- if cherryPickedCommitShaMap[c.Sha] {
+ if diffed {
+ shaColor = diffedColor
+ } else if cherryPickedCommitShaMap[c.Sha] {
shaColor = copied
}
- // for _, entry := range diffEntries {
- // if c.Sha == entry.Sha {
- // shaColor = magenta
- // }
- // }
-
tagString := ""
secondColumnString := blue.Sprint(utils.UnixToDate(c.UnixTimestamp))
if c.Action != "" {
@@ -80,14 +77,14 @@ func getFullDescriptionDisplayStringsForCommit(c *commands.Commit, cherryPickedC
return []string{shaColor.Sprint(c.ShortSha()), secondColumnString, yellow.Sprint(truncatedAuthor), tagString + defaultColor.Sprint(c.Name)}
}
-func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool) []string {
+func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map[string]bool, diffed bool) []string {
red := color.New(color.FgRed)
yellow := color.New(color.FgYellow)
green := color.New(color.FgGreen)
blue := color.New(color.FgBlue)
cyan := color.New(color.FgCyan)
defaultColor := color.New(theme.DefaultTextColor)
- // magenta := color.New(color.FgMagenta)
+ diffedColor := color.New(theme.DiffTerminalColor)
// for some reason, setting the background to blue pads out the other commits
// horizontally. For the sake of accessibility I'm considering this a feature,
@@ -110,16 +107,12 @@ func getDisplayStringsForCommit(c *commands.Commit, cherryPickedCommitShaMap map
shaColor = defaultColor
}
- if cherryPickedCommitShaMap[c.Sha] {
+ if diffed {
+ shaColor = diffedColor
+ } else if cherryPickedCommitShaMap[c.Sha] {
shaColor = copied
}
- // for _, entry := range diffEntries {
- // if c.Sha == entry.Sha {
- // shaColor = magenta
- // }
- // }
-
actionString := ""
tagString := ""
if c.Action != "" {
diff --git a/pkg/gui/presentation/files.go b/pkg/gui/presentation/files.go
index 589e8aecc..3e70617fa 100644
--- a/pkg/gui/presentation/files.go
+++ b/pkg/gui/presentation/files.go
@@ -3,34 +3,42 @@ package presentation
import (
"github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/theme"
)
-func GetFileListDisplayStrings(files []*commands.File) [][]string {
+func GetFileListDisplayStrings(files []*commands.File, diffName string) [][]string {
lines := make([][]string, len(files))
for i := range files {
- lines[i] = getFileDisplayStrings(files[i])
+ diffed := files[i].Name == diffName
+ lines[i] = getFileDisplayStrings(files[i], diffed)
}
return lines
}
// getFileDisplayStrings returns the display string of branch
-func getFileDisplayStrings(f *commands.File) []string {
+func getFileDisplayStrings(f *commands.File, diffed bool) []string {
// potentially inefficient to be instantiating these color
// objects with each render
red := color.New(color.FgRed)
green := color.New(color.FgGreen)
+ diffColor := color.New(theme.DiffTerminalColor)
if !f.Tracked && !f.HasStagedChanges {
return []string{red.Sprint(f.DisplayString)}
}
output := green.Sprint(f.DisplayString[0:1])
output += red.Sprint(f.DisplayString[1:3])
- if f.HasUnstagedChanges {
- output += red.Sprint(f.Name)
+
+ var restColor *color.Color
+ if diffed {
+ restColor = diffColor
+ } else if f.HasUnstagedChanges {
+ restColor = red
} else {
- output += green.Sprint(f.Name)
+ restColor = green
}
+ output += restColor.Sprint(f.Name)
return []string{output}
}
diff --git a/pkg/gui/presentation/reflog_commits.go b/pkg/gui/presentation/reflog_commits.go
index e57560b76..cf3765b1c 100644
--- a/pkg/gui/presentation/reflog_commits.go
+++ b/pkg/gui/presentation/reflog_commits.go
@@ -7,10 +7,10 @@ import (
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool) [][]string {
+func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool, diffName string) [][]string {
lines := make([][]string, len(commits))
- var displayFunc func(*commands.Commit) []string
+ var displayFunc func(*commands.Commit, bool) []string
if fullDescription {
displayFunc = getFullDescriptionDisplayStringsForReflogCommit
} else {
@@ -18,23 +18,27 @@ func GetReflogCommitListDisplayStrings(commits []*commands.Commit, fullDescripti
}
for i := range commits {
- lines[i] = displayFunc(commits[i])
+ diffed := commits[i].Sha == diffName
+ lines[i] = displayFunc(commits[i], diffed)
}
return lines
}
-func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit) []string {
- defaultColor := color.New(theme.DefaultTextColor)
+func getFullDescriptionDisplayStringsForReflogCommit(c *commands.Commit, diffed bool) []string {
+ colorAttr := theme.DefaultTextColor
+ if diffed {
+ colorAttr = theme.DiffTerminalColor
+ }
return []string{
utils.ColoredString(c.ShortSha(), color.FgBlue),
utils.ColoredString(utils.UnixToDate(c.UnixTimestamp), color.FgMagenta),
- defaultColor.Sprint(c.Name),
+ utils.ColoredString(c.Name, colorAttr),
}
}
-func getDisplayStringsForReflogCommit(c *commands.Commit) []string {
+func getDisplayStringsForReflogCommit(c *commands.Commit, diffed bool) []string {
defaultColor := color.New(theme.DefaultTextColor)
return []string{utils.ColoredString(c.ShortSha(), color.FgBlue), defaultColor.Sprint(c.Name)}
diff --git a/pkg/gui/presentation/remote_branches.go b/pkg/gui/presentation/remote_branches.go
index d3094c8cb..e52e6d7f3 100644
--- a/pkg/gui/presentation/remote_branches.go
+++ b/pkg/gui/presentation/remote_branches.go
@@ -2,22 +2,29 @@ package presentation
import (
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetRemoteBranchListDisplayStrings(branches []*commands.RemoteBranch) [][]string {
+func GetRemoteBranchListDisplayStrings(branches []*commands.RemoteBranch, diffName string) [][]string {
lines := make([][]string, len(branches))
for i := range branches {
- lines[i] = getRemoteBranchDisplayStrings(branches[i])
+ diffed := branches[i].FullName() == diffName
+ lines[i] = getRemoteBranchDisplayStrings(branches[i], diffed)
}
return lines
}
// getRemoteBranchDisplayStrings returns the display string of branch
-func getRemoteBranchDisplayStrings(b *commands.RemoteBranch) []string {
- displayName := utils.ColoredString(b.Name, GetBranchColor(b.Name))
+func getRemoteBranchDisplayStrings(b *commands.RemoteBranch, diffed bool) []string {
+ nameColorAttr := GetBranchColor(b.Name)
+ if diffed {
+ nameColorAttr = theme.DiffTerminalColor
+ }
+
+ displayName := utils.ColoredString(b.Name, nameColorAttr)
return []string{displayName}
}
diff --git a/pkg/gui/presentation/remotes.go b/pkg/gui/presentation/remotes.go
index 3adfad858..5ad5f77c8 100644
--- a/pkg/gui/presentation/remotes.go
+++ b/pkg/gui/presentation/remotes.go
@@ -5,22 +5,29 @@ import (
"github.com/fatih/color"
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/theme"
"github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetRemoteListDisplayStrings(remotes []*commands.Remote) [][]string {
+func GetRemoteListDisplayStrings(remotes []*commands.Remote, diffName string) [][]string {
lines := make([][]string, len(remotes))
for i := range remotes {
- lines[i] = getRemoteDisplayStrings(remotes[i])
+ diffed := remotes[i].Name == diffName
+ lines[i] = getRemoteDisplayStrings(remotes[i], diffed)
}
return lines
}
// getRemoteDisplayStrings returns the display string of branch
-func getRemoteDisplayStrings(r *commands.Remote) []string {
+func getRemoteDisplayStrings(r *commands.Remote, diffed bool) []string {
branchCount := len(r.Branches)
- return []string{r.Name, utils.ColoredString(fmt.Sprintf("%d branches", branchCount), color.FgBlue)}
+ nameColorAttr := theme.DefaultTextColor
+ if diffed {
+ nameColorAttr = theme.DiffTerminalColor
+ }
+
+ return []string{utils.ColoredString(r.Name, nameColorAttr), utils.ColoredString(fmt.Sprintf("%d branches", branchCount), color.FgBlue)}
}
diff --git a/pkg/gui/presentation/stash_entries.go b/pkg/gui/presentation/stash_entries.go
index a5557a433..d1f54cc8a 100644
--- a/pkg/gui/presentation/stash_entries.go
+++ b/pkg/gui/presentation/stash_entries.go
@@ -2,19 +2,26 @@ package presentation
import (
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/theme"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry) [][]string {
+func GetStashEntryListDisplayStrings(stashEntries []*commands.StashEntry, diffName string) [][]string {
lines := make([][]string, len(stashEntries))
for i := range stashEntries {
- lines[i] = getStashEntryDisplayStrings(stashEntries[i])
+ diffed := stashEntries[i].RefName() == diffName
+ lines[i] = getStashEntryDisplayStrings(stashEntries[i], diffed)
}
return lines
}
// getStashEntryDisplayStrings returns the display string of branch
-func getStashEntryDisplayStrings(s *commands.StashEntry) []string {
- return []string{s.Name}
+func getStashEntryDisplayStrings(s *commands.StashEntry, diffed bool) []string {
+ attr := theme.DefaultTextColor
+ if diffed {
+ attr = theme.DiffTerminalColor
+ }
+ return []string{utils.ColoredString(s.Name, attr)}
}
diff --git a/pkg/gui/presentation/tags.go b/pkg/gui/presentation/tags.go
index 13f2b8b59..475c717cc 100644
--- a/pkg/gui/presentation/tags.go
+++ b/pkg/gui/presentation/tags.go
@@ -2,19 +2,26 @@ package presentation
import (
"github.com/jesseduffield/lazygit/pkg/commands"
+ "github.com/jesseduffield/lazygit/pkg/theme"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
-func GetTagListDisplayStrings(tags []*commands.Tag) [][]string {
+func GetTagListDisplayStrings(tags []*commands.Tag, diffName string) [][]string {
lines := make([][]string, len(tags))
for i := range tags {
- lines[i] = getTagDisplayStrings(tags[i])
+ diffed := tags[i].Name == diffName
+ lines[i] = getTagDisplayStrings(tags[i], diffed)
}
return lines
}
// getTagDisplayStrings returns the display string of branch
-func getTagDisplayStrings(t *commands.Tag) []string {
- return []string{t.Name}
+func getTagDisplayStrings(t *commands.Tag, diffed bool) []string {
+ attr := theme.DefaultTextColor
+ if diffed {
+ attr = theme.DiffTerminalColor
+ }
+ return []string{utils.ColoredString(t.Name, attr)}
}