mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-08 04:04:22 +02:00
Merge pull request #1926 from jesseduffield/prep-for-author-setting
This commit is contained in:
commit
f7c44f2407
@ -157,14 +157,15 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
|
|||||||
// example input:
|
// example input:
|
||||||
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
|
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
|
||||||
func (self *CommitLoader) extractCommitFromLine(line string) *models.Commit {
|
func (self *CommitLoader) extractCommitFromLine(line string) *models.Commit {
|
||||||
split := strings.SplitN(line, "\x00", 6)
|
split := strings.SplitN(line, "\x00", 7)
|
||||||
|
|
||||||
sha := split[0]
|
sha := split[0]
|
||||||
unixTimestamp := split[1]
|
unixTimestamp := split[1]
|
||||||
author := split[2]
|
authorName := split[2]
|
||||||
extraInfo := strings.TrimSpace(split[3])
|
authorEmail := split[3]
|
||||||
parentHashes := split[4]
|
extraInfo := strings.TrimSpace(split[4])
|
||||||
message := split[5]
|
parentHashes := split[5]
|
||||||
|
message := split[6]
|
||||||
|
|
||||||
tags := []string{}
|
tags := []string{}
|
||||||
|
|
||||||
@ -189,7 +190,8 @@ func (self *CommitLoader) extractCommitFromLine(line string) *models.Commit {
|
|||||||
Tags: tags,
|
Tags: tags,
|
||||||
ExtraInfo: extraInfo,
|
ExtraInfo: extraInfo,
|
||||||
UnixTimestamp: int64(unitTimestampInt),
|
UnixTimestamp: int64(unitTimestampInt),
|
||||||
Author: author,
|
AuthorName: authorName,
|
||||||
|
AuthorEmail: authorEmail,
|
||||||
Parents: parents,
|
Parents: parents,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,7 +448,8 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) oscommands.ICmdObj {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var prettyFormat = fmt.Sprintf(
|
var prettyFormat = fmt.Sprintf(
|
||||||
"--pretty=format:\"%%H%s%%at%s%%aN%s%%d%s%%p%s%%s\"",
|
"--pretty=format:\"%%H%s%%at%s%%aN%s%%ae%s%%d%s%%p%s%%s\"",
|
||||||
|
NULL_CODE,
|
||||||
NULL_CODE,
|
NULL_CODE,
|
||||||
NULL_CODE,
|
NULL_CODE,
|
||||||
NULL_CODE,
|
NULL_CODE,
|
||||||
|
@ -12,14 +12,14 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var commitsOutput = strings.Replace(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield| (HEAD -> better-tests)|b21997d6b4cbdf84b149|better typing for rebase mode
|
var commitsOutput = strings.Replace(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield|jessedduffield@gmail.com| (HEAD -> better-tests)|b21997d6b4cbdf84b149|better typing for rebase mode
|
||||||
b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164|1640824515|Jesse Duffield| (origin/better-tests)|e94e8fc5b6fab4cb755f|fix logging
|
b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164|1640824515|Jesse Duffield|jessedduffield@gmail.com| (origin/better-tests)|e94e8fc5b6fab4cb755f|fix logging
|
||||||
e94e8fc5b6fab4cb755f29f1bdb3ee5e001df35c|1640823749|Jesse Duffield||d8084cd558925eb7c9c3|refactor
|
e94e8fc5b6fab4cb755f29f1bdb3ee5e001df35c|1640823749|Jesse Duffield|jessedduffield@gmail.com||d8084cd558925eb7c9c3|refactor
|
||||||
d8084cd558925eb7c9c38afeed5725c21653ab90|1640821426|Jesse Duffield||65f910ebd85283b5cce9|WIP
|
d8084cd558925eb7c9c38afeed5725c21653ab90|1640821426|Jesse Duffield|jessedduffield@gmail.com||65f910ebd85283b5cce9|WIP
|
||||||
65f910ebd85283b5cce9bf67d03d3f1a9ea3813a|1640821275|Jesse Duffield||26c07b1ab33860a1a759|WIP
|
65f910ebd85283b5cce9bf67d03d3f1a9ea3813a|1640821275|Jesse Duffield|jessedduffield@gmail.com||26c07b1ab33860a1a759|WIP
|
||||||
26c07b1ab33860a1a7591a0638f9925ccf497ffa|1640750752|Jesse Duffield||3d4470a6c072208722e5|WIP
|
26c07b1ab33860a1a7591a0638f9925ccf497ffa|1640750752|Jesse Duffield|jessedduffield@gmail.com||3d4470a6c072208722e5|WIP
|
||||||
3d4470a6c072208722e5ae9a54bcb9634959a1c5|1640748818|Jesse Duffield||053a66a7be3da43aacdc|WIP
|
3d4470a6c072208722e5ae9a54bcb9634959a1c5|1640748818|Jesse Duffield|jessedduffield@gmail.com||053a66a7be3da43aacdc|WIP
|
||||||
053a66a7be3da43aacdc7aa78e1fe757b82c4dd2|1640739815|Jesse Duffield||985fe482e806b172aea4|refactoring the config struct`, "|", "\x00", -1)
|
053a66a7be3da43aacdc7aa78e1fe757b82c4dd2|1640739815|Jesse Duffield|jessedduffield@gmail.com||985fe482e806b172aea4|refactoring the config struct`, "|", "\x00", -1)
|
||||||
|
|
||||||
func TestGetCommits(t *testing.T) {
|
func TestGetCommits(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
@ -40,7 +40,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
opts: GetCommitsOptions{RefName: "HEAD", IncludeRebaseCommits: false},
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
||||||
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
|
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, "", nil),
|
||||||
|
|
||||||
expectedCommits: []*models.Commit{},
|
expectedCommits: []*models.Commit{},
|
||||||
expectedError: nil,
|
expectedError: nil,
|
||||||
@ -54,7 +54,7 @@ func TestGetCommits(t *testing.T) {
|
|||||||
// here it's seeing which commits are yet to be pushed
|
// here it's seeing which commits are yet to be pushed
|
||||||
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
Expect(`git merge-base "HEAD" "HEAD"@{u}`, "b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164", nil).
|
||||||
// here it's actually getting all the commits in a formatted form, one per line
|
// here it's actually getting all the commits in a formatted form, one per line
|
||||||
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
|
Expect(`git log "HEAD" --topo-order --oneline --pretty=format:"%H%x00%at%x00%aN%x00%ae%x00%d%x00%p%x00%s" --abbrev=40`, commitsOutput, nil).
|
||||||
// here it's seeing where our branch diverged from the master branch so that we can mark that commit and parent commits as 'merged'
|
// here it's seeing where our branch diverged from the master branch so that we can mark that commit and parent commits as 'merged'
|
||||||
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
|
Expect(`git merge-base "HEAD" "master"`, "26c07b1ab33860a1a7591a0638f9925ccf497ffa", nil),
|
||||||
|
|
||||||
@ -66,7 +66,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "(HEAD -> better-tests)",
|
ExtraInfo: "(HEAD -> better-tests)",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640826609,
|
UnixTimestamp: 1640826609,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"b21997d6b4cbdf84b149",
|
"b21997d6b4cbdf84b149",
|
||||||
@ -79,7 +80,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "(origin/better-tests)",
|
ExtraInfo: "(origin/better-tests)",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640824515,
|
UnixTimestamp: 1640824515,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"e94e8fc5b6fab4cb755f",
|
"e94e8fc5b6fab4cb755f",
|
||||||
@ -92,7 +94,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640823749,
|
UnixTimestamp: 1640823749,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"d8084cd558925eb7c9c3",
|
"d8084cd558925eb7c9c3",
|
||||||
@ -105,7 +108,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640821426,
|
UnixTimestamp: 1640821426,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"65f910ebd85283b5cce9",
|
"65f910ebd85283b5cce9",
|
||||||
@ -118,7 +122,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640821275,
|
UnixTimestamp: 1640821275,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"26c07b1ab33860a1a759",
|
"26c07b1ab33860a1a759",
|
||||||
@ -131,7 +136,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640750752,
|
UnixTimestamp: 1640750752,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"3d4470a6c072208722e5",
|
"3d4470a6c072208722e5",
|
||||||
@ -144,7 +150,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640748818,
|
UnixTimestamp: 1640748818,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"053a66a7be3da43aacdc",
|
"053a66a7be3da43aacdc",
|
||||||
@ -157,7 +164,8 @@ func TestGetCommits(t *testing.T) {
|
|||||||
Action: "",
|
Action: "",
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
ExtraInfo: "",
|
ExtraInfo: "",
|
||||||
Author: "Jesse Duffield",
|
AuthorName: "Jesse Duffield",
|
||||||
|
AuthorEmail: "jessedduffield@gmail.com",
|
||||||
UnixTimestamp: 1640739815,
|
UnixTimestamp: 1640739815,
|
||||||
Parents: []string{
|
Parents: []string{
|
||||||
"985fe482e806b172aea4",
|
"985fe482e806b172aea4",
|
||||||
|
@ -17,7 +17,8 @@ type Commit struct {
|
|||||||
Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
|
Action string // one of "", "pick", "edit", "squash", "reword", "drop", "fixup"
|
||||||
Tags []string
|
Tags []string
|
||||||
ExtraInfo string // something like 'HEAD -> master, tag: v0.15.2'
|
ExtraInfo string // something like 'HEAD -> master, tag: v0.15.2'
|
||||||
Author string // something like 'Jesse Duffield <jessedduffield@gmail.com>'
|
AuthorName string // something like 'Jesse Duffield'
|
||||||
|
AuthorEmail string // something like 'jessedduffield@gmail.com'
|
||||||
UnixTimestamp int64
|
UnixTimestamp int64
|
||||||
|
|
||||||
// SHAs of parent commits (will be multiple if it's a merge commit)
|
// SHAs of parent commits (will be multiple if it's a merge commit)
|
||||||
|
@ -58,7 +58,7 @@ func (self *MenuContext) GetSelectedItemId() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return item.DisplayString
|
return item.Label
|
||||||
}
|
}
|
||||||
|
|
||||||
type MenuViewModel struct {
|
type MenuViewModel struct {
|
||||||
@ -96,11 +96,11 @@ func (self *MenuViewModel) GetDisplayStrings(_startIdx int, _length int) [][]str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getItemDisplayStrings(item *types.MenuItem) []string {
|
func getItemDisplayStrings(item *types.MenuItem) []string {
|
||||||
if item.DisplayStrings != nil {
|
if item.LabelColumns != nil {
|
||||||
return item.DisplayStrings
|
return item.LabelColumns
|
||||||
}
|
}
|
||||||
|
|
||||||
styledStr := item.DisplayString
|
styledStr := item.Label
|
||||||
if item.OpensMenu {
|
if item.OpensMenu {
|
||||||
styledStr = presentation.OpensMenuStyle(styledStr)
|
styledStr = presentation.OpensMenuStyle(styledStr)
|
||||||
}
|
}
|
||||||
|
@ -101,35 +101,35 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
|
|||||||
Title: self.c.Tr.Actions.CopyCommitAttributeToClipboard,
|
Title: self.c.Tr.Actions.CopyCommitAttributeToClipboard,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcCommitSha,
|
Label: self.c.Tr.LcCommitSha,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.copyCommitSHAToClipboard(commit)
|
return self.copyCommitSHAToClipboard(commit)
|
||||||
},
|
},
|
||||||
Key: 's',
|
Key: 's',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcCommitURL,
|
Label: self.c.Tr.LcCommitURL,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.copyCommitURLToClipboard(commit)
|
return self.copyCommitURLToClipboard(commit)
|
||||||
},
|
},
|
||||||
Key: 'u',
|
Key: 'u',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcCommitDiff,
|
Label: self.c.Tr.LcCommitDiff,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.copyCommitDiffToClipboard(commit)
|
return self.copyCommitDiffToClipboard(commit)
|
||||||
},
|
},
|
||||||
Key: 'd',
|
Key: 'd',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcCommitMessage,
|
Label: self.c.Tr.LcCommitMessage,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.copyCommitMessageToClipboard(commit)
|
return self.copyCommitMessageToClipboard(commit)
|
||||||
},
|
},
|
||||||
Key: 'm',
|
Key: 'm',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcCommitAuthor,
|
Label: self.c.Tr.LcCommitAuthor,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.copyAuthorToClipboard(commit)
|
return self.copyAuthorToClipboard(commit)
|
||||||
},
|
},
|
||||||
|
@ -67,7 +67,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
|
|
||||||
menuItems := []*types.MenuItem{
|
menuItems := []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
|
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.NewTerm()),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||||
if err := self.git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
|
if err := self.git.Bisect.Mark(commit.Sha, info.NewTerm()); err != nil {
|
||||||
@ -79,7 +79,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
Key: 'b',
|
Key: 'b',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
|
Label: fmt.Sprintf(self.c.Tr.Bisect.Mark, commit.ShortSha(), info.OldTerm()),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
self.c.LogAction(self.c.Tr.Actions.BisectMark)
|
||||||
if err := self.git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil {
|
if err := self.git.Bisect.Mark(commit.Sha, info.OldTerm()); err != nil {
|
||||||
@ -91,7 +91,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
Key: 'g',
|
Key: 'g',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
|
Label: fmt.Sprintf(self.c.Tr.Bisect.Skip, commit.ShortSha()),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
|
self.c.LogAction(self.c.Tr.Actions.BisectSkip)
|
||||||
if err := self.git.Bisect.Skip(commit.Sha); err != nil {
|
if err := self.git.Bisect.Skip(commit.Sha); err != nil {
|
||||||
@ -103,7 +103,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
Key: 's',
|
Key: 's',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.Bisect.ResetOption,
|
Label: self.c.Tr.Bisect.ResetOption,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.helpers.Bisect.Reset()
|
return self.helpers.Bisect.Reset()
|
||||||
},
|
},
|
||||||
@ -122,7 +122,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
|||||||
Title: self.c.Tr.Bisect.BisectMenuTitle,
|
Title: self.c.Tr.Bisect.BisectMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()),
|
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.NewTerm()),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
||||||
if err := self.git.Bisect.Start(); err != nil {
|
if err := self.git.Bisect.Start(); err != nil {
|
||||||
@ -138,7 +138,7 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo,
|
|||||||
Key: 'b',
|
Key: 'b',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
|
Label: fmt.Sprintf(self.c.Tr.Bisect.MarkStart, commit.ShortSha(), info.OldTerm()),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
self.c.LogAction(self.c.Tr.Actions.StartBisect)
|
||||||
if err := self.git.Bisect.Start(); err != nil {
|
if err := self.git.Bisect.Start(); err != nil {
|
||||||
|
@ -111,7 +111,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error
|
|||||||
Title: self.c.Tr.Actions.SetUnsetUpstream,
|
Title: self.c.Tr.Actions.SetUnsetUpstream,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{self.c.Tr.LcUnsetUpstream},
|
LabelColumns: []string{self.c.Tr.LcUnsetUpstream},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
if err := self.git.Branch.UnsetUpstream(selectedBranch.Name); err != nil {
|
if err := self.git.Branch.UnsetUpstream(selectedBranch.Name); err != nil {
|
||||||
return self.c.Error(err)
|
return self.c.Error(err)
|
||||||
@ -130,7 +130,7 @@ func (self *BranchesController) setUpstream(selectedBranch *models.Branch) error
|
|||||||
Key: 'u',
|
Key: 'u',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{self.c.Tr.LcSetUpstream},
|
LabelColumns: []string{self.c.Tr.LcSetUpstream},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.helpers.Upstream.PromptForUpstreamWithoutInitialContent(selectedBranch, func(upstream string) error {
|
return self.helpers.Upstream.PromptForUpstreamWithoutInitialContent(selectedBranch, func(upstream string) error {
|
||||||
upstreamRemote, upstreamBranch, err := self.helpers.Upstream.ParseUpstream(upstream)
|
upstreamRemote, upstreamBranch, err := self.helpers.Upstream.ParseUpstream(upstream)
|
||||||
@ -417,20 +417,20 @@ func (self *BranchesController) newBranch(selectedBranch *models.Branch) error {
|
|||||||
func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Branch, checkedOutBranch *models.Branch) error {
|
func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Branch, checkedOutBranch *models.Branch) error {
|
||||||
menuItems := make([]*types.MenuItem, 0, 4)
|
menuItems := make([]*types.MenuItem, 0, 4)
|
||||||
|
|
||||||
fromToDisplayStrings := func(from string, to string) []string {
|
fromToLabelColumns := func(from string, to string) []string {
|
||||||
return []string{fmt.Sprintf("%s → %s", from, to)}
|
return []string{fmt.Sprintf("%s → %s", from, to)}
|
||||||
}
|
}
|
||||||
|
|
||||||
menuItemsForBranch := func(branch *models.Branch) []*types.MenuItem {
|
menuItemsForBranch := func(branch *models.Branch) []*types.MenuItem {
|
||||||
return []*types.MenuItem{
|
return []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayStrings: fromToDisplayStrings(branch.Name, self.c.Tr.LcDefaultBranch),
|
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.LcDefaultBranch),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.createPullRequest(branch.Name, "")
|
return self.createPullRequest(branch.Name, "")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: fromToDisplayStrings(branch.Name, self.c.Tr.LcSelectBranch),
|
LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.LcSelectBranch),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.Prompt(types.PromptOpts{
|
return self.c.Prompt(types.PromptOpts{
|
||||||
Title: branch.Name + " →",
|
Title: branch.Name + " →",
|
||||||
@ -447,7 +447,7 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra
|
|||||||
if selectedBranch != checkedOutBranch {
|
if selectedBranch != checkedOutBranch {
|
||||||
menuItems = append(menuItems,
|
menuItems = append(menuItems,
|
||||||
&types.MenuItem{
|
&types.MenuItem{
|
||||||
DisplayStrings: fromToDisplayStrings(checkedOutBranch.Name, selectedBranch.Name),
|
LabelColumns: fromToLabelColumns(checkedOutBranch.Name, selectedBranch.Name),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.createPullRequest(checkedOutBranch.Name, selectedBranch.Name)
|
return self.createPullRequest(checkedOutBranch.Name, selectedBranch.Name)
|
||||||
},
|
},
|
||||||
|
@ -500,19 +500,19 @@ func (self *FilesController) handleStatusFilterPressed() error {
|
|||||||
Title: self.c.Tr.FilteringMenuTitle,
|
Title: self.c.Tr.FilteringMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.FilterStagedFiles,
|
Label: self.c.Tr.FilterStagedFiles,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.setStatusFiltering(filetree.DisplayStaged)
|
return self.setStatusFiltering(filetree.DisplayStaged)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.FilterUnstagedFiles,
|
Label: self.c.Tr.FilterUnstagedFiles,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.setStatusFiltering(filetree.DisplayUnstaged)
|
return self.setStatusFiltering(filetree.DisplayUnstaged)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.ResetCommitFilterState,
|
Label: self.c.Tr.ResetCommitFilterState,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.setStatusFiltering(filetree.DisplayAll)
|
return self.setStatusFiltering(filetree.DisplayAll)
|
||||||
},
|
},
|
||||||
@ -557,14 +557,14 @@ func (self *FilesController) createStashMenu() error {
|
|||||||
Title: self.c.Tr.LcStashOptions,
|
Title: self.c.Tr.LcStashOptions,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcStashAllChanges,
|
Label: self.c.Tr.LcStashAllChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges, self.c.Tr.NoFilesToStash)
|
return self.handleStashSave(self.git.Stash.Save, self.c.Tr.Actions.StashAllChanges, self.c.Tr.NoFilesToStash)
|
||||||
},
|
},
|
||||||
Key: 'a',
|
Key: 'a',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcStashAllChangesKeepIndex,
|
Label: self.c.Tr.LcStashAllChangesKeepIndex,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
// if there are no staged files it behaves the same as Stash.Save
|
// if there are no staged files it behaves the same as Stash.Save
|
||||||
return self.handleStashSave(self.git.Stash.StashAndKeepIndex, self.c.Tr.Actions.StashAllChangesKeepIndex, self.c.Tr.NoFilesToStash)
|
return self.handleStashSave(self.git.Stash.StashAndKeepIndex, self.c.Tr.Actions.StashAllChangesKeepIndex, self.c.Tr.NoFilesToStash)
|
||||||
@ -572,7 +572,7 @@ func (self *FilesController) createStashMenu() error {
|
|||||||
Key: 'i',
|
Key: 'i',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcStashStagedChanges,
|
Label: self.c.Tr.LcStashStagedChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
// there must be something in staging otherwise the current implementation mucks the stash up
|
// there must be something in staging otherwise the current implementation mucks the stash up
|
||||||
if !self.helpers.WorkingTree.AnyStagedFiles() {
|
if !self.helpers.WorkingTree.AnyStagedFiles() {
|
||||||
@ -583,7 +583,7 @@ func (self *FilesController) createStashMenu() error {
|
|||||||
Key: 's',
|
Key: 's',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcStashUnstagedChanges,
|
Label: self.c.Tr.LcStashUnstagedChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
if self.helpers.WorkingTree.AnyStagedFiles() {
|
if self.helpers.WorkingTree.AnyStagedFiles() {
|
||||||
return self.handleStashSave(self.git.Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges, self.c.Tr.NoFilesToStash)
|
return self.handleStashSave(self.git.Stash.StashUnstagedChanges, self.c.Tr.Actions.StashUnstagedChanges, self.c.Tr.NoFilesToStash)
|
||||||
|
@ -43,7 +43,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
|||||||
if node.File == nil {
|
if node.File == nil {
|
||||||
menuItems = []*types.MenuItem{
|
menuItems = []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcDiscardAllChanges,
|
Label: self.c.Tr.LcDiscardAllChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInDirectory)
|
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInDirectory)
|
||||||
if err := self.git.WorkingTree.DiscardAllDirChanges(node); err != nil {
|
if err := self.git.WorkingTree.DiscardAllDirChanges(node); err != nil {
|
||||||
@ -57,7 +57,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
|||||||
|
|
||||||
if node.GetHasStagedChanges() && node.GetHasUnstagedChanges() {
|
if node.GetHasStagedChanges() && node.GetHasUnstagedChanges() {
|
||||||
menuItems = append(menuItems, &types.MenuItem{
|
menuItems = append(menuItems, &types.MenuItem{
|
||||||
DisplayString: self.c.Tr.LcDiscardUnstagedChanges,
|
Label: self.c.Tr.LcDiscardUnstagedChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DiscardUnstagedChangesInDirectory)
|
self.c.LogAction(self.c.Tr.Actions.DiscardUnstagedChangesInDirectory)
|
||||||
if err := self.git.WorkingTree.DiscardUnstagedDirChanges(node); err != nil {
|
if err := self.git.WorkingTree.DiscardUnstagedDirChanges(node); err != nil {
|
||||||
@ -78,7 +78,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
|||||||
|
|
||||||
menuItems = []*types.MenuItem{
|
menuItems = []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcSubmoduleStashAndReset,
|
Label: self.c.Tr.LcSubmoduleStashAndReset,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.ResetSubmodule(submodule)
|
return self.ResetSubmodule(submodule)
|
||||||
},
|
},
|
||||||
@ -87,7 +87,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
|||||||
} else {
|
} else {
|
||||||
menuItems = []*types.MenuItem{
|
menuItems = []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcDiscardAllChanges,
|
Label: self.c.Tr.LcDiscardAllChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInFile)
|
self.c.LogAction(self.c.Tr.Actions.DiscardAllChangesInFile)
|
||||||
if err := self.git.WorkingTree.DiscardAllFileChanges(file); err != nil {
|
if err := self.git.WorkingTree.DiscardAllFileChanges(file); err != nil {
|
||||||
@ -101,7 +101,7 @@ func (self *FilesRemoveController) remove(node *filetree.FileNode) error {
|
|||||||
|
|
||||||
if file.HasStagedChanges && file.HasUnstagedChanges {
|
if file.HasStagedChanges && file.HasUnstagedChanges {
|
||||||
menuItems = append(menuItems, &types.MenuItem{
|
menuItems = append(menuItems, &types.MenuItem{
|
||||||
DisplayString: self.c.Tr.LcDiscardUnstagedChanges,
|
Label: self.c.Tr.LcDiscardUnstagedChanges,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.DiscardAllUnstagedChangesInFile)
|
self.c.LogAction(self.c.Tr.Actions.DiscardAllUnstagedChangesInFile)
|
||||||
if err := self.git.WorkingTree.DiscardUnstagedFileChanges(file); err != nil {
|
if err := self.git.WorkingTree.DiscardUnstagedFileChanges(file); err != nil {
|
||||||
|
@ -64,30 +64,30 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er
|
|||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
// not localising here because it's one to one with the actual git flow commands
|
// not localising here because it's one to one with the actual git flow commands
|
||||||
DisplayString: fmt.Sprintf("finish branch '%s'", branch.Name),
|
Label: fmt.Sprintf("finish branch '%s'", branch.Name),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.gitFlowFinishBranch(branch.Name)
|
return self.gitFlowFinishBranch(branch.Name)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "start feature",
|
Label: "start feature",
|
||||||
OnPress: startHandler("feature"),
|
OnPress: startHandler("feature"),
|
||||||
Key: 'f',
|
Key: 'f',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "start hotfix",
|
Label: "start hotfix",
|
||||||
OnPress: startHandler("hotfix"),
|
OnPress: startHandler("hotfix"),
|
||||||
Key: 'h',
|
Key: 'h',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "start bugfix",
|
Label: "start bugfix",
|
||||||
OnPress: startHandler("bugfix"),
|
OnPress: startHandler("bugfix"),
|
||||||
Key: 'b',
|
Key: 'b',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "start release",
|
Label: "start release",
|
||||||
OnPress: startHandler("release"),
|
OnPress: startHandler("release"),
|
||||||
Key: 'r',
|
Key: 'r',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -64,7 +64,7 @@ func (self *MergeAndRebaseHelper) CreateRebaseOptionsMenu() error {
|
|||||||
|
|
||||||
menuItems := slices.Map(options, func(row optionAndKey) *types.MenuItem {
|
menuItems := slices.Map(options, func(row optionAndKey) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayString: row.option,
|
Label: row.option,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.genericMergeCommand(row.option)
|
return self.genericMergeCommand(row.option)
|
||||||
},
|
},
|
||||||
|
@ -146,7 +146,7 @@ func (self *RefsHelper) CreateGitResetMenu(ref string) error {
|
|||||||
|
|
||||||
menuItems := slices.Map(strengths, func(row strengthWithKey) *types.MenuItem {
|
menuItems := slices.Map(strengths, func(row strengthWithKey) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
fmt.Sprintf("%s reset", row.strength),
|
fmt.Sprintf("%s reset", row.strength),
|
||||||
style.FgRed.Sprintf("reset --%s %s", row.strength, ref),
|
style.FgRed.Sprintf("reset --%s %s", row.strength, ref),
|
||||||
},
|
},
|
||||||
|
@ -26,13 +26,13 @@ func (self *TagsHelper) CreateTagMenu(commitSha string, onCreate func()) error {
|
|||||||
Title: self.c.Tr.TagMenuTitle,
|
Title: self.c.Tr.TagMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcLightweightTag,
|
Label: self.c.Tr.LcLightweightTag,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.handleCreateLightweightTag(commitSha, onCreate)
|
return self.handleCreateLightweightTag(commitSha, onCreate)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.LcAnnotatedTag,
|
Label: self.c.Tr.LcAnnotatedTag,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.handleCreateAnnotatedTag(commitSha, onCreate)
|
return self.handleCreateAnnotatedTag(commitSha, onCreate)
|
||||||
},
|
},
|
||||||
|
@ -470,7 +470,7 @@ func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
menuItems[i] = &types.MenuItem{
|
menuItems[i] = &types.MenuItem{
|
||||||
DisplayString: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
|
Label: fmt.Sprintf("%s: %s", utils.SafeTruncate(parentSha, 8), message),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
parentNumber := i + 1
|
parentNumber := i + 1
|
||||||
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
self.c.LogAction(self.c.Tr.Actions.RevertCommit)
|
||||||
@ -570,7 +570,7 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
Title: self.c.Tr.LogMenuTitle,
|
Title: self.c.Tr.LogMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.ToggleShowGitGraphAll,
|
Label: self.c.Tr.ToggleShowGitGraphAll,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
self.context().SetShowWholeGitGraph(!self.context().GetShowWholeGitGraph())
|
self.context().SetShowWholeGitGraph(!self.context().GetShowWholeGitGraph())
|
||||||
|
|
||||||
@ -586,8 +586,8 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.ShowGitGraph,
|
Label: self.c.Tr.ShowGitGraph,
|
||||||
OpensMenu: true,
|
OpensMenu: true,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
onPress := func(value string) func() error {
|
onPress := func(value string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
@ -599,24 +599,24 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
Title: self.c.Tr.LogMenuTitle,
|
Title: self.c.Tr.LogMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: "always",
|
Label: "always",
|
||||||
OnPress: onPress("always"),
|
OnPress: onPress("always"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "never",
|
Label: "never",
|
||||||
OnPress: onPress("never"),
|
OnPress: onPress("never"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "when maximised",
|
Label: "when maximised",
|
||||||
OnPress: onPress("when-maximised"),
|
OnPress: onPress("when-maximised"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: self.c.Tr.SortCommits,
|
Label: self.c.Tr.SortCommits,
|
||||||
OpensMenu: true,
|
OpensMenu: true,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
onPress := func(value string) func() error {
|
onPress := func(value string) func() error {
|
||||||
return func() error {
|
return func() error {
|
||||||
@ -636,16 +636,16 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
|
|||||||
Title: self.c.Tr.LogMenuTitle,
|
Title: self.c.Tr.LogMenuTitle,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: "topological (topo-order)",
|
Label: "topological (topo-order)",
|
||||||
OnPress: onPress("topo-order"),
|
OnPress: onPress("topo-order"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "date-order",
|
Label: "date-order",
|
||||||
OnPress: onPress("date-order"),
|
OnPress: onPress("date-order"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "author-date-order",
|
Label: "author-date-order",
|
||||||
OnPress: onPress("author-date-order"),
|
OnPress: onPress("author-date-order"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -146,7 +146,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
|||||||
Title: self.c.Tr.LcBulkSubmoduleOptions,
|
Title: self.c.Tr.LcBulkSubmoduleOptions,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{self.c.Tr.LcBulkInitSubmodules, style.FgGreen.Sprint(self.git.Submodule.BulkInitCmdObj().ToString())},
|
LabelColumns: []string{self.c.Tr.LcBulkInitSubmodules, style.FgGreen.Sprint(self.git.Submodule.BulkInitCmdObj().ToString())},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BulkInitialiseSubmodules)
|
self.c.LogAction(self.c.Tr.Actions.BulkInitialiseSubmodules)
|
||||||
@ -161,7 +161,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
|||||||
Key: 'i',
|
Key: 'i',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())},
|
LabelColumns: []string{self.c.Tr.LcBulkUpdateSubmodules, style.FgYellow.Sprint(self.git.Submodule.BulkUpdateCmdObj().ToString())},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BulkUpdateSubmodules)
|
self.c.LogAction(self.c.Tr.Actions.BulkUpdateSubmodules)
|
||||||
@ -175,7 +175,7 @@ func (self *SubmodulesController) openBulkActionsMenu() error {
|
|||||||
Key: 'u',
|
Key: 'u',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())},
|
LabelColumns: []string{self.c.Tr.LcBulkDeinitSubmodules, style.FgRed.Sprint(self.git.Submodule.BulkDeinitCmdObj().ToString())},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
return self.c.WithWaitingStatus(self.c.Tr.LcRunningCommand, func() error {
|
||||||
self.c.LogAction(self.c.Tr.Actions.BulkDeinitialiseSubmodules)
|
self.c.LogAction(self.c.Tr.Actions.BulkDeinitialiseSubmodules)
|
||||||
|
@ -19,7 +19,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
|
|
||||||
menuItems := []*types.MenuItem{
|
menuItems := []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
self.c.Tr.LcDiscardAllChangesToAllFiles,
|
self.c.Tr.LcDiscardAllChangesToAllFiles,
|
||||||
red.Sprint(nukeStr),
|
red.Sprint(nukeStr),
|
||||||
},
|
},
|
||||||
@ -35,7 +35,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
Tooltip: self.c.Tr.NukeDescription,
|
Tooltip: self.c.Tr.NukeDescription,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
self.c.Tr.LcDiscardAnyUnstagedChanges,
|
self.c.Tr.LcDiscardAnyUnstagedChanges,
|
||||||
red.Sprint("git checkout -- ."),
|
red.Sprint("git checkout -- ."),
|
||||||
},
|
},
|
||||||
@ -50,7 +50,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
Key: 'u',
|
Key: 'u',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
self.c.Tr.LcDiscardUntrackedFiles,
|
self.c.Tr.LcDiscardUntrackedFiles,
|
||||||
red.Sprint("git clean -fd"),
|
red.Sprint("git clean -fd"),
|
||||||
},
|
},
|
||||||
@ -65,7 +65,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
Key: 'c',
|
Key: 'c',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
self.c.Tr.LcSoftReset,
|
self.c.Tr.LcSoftReset,
|
||||||
red.Sprint("git reset --soft HEAD"),
|
red.Sprint("git reset --soft HEAD"),
|
||||||
},
|
},
|
||||||
@ -80,7 +80,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
Key: 's',
|
Key: 's',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
"mixed reset",
|
"mixed reset",
|
||||||
red.Sprint("git reset --mixed HEAD"),
|
red.Sprint("git reset --mixed HEAD"),
|
||||||
},
|
},
|
||||||
@ -95,7 +95,7 @@ func (self *FilesController) createResetMenu() error {
|
|||||||
Key: 'm',
|
Key: 'm',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
self.c.Tr.LcHardReset,
|
self.c.Tr.LcHardReset,
|
||||||
red.Sprint("git reset --hard HEAD"),
|
red.Sprint("git reset --hard HEAD"),
|
||||||
},
|
},
|
||||||
|
@ -112,7 +112,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel() error {
|
|||||||
name := name
|
name := name
|
||||||
menuItems = append(menuItems, []*types.MenuItem{
|
menuItems = append(menuItems, []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf("%s %s", gui.c.Tr.LcDiff, name),
|
Label: fmt.Sprintf("%s %s", gui.c.Tr.LcDiff, name),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
gui.State.Modes.Diffing.Ref = name
|
gui.State.Modes.Diffing.Ref = name
|
||||||
// can scope this down based on current view but too lazy right now
|
// can scope this down based on current view but too lazy right now
|
||||||
@ -124,7 +124,7 @@ func (gui *Gui) handleCreateDiffingMenuPanel() error {
|
|||||||
|
|
||||||
menuItems = append(menuItems, []*types.MenuItem{
|
menuItems = append(menuItems, []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: gui.c.Tr.LcEnterRefToDiff,
|
Label: gui.c.Tr.LcEnterRefToDiff,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return gui.c.Prompt(types.PromptOpts{
|
return gui.c.Prompt(types.PromptOpts{
|
||||||
Title: gui.c.Tr.LcEnteRefName,
|
Title: gui.c.Tr.LcEnteRefName,
|
||||||
@ -141,14 +141,14 @@ func (gui *Gui) handleCreateDiffingMenuPanel() error {
|
|||||||
if gui.State.Modes.Diffing.Active() {
|
if gui.State.Modes.Diffing.Active() {
|
||||||
menuItems = append(menuItems, []*types.MenuItem{
|
menuItems = append(menuItems, []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: gui.c.Tr.LcSwapDiff,
|
Label: gui.c.Tr.LcSwapDiff,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
gui.State.Modes.Diffing.Reverse = !gui.State.Modes.Diffing.Reverse
|
gui.State.Modes.Diffing.Reverse = !gui.State.Modes.Diffing.Reverse
|
||||||
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: gui.c.Tr.LcExitDiffMode,
|
Label: gui.c.Tr.LcExitDiffMode,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
gui.State.Modes.Diffing = diffing.New()
|
gui.State.Modes.Diffing = diffing.New()
|
||||||
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||||
|
@ -13,7 +13,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
Title: gui.c.Tr.CommandLog,
|
Title: gui.c.Tr.CommandLog,
|
||||||
Items: []*types.MenuItem{
|
Items: []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: gui.c.Tr.ToggleShowCommandLog,
|
Label: gui.c.Tr.ToggleShowCommandLog,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
currentContext := gui.currentStaticContext()
|
currentContext := gui.currentStaticContext()
|
||||||
if gui.ShowExtrasWindow && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY {
|
if gui.ShowExtrasWindow && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY {
|
||||||
@ -29,8 +29,8 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: gui.c.Tr.FocusCommandLog,
|
Label: gui.c.Tr.FocusCommandLog,
|
||||||
OnPress: gui.handleFocusCommandLog,
|
OnPress: gui.handleFocusCommandLog,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -26,7 +26,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel() error {
|
|||||||
|
|
||||||
if fileName != "" {
|
if fileName != "" {
|
||||||
menuItems = append(menuItems, &types.MenuItem{
|
menuItems = append(menuItems, &types.MenuItem{
|
||||||
DisplayString: fmt.Sprintf("%s '%s'", gui.c.Tr.LcFilterBy, fileName),
|
Label: fmt.Sprintf("%s '%s'", gui.c.Tr.LcFilterBy, fileName),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return gui.setFiltering(fileName)
|
return gui.setFiltering(fileName)
|
||||||
},
|
},
|
||||||
@ -34,7 +34,7 @@ func (gui *Gui) handleCreateFilteringMenuPanel() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
menuItems = append(menuItems, &types.MenuItem{
|
menuItems = append(menuItems, &types.MenuItem{
|
||||||
DisplayString: gui.c.Tr.LcFilterPathOption,
|
Label: gui.c.Tr.LcFilterPathOption,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return gui.c.Prompt(types.PromptOpts{
|
return gui.c.Prompt(types.PromptOpts{
|
||||||
FindSuggestionsFunc: gui.helpers.Suggestions.GetFilePathSuggestionsFunc(),
|
FindSuggestionsFunc: gui.helpers.Suggestions.GetFilePathSuggestionsFunc(),
|
||||||
@ -48,8 +48,8 @@ func (gui *Gui) handleCreateFilteringMenuPanel() error {
|
|||||||
|
|
||||||
if gui.State.Modes.Filtering.Active() {
|
if gui.State.Modes.Filtering.Active() {
|
||||||
menuItems = append(menuItems, &types.MenuItem{
|
menuItems = append(menuItems, &types.MenuItem{
|
||||||
DisplayString: gui.c.Tr.LcExitFilterMode,
|
Label: gui.c.Tr.LcExitFilterMode,
|
||||||
OnPress: gui.clearFiltering,
|
OnPress: gui.clearFiltering,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||||||
if !opts.HideCancel {
|
if !opts.HideCancel {
|
||||||
// this is mutative but I'm okay with that for now
|
// this is mutative but I'm okay with that for now
|
||||||
opts.Items = append(opts.Items, &types.MenuItem{
|
opts.Items = append(opts.Items, &types.MenuItem{
|
||||||
DisplayStrings: []string{gui.c.Tr.LcCancel},
|
LabelColumns: []string{gui.c.Tr.LcCancel},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@ -31,7 +31,7 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, item := range opts.Items {
|
for _, item := range opts.Items {
|
||||||
if item.OpensMenu && item.DisplayStrings != nil {
|
if item.OpensMenu && item.LabelColumns != nil {
|
||||||
return errors.New("Message for the developer of this app: you've set opensMenu with displaystrings on the menu panel. Bad developer!. Apologies, user")
|
return errors.New("Message for the developer of this app: you've set opensMenu with displaystrings on the menu panel. Bad developer!. Apologies, user")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ func (gui *Gui) handleCreateOptionsMenu() error {
|
|||||||
|
|
||||||
menuItems := slices.Map(bindings, func(binding *types.Binding) *types.MenuItem {
|
menuItems := slices.Map(bindings, func(binding *types.Binding) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayString: gui.displayDescription(binding),
|
Label: gui.displayDescription(binding),
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
if binding.Key == nil {
|
if binding.Key == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -15,38 +15,38 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
|||||||
|
|
||||||
menuItems := []*types.MenuItem{
|
menuItems := []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: "reset patch",
|
Label: "reset patch",
|
||||||
OnPress: gui.handleResetPatch,
|
OnPress: gui.handleResetPatch,
|
||||||
Key: 'c',
|
Key: 'c',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "apply patch",
|
Label: "apply patch",
|
||||||
OnPress: func() error { return gui.handleApplyPatch(false) },
|
OnPress: func() error { return gui.handleApplyPatch(false) },
|
||||||
Key: 'a',
|
Key: 'a',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "apply patch in reverse",
|
Label: "apply patch in reverse",
|
||||||
OnPress: func() error { return gui.handleApplyPatch(true) },
|
OnPress: func() error { return gui.handleApplyPatch(true) },
|
||||||
Key: 'r',
|
Key: 'r',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if gui.git.Patch.PatchManager.CanRebase && gui.git.Status.WorkingTreeState() == enums.REBASE_MODE_NONE {
|
if gui.git.Patch.PatchManager.CanRebase && gui.git.Status.WorkingTreeState() == enums.REBASE_MODE_NONE {
|
||||||
menuItems = append(menuItems, []*types.MenuItem{
|
menuItems = append(menuItems, []*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf("remove patch from original commit (%s)", gui.git.Patch.PatchManager.To),
|
Label: fmt.Sprintf("remove patch from original commit (%s)", gui.git.Patch.PatchManager.To),
|
||||||
OnPress: gui.handleDeletePatchFromCommit,
|
OnPress: gui.handleDeletePatchFromCommit,
|
||||||
Key: 'd',
|
Key: 'd',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "move patch out into index",
|
Label: "move patch out into index",
|
||||||
OnPress: gui.handleMovePatchIntoWorkingTree,
|
OnPress: gui.handleMovePatchIntoWorkingTree,
|
||||||
Key: 'i',
|
Key: 'i',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DisplayString: "move patch into new commit",
|
Label: "move patch into new commit",
|
||||||
OnPress: gui.handlePullPatchIntoNewCommit,
|
OnPress: gui.handlePullPatchIntoNewCommit,
|
||||||
Key: 'n',
|
Key: 'n',
|
||||||
},
|
},
|
||||||
}...)
|
}...)
|
||||||
|
|
||||||
@ -59,9 +59,9 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
|||||||
append(
|
append(
|
||||||
[]*types.MenuItem{
|
[]*types.MenuItem{
|
||||||
{
|
{
|
||||||
DisplayString: fmt.Sprintf("move patch to selected commit (%s)", selectedCommit.Sha),
|
Label: fmt.Sprintf("move patch to selected commit (%s)", selectedCommit.Sha),
|
||||||
OnPress: gui.handleMovePatchToSelectedCommit,
|
OnPress: gui.handleMovePatchToSelectedCommit,
|
||||||
Key: 'm',
|
Key: 'm',
|
||||||
},
|
},
|
||||||
}, menuItems[1:]...,
|
}, menuItems[1:]...,
|
||||||
)...,
|
)...,
|
||||||
|
@ -156,7 +156,7 @@ func loadPipesets(commits []*models.Commit) [][]*graph.Pipe {
|
|||||||
// pipe sets are unique to a commit head. and a commit count. Sometimes we haven't loaded everything for that.
|
// pipe sets are unique to a commit head. and a commit count. Sometimes we haven't loaded everything for that.
|
||||||
// so let's just cache it based on that.
|
// so let's just cache it based on that.
|
||||||
getStyle := func(commit *models.Commit) style.TextStyle {
|
getStyle := func(commit *models.Commit) style.TextStyle {
|
||||||
return authors.AuthorStyle(commit.Author)
|
return authors.AuthorStyle(commit.AuthorName)
|
||||||
}
|
}
|
||||||
pipeSets = graph.GetPipeSets(commits, getStyle)
|
pipeSets = graph.GetPipeSets(commits, getStyle)
|
||||||
pipeSetCache[cacheKey] = pipeSets
|
pipeSetCache[cacheKey] = pipeSets
|
||||||
@ -288,7 +288,7 @@ func displayCommit(
|
|||||||
cols = append(
|
cols = append(
|
||||||
cols,
|
cols,
|
||||||
actionString,
|
actionString,
|
||||||
authorFunc(commit.Author),
|
authorFunc(commit.AuthorName),
|
||||||
graphLine+tagString+theme.DefaultTextColor.Sprint(name),
|
graphLine+tagString+theme.DefaultTextColor.Sprint(name),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ func TestGetNextPipes(t *testing.T) {
|
|||||||
func BenchmarkRenderCommitGraph(b *testing.B) {
|
func BenchmarkRenderCommitGraph(b *testing.B) {
|
||||||
commits := generateCommits(50)
|
commits := generateCommits(50)
|
||||||
getStyle := func(commit *models.Commit) style.TextStyle {
|
getStyle := func(commit *models.Commit) style.TextStyle {
|
||||||
return authors.AuthorStyle(commit.Author)
|
return authors.AuthorStyle(commit.AuthorName)
|
||||||
}
|
}
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
@ -538,7 +538,7 @@ func BenchmarkRenderCommitGraph(b *testing.B) {
|
|||||||
|
|
||||||
func generateCommits(count int) []*models.Commit {
|
func generateCommits(count int) []*models.Commit {
|
||||||
rand.Seed(1234)
|
rand.Seed(1234)
|
||||||
pool := []*models.Commit{{Sha: "a", Author: "A"}}
|
pool := []*models.Commit{{Sha: "a", AuthorName: "A"}}
|
||||||
commits := make([]*models.Commit, 0, count)
|
commits := make([]*models.Commit, 0, count)
|
||||||
authorPool := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
authorPool := []string{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}
|
||||||
for len(commits) < count {
|
for len(commits) < count {
|
||||||
@ -555,8 +555,8 @@ func generateCommits(count int) []*models.Commit {
|
|||||||
newParent = pool[j]
|
newParent = pool[j]
|
||||||
} else {
|
} else {
|
||||||
newParent = &models.Commit{
|
newParent = &models.Commit{
|
||||||
Sha: fmt.Sprintf("%s%d", currentCommit.Sha, j),
|
Sha: fmt.Sprintf("%s%d", currentCommit.Sha, j),
|
||||||
Author: authorPool[rand.Intn(len(authorPool))],
|
AuthorName: authorPool[rand.Intn(len(authorPool))],
|
||||||
}
|
}
|
||||||
pool = append(pool, newParent)
|
pool = append(pool, newParent)
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ func (gui *Gui) handleCreateRecentReposMenu() error {
|
|||||||
// we won't show the current repo hence the -1
|
// we won't show the current repo hence the -1
|
||||||
menuItems := slices.Map(recentRepoPaths[1:], func(path string) *types.MenuItem {
|
menuItems := slices.Map(recentRepoPaths[1:], func(path string) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayStrings: []string{
|
LabelColumns: []string{
|
||||||
filepath.Base(path),
|
filepath.Base(path),
|
||||||
style.FgMagenta.Sprint(path),
|
style.FgMagenta.Sprint(path),
|
||||||
},
|
},
|
||||||
|
@ -102,7 +102,7 @@ func (self *HandlerCreator) inputPrompt(prompt *config.CustomCommandPrompt, wrap
|
|||||||
func (self *HandlerCreator) menuPrompt(prompt *config.CustomCommandPrompt, wrappedF func(string) error) error {
|
func (self *HandlerCreator) menuPrompt(prompt *config.CustomCommandPrompt, wrappedF func(string) error) error {
|
||||||
menuItems := slices.Map(prompt.Options, func(option config.CustomCommandMenuOption) *types.MenuItem {
|
menuItems := slices.Map(prompt.Options, func(option config.CustomCommandMenuOption) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayStrings: []string{option.Name, style.FgYellow.Sprint(option.Description)},
|
LabelColumns: []string{option.Name, style.FgYellow.Sprint(option.Description)},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return wrappedF(option.Value)
|
return wrappedF(option.Value)
|
||||||
},
|
},
|
||||||
@ -127,7 +127,7 @@ func (self *HandlerCreator) menuPromptFromCommand(prompt *config.CustomCommandPr
|
|||||||
|
|
||||||
menuItems := slices.Map(candidates, func(candidate *commandMenuEntry) *types.MenuItem {
|
menuItems := slices.Map(candidates, func(candidate *commandMenuEntry) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayStrings: []string{candidate.label},
|
LabelColumns: []string{candidate.label},
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return wrappedF(candidate.value)
|
return wrappedF(candidate.value)
|
||||||
},
|
},
|
||||||
|
@ -105,7 +105,7 @@ func (gui *Gui) askForConfigFile(action func(file string) error) error {
|
|||||||
default:
|
default:
|
||||||
menuItems := slices.Map(confPaths, func(path string) *types.MenuItem {
|
menuItems := slices.Map(confPaths, func(path string) *types.MenuItem {
|
||||||
return &types.MenuItem{
|
return &types.MenuItem{
|
||||||
DisplayString: path,
|
Label: path,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return action(path)
|
return action(path)
|
||||||
},
|
},
|
||||||
|
@ -109,17 +109,21 @@ type PromptOpts struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MenuItem struct {
|
type MenuItem struct {
|
||||||
DisplayString string
|
Label string
|
||||||
DisplayStrings []string
|
|
||||||
OnPress func() error
|
// alternative to Label. Allows specifying columns which will be auto-aligned
|
||||||
// only applies when displayString is used
|
LabelColumns []string
|
||||||
|
|
||||||
|
OnPress func() error
|
||||||
|
|
||||||
|
// Only applies when Label is used
|
||||||
OpensMenu bool
|
OpensMenu bool
|
||||||
|
|
||||||
// if Key is defined it allows the user to press the key to invoke the menu
|
// If Key is defined it allows the user to press the key to invoke the menu
|
||||||
// item, as opposed to having to navigate to it
|
// item, as opposed to having to navigate to it
|
||||||
Key Key
|
Key Key
|
||||||
|
|
||||||
// the tooltip will be displayed upon highlighting the menu item
|
// The tooltip will be displayed upon highlighting the menu item
|
||||||
Tooltip string
|
Tooltip string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user