mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-08 04:04:22 +02:00
Added copy to clipboard option to the patch options
This commit is contained in:
parent
6127e487dd
commit
f6f82091bc
@ -3,6 +3,7 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
"github.com/jesseduffield/lazygit/pkg/commands/types/enums"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
)
|
)
|
||||||
@ -28,6 +29,11 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
|||||||
OnPress: func() error { return gui.handleApplyPatch(true) },
|
OnPress: func() error { return gui.handleApplyPatch(true) },
|
||||||
Key: 'r',
|
Key: 'r',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Label: "Copy patch to clipboard",
|
||||||
|
OnPress: func() error { return gui.copyPatchToClipbaord() },
|
||||||
|
Key: gocui.KeyCtrlO,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
@ -192,3 +198,16 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
|
|||||||
}
|
}
|
||||||
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (gui *Gui) copyPatchToClipbaord() error {
|
||||||
|
patch := gui.git.Patch.PatchManager.RenderAggregatedPatchColored(true)
|
||||||
|
|
||||||
|
gui.c.LogAction(gui.c.Tr.Actions.CopyPatchToClipboard)
|
||||||
|
if err := gui.os.CopyToClipboard(patch); err != nil {
|
||||||
|
return gui.c.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
gui.c.Toast((gui.c.Tr.Actions.CopyPatchToClipboard))
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -466,6 +466,7 @@ type TranslationSet struct {
|
|||||||
CommitURLCopiedToClipboard string
|
CommitURLCopiedToClipboard string
|
||||||
CommitMessageCopiedToClipboard string
|
CommitMessageCopiedToClipboard string
|
||||||
CommitAuthorCopiedToClipboard string
|
CommitAuthorCopiedToClipboard string
|
||||||
|
PatchCopiedToClipboard string
|
||||||
LcCopiedToClipboard string
|
LcCopiedToClipboard string
|
||||||
ErrCannotEditDirectory string
|
ErrCannotEditDirectory string
|
||||||
ErrStageDirWithInlineMergeConflicts string
|
ErrStageDirWithInlineMergeConflicts string
|
||||||
@ -569,6 +570,7 @@ type Actions struct {
|
|||||||
CopyCommitURLToClipboard string
|
CopyCommitURLToClipboard string
|
||||||
CopyCommitAuthorToClipboard string
|
CopyCommitAuthorToClipboard string
|
||||||
CopyCommitAttributeToClipboard string
|
CopyCommitAttributeToClipboard string
|
||||||
|
CopyPatchToClipboard string
|
||||||
CustomCommand string
|
CustomCommand string
|
||||||
DiscardAllChangesInDirectory string
|
DiscardAllChangesInDirectory string
|
||||||
DiscardUnstagedChangesInDirectory string
|
DiscardUnstagedChangesInDirectory string
|
||||||
@ -1117,6 +1119,7 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
CommitURLCopiedToClipboard: "Commit URL copied to clipboard",
|
CommitURLCopiedToClipboard: "Commit URL copied to clipboard",
|
||||||
CommitMessageCopiedToClipboard: "Commit message copied to clipboard",
|
CommitMessageCopiedToClipboard: "Commit message copied to clipboard",
|
||||||
CommitAuthorCopiedToClipboard: "Commit author copied to clipboard",
|
CommitAuthorCopiedToClipboard: "Commit author copied to clipboard",
|
||||||
|
PatchCopiedToClipboard: "Patch copied to clipboard",
|
||||||
LcCopiedToClipboard: "copied to clipboard",
|
LcCopiedToClipboard: "copied to clipboard",
|
||||||
ErrCannotEditDirectory: "Cannot edit directory: you can only edit individual files",
|
ErrCannotEditDirectory: "Cannot edit directory: you can only edit individual files",
|
||||||
ErrStageDirWithInlineMergeConflicts: "Cannot stage/unstage directory containing files with inline merge conflicts. Please fix up the merge conflicts first",
|
ErrStageDirWithInlineMergeConflicts: "Cannot stage/unstage directory containing files with inline merge conflicts. Please fix up the merge conflicts first",
|
||||||
@ -1201,6 +1204,7 @@ func EnglishTranslationSet() TranslationSet {
|
|||||||
CopyCommitURLToClipboard: "Copy commit URL to clipboard",
|
CopyCommitURLToClipboard: "Copy commit URL to clipboard",
|
||||||
CopyCommitAuthorToClipboard: "Copy commit author to clipboard",
|
CopyCommitAuthorToClipboard: "Copy commit author to clipboard",
|
||||||
CopyCommitAttributeToClipboard: "Copy to clipboard",
|
CopyCommitAttributeToClipboard: "Copy to clipboard",
|
||||||
|
CopyPatchToClipboard: "Copy patch to clipboard",
|
||||||
MoveCommitUp: "Move commit up",
|
MoveCommitUp: "Move commit up",
|
||||||
MoveCommitDown: "Move commit down",
|
MoveCommitDown: "Move commit down",
|
||||||
CustomCommand: "Custom command",
|
CustomCommand: "Custom command",
|
||||||
|
Loading…
Reference in New Issue
Block a user