diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-03 08:23:47 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-11-05 07:58:21 +1100 |
commit | 9a9e3d506d5aa22d06f2adfc25427200c561edf1 (patch) | |
tree | a155c7be295fc039325d33f9ecf6d2dc5fa72b1c | |
parent | 06ca71e955d58128773e2ab4b5db173b4609497f (diff) |
more consistent rendering
-rw-r--r-- | pkg/gui/gui.go | 5 | ||||
-rw-r--r-- | pkg/gui/presentation/graph/cell.go | 8 | ||||
-rw-r--r-- | pkg/gui/presentation/graph/graph_test.go | 94 |
3 files changed, 54 insertions, 53 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 4371b9391..35b497fc9 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -23,6 +23,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/modes/diffing" "github.com/jesseduffield/lazygit/pkg/gui/modes/filtering" "github.com/jesseduffield/lazygit/pkg/gui/presentation/authors" + "github.com/jesseduffield/lazygit/pkg/gui/presentation/graph" "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/i18n" @@ -462,8 +463,8 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom var RuneReplacements = map[rune]string{ // for the commit graph - '⏣': "M", - '⎔': "o", + graph.MergeSymbol: "M", + graph.CommitSymbol: "o", } // Run setup the gui with keybindings and start the mainloop diff --git a/pkg/gui/presentation/graph/cell.go b/pkg/gui/presentation/graph/cell.go index 84ff722ba..9ba7d92fb 100644 --- a/pkg/gui/presentation/graph/cell.go +++ b/pkg/gui/presentation/graph/cell.go @@ -8,8 +8,8 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/style" ) -const mergeSymbol = "⏣" -const commitSymbol = "⎔" +const MergeSymbol = '⏣' +const CommitSymbol = '◯' type cellType int @@ -35,9 +35,9 @@ func (cell *Cell) render(writer io.StringWriter) { case CONNECTION: adjustedFirst = first case COMMIT: - adjustedFirst = commitSymbol + adjustedFirst = string(CommitSymbol) case MERGE: - adjustedFirst = mergeSymbol + adjustedFirst = string(MergeSymbol) } var rightStyle *style.TextStyle diff --git a/pkg/gui/presentation/graph/graph_test.go b/pkg/gui/presentation/graph/graph_test.go index 416409b9f..300042558 100644 --- a/pkg/gui/presentation/graph/graph_test.go +++ b/pkg/gui/presentation/graph/graph_test.go @@ -45,20 +45,20 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "D", Parents: []string{"G"}}, }, expectedOutput: ` - 1 ⎔ - 2 ⎔ - 3 ⎔ + 1 ◯ + 2 ◯ + 3 ◯ 4 ⏣─╮ - 7 │ ⎔ - 5 ⎔─╯ - 8 ⎔ + 7 │ ◯ + 5 ◯─╯ + 8 ◯ 9 ⏣─╮ - B │ ⎔ - D │ ⎔ - A ⎔ │ - E ⎔ │ - F ⎔ │ - D ⎔─╯`, + B │ ◯ + D │ ◯ + A ◯ │ + E ◯ │ + F ◯ │ + D ◯─╯`, }, { name: "with a path that has room to move to the left", @@ -71,12 +71,12 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "6", Parents: []string{"7"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 4 │ ⏣─╮ - 3 ⎔─╯ │ - 5 ⎔───╯ - 6 ⎔`, + 3 ◯─╯ │ + 5 ◯───╯ + 6 ◯`, }, { name: "with a new commit", @@ -90,13 +90,13 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "6", Parents: []string{"7"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 4 │ ⏣─╮ - Z │ │ │ ⎔ - 3 ⎔─╯ │ │ - 5 ⎔───╯ │ - 6 ⎔ ╭───╯`, + Z │ │ │ ◯ + 3 ◯─╯ │ │ + 5 ◯───╯ │ + 6 ◯ ╭───╯`, }, { name: "with a path that has room to move to the left and continues", @@ -109,12 +109,12 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "7", Parents: []string{"11"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 3 ⏣─│─╮ 5 ⏣─│─│─╮ - 4 │ ⎔─╯ │ - 7 ⎔─╯ ╭─╯`, + 4 │ ◯─╯ │ + 7 ◯─╯ ╭─╯`, }, { name: "with a path that has room to move to the left and continues", @@ -128,13 +128,13 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "B", Parents: []string{"C"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 3 ⏣─│─╮ 5 ⏣─│─│─╮ 7 ⏣─│─│─│─╮ - 4 ⎔─┴─╯ │ │ - B ⎔ ╭───╯ │`, + 4 ◯─┴─╯ │ │ + B ◯ ╭───╯ │`, }, { name: "with a path that has room to move to the left and continues", @@ -147,10 +147,10 @@ func TestRenderCommitGraph(t *testing.T) { }, expectedOutput: ` 1 ⏣─╮ - 3 │ ⎔ + 3 │ ◯ 2 ⏣─│ 4 ⏣─│─╮ - 6 ⎔ │ │`, + 6 ◯ │ │`, }, { name: "new merge path fills gap before continuing path on right", @@ -163,10 +163,10 @@ func TestRenderCommitGraph(t *testing.T) { }, expectedOutput: ` 1 ⏣─┬─┬─╮ - 4 │ │ ⎔ │ - 2 ⎔─│─╯ │ + 4 │ │ ◯ │ + 2 ◯─│─╯ │ A ⏣─│─╮ │ - B │ │ ⎔ │`, + B │ │ ◯ │`, }, { name: "with a path that has room to move to the left and continues", @@ -181,14 +181,14 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "C", Parents: []string{"D"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 3 ⏣─│─╮ 5 ⏣─│─│─╮ 7 ⏣─│─│─│─╮ - 4 ⎔─┴─╯ │ │ - B ⎔ ╭───╯ │ - C ⎔ │ ╭───╯`, + 4 ◯─┴─╯ │ │ + B ◯ ╭───╯ │ + C ◯ │ ╭───╯`, }, { name: "with a path that has room to move to the left and continues", @@ -205,16 +205,16 @@ func TestRenderCommitGraph(t *testing.T) { {Sha: "D", Parents: []string{"F"}}, }, expectedOutput: ` - 1 ⎔ + 1 ◯ 2 ⏣─╮ 3 ⏣─│─╮ 5 ⏣─│─│─╮ 7 ⏣─│─│─│─╮ 8 ⏣─│─│─│─│─╮ - 4 ⎔─┴─╯ │ │ │ - B ⎔ ╭───╯ │ │ - C ⎔ │ ╭───╯ │ - D ⎔ │ │ ╭───╯`, + 4 ◯─┴─╯ │ │ │ + B ◯ ╭───╯ │ │ + C ◯ │ ╭───╯ │ + D ◯ │ │ ╭───╯`, }, } @@ -269,7 +269,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 0, toPos: 0, fromSha: "b", toSha: "c", kind: STARTS, style: green}, }, prevCommit: &models.Commit{Sha: "a"}, - expectedStr: "⎔", + expectedStr: "◯", expectedStyles: []style.TextStyle{green}, }, { @@ -279,7 +279,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 0, toPos: 0, fromSha: "selected", toSha: "c", kind: STARTS, style: green}, }, prevCommit: &models.Commit{Sha: "a"}, - expectedStr: "⎔", + expectedStr: "◯", expectedStyles: []style.TextStyle{highlightStyle}, }, { @@ -349,7 +349,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 2, toPos: 0, fromSha: "c1", toSha: "a2", kind: TERMINATES, style: green}, }, prevCommit: &models.Commit{Sha: "a1"}, - expectedStr: "⎔─┴─╯", + expectedStr: "◯─┴─╯", expectedStyles: []style.TextStyle{ yellow, magenta, magenta, green, green, }, @@ -406,7 +406,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 0, toPos: 0, fromSha: "a2", toSha: "a3", kind: STARTS, style: yellow}, }, prevCommit: &models.Commit{Sha: "selected"}, - expectedStr: "⎔", + expectedStr: "◯", expectedStyles: []style.TextStyle{ yellow, }, @@ -418,7 +418,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 1, toPos: 1, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red}, }, prevCommit: &models.Commit{Sha: "selected"}, - expectedStr: "⎔ │", + expectedStr: "◯ │", expectedStyles: []style.TextStyle{ highlightStyle, nothing, highlightStyle, }, @@ -431,7 +431,7 @@ func TestRenderPipeSet(t *testing.T) { {fromPos: 2, toPos: 2, fromSha: "selected", toSha: "b3", kind: CONTINUES, style: red}, }, prevCommit: &models.Commit{Sha: "selected"}, - expectedStr: "⎔ │ │", + expectedStr: "◯ │ │", expectedStyles: []style.TextStyle{ highlightStyle, nothing, green, nothing, highlightStyle, }, |