mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-28 16:02:01 +03:00
minor changes
This commit is contained in:
@ -546,7 +546,9 @@ func RunLineOutputCmd(cmd *exec.Cmd, onLine func(line string) (bool, error)) err
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *OSCommand) CopyToClipboard(str string) error {
|
func (c *OSCommand) CopyToClipboard(str string) error {
|
||||||
c.LogCommand(fmt.Sprintf("Copying '%s' to clipboard", utils.TruncateWithEllipsis(str, 40)), false)
|
escaped := strings.Replace(str, "\n", "\\n", -1)
|
||||||
|
truncated := utils.TruncateWithEllipsis(escaped, 40)
|
||||||
|
c.LogCommand(fmt.Sprintf("Copying '%s' to clipboard", truncated), false)
|
||||||
return clipboard.WriteAll(str)
|
return clipboard.WriteAll(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,20 +194,17 @@ func (p *PatchParser) Render(firstLineIndex int, lastLineIndex int, incLineIndic
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderLines returns the coloured string of diff part from firstLineIndex to
|
// PlainRenderLines returns the non-coloured string of diff part from firstLineIndex to
|
||||||
// lastLineIndex
|
// lastLineIndex
|
||||||
func (p *PatchParser) RenderLines(firstLineIndex, lastLineIndex int) string {
|
func (p *PatchParser) PlainRenderLines(firstLineIndex, lastLineIndex int) string {
|
||||||
renderedLines := make([]string, lastLineIndex-firstLineIndex+1)
|
linesToCopy := p.PatchLines[firstLineIndex : lastLineIndex+1]
|
||||||
for index := firstLineIndex; index <= lastLineIndex; index++ {
|
|
||||||
renderedLines[index-firstLineIndex] = p.PatchLines[index].render(
|
renderedLines := make([]string, len(linesToCopy))
|
||||||
false, false,
|
for index, line := range linesToCopy {
|
||||||
)
|
renderedLines[index] = line.Content
|
||||||
}
|
}
|
||||||
result := strings.Join(renderedLines, "\n")
|
|
||||||
if strings.TrimSpace(utils.Decolorise(result)) == "" {
|
return strings.Join(renderedLines, "\n")
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line
|
// GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line
|
||||||
|
@ -1309,6 +1309,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
|
|||||||
Key: gui.getKey(config.Universal.CopyToClipboard),
|
Key: gui.getKey(config.Universal.CopyToClipboard),
|
||||||
Modifier: gocui.ModNone,
|
Modifier: gocui.ModNone,
|
||||||
Handler: gui.copySelectedToClipboard,
|
Handler: gui.copySelectedToClipboard,
|
||||||
|
Description: gui.Tr.LcCopySelectedTexToClipboard,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ViewName: "main",
|
ViewName: "main",
|
||||||
|
@ -180,9 +180,9 @@ func (s *State) RenderForLineIndices(includedLineIndices []int) string {
|
|||||||
return s.patchParser.Render(firstLineIdx, lastLineIdx, includedLineIndices)
|
return s.patchParser.Render(firstLineIdx, lastLineIdx, includedLineIndices)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) RenderSelected() string {
|
func (s *State) PlainRenderSelected() string {
|
||||||
firstLineIdx, lastLineIdx := s.SelectedRange()
|
firstLineIdx, lastLineIdx := s.SelectedRange()
|
||||||
return s.patchParser.RenderLines(firstLineIdx, lastLineIdx)
|
return s.patchParser.PlainRenderLines(firstLineIdx, lastLineIdx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *State) SelectBottom() {
|
func (s *State) SelectBottom() {
|
||||||
|
@ -2,13 +2,11 @@ package gui
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
"github.com/jesseduffield/lazygit/pkg/commands/patch"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/lbl"
|
"github.com/jesseduffield/lazygit/pkg/gui/lbl"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Currently there are two 'pseudo-panels' that make use of this 'pseudo-panel'.
|
// Currently there are two 'pseudo-panels' that make use of this 'pseudo-panel'.
|
||||||
@ -90,9 +88,7 @@ func (gui *Gui) handleSelectNextHunk() error {
|
|||||||
|
|
||||||
func (gui *Gui) copySelectedToClipboard() error {
|
func (gui *Gui) copySelectedToClipboard() error {
|
||||||
return gui.withLBLActiveCheck(func(state *LblPanelState) error {
|
return gui.withLBLActiveCheck(func(state *LblPanelState) error {
|
||||||
|
selected := state.PlainRenderSelected()
|
||||||
colorSelected := state.RenderSelected()
|
|
||||||
selected := strings.TrimSpace(utils.Decolorise(colorSelected))
|
|
||||||
|
|
||||||
if err := gui.OSCommand.WithSpan(
|
if err := gui.OSCommand.WithSpan(
|
||||||
gui.Tr.Spans.CopySelectedTextToClipboard,
|
gui.Tr.Spans.CopySelectedTextToClipboard,
|
||||||
|
@ -361,6 +361,7 @@ type TranslationSet struct {
|
|||||||
LcCopyFileNameToClipboard string
|
LcCopyFileNameToClipboard string
|
||||||
LcCopyCommitFileNameToClipboard string
|
LcCopyCommitFileNameToClipboard string
|
||||||
LcCommitPrefixPatternError string
|
LcCommitPrefixPatternError string
|
||||||
|
LcCopySelectedTexToClipboard string
|
||||||
NoFilesStagedTitle string
|
NoFilesStagedTitle string
|
||||||
NoFilesStagedPrompt string
|
NoFilesStagedPrompt string
|
||||||
BranchNotFoundTitle string
|
BranchNotFoundTitle string
|
||||||
@ -883,6 +884,7 @@ func englishTranslationSet() TranslationSet {
|
|||||||
LcCopyBranchNameToClipboard: "copy branch name to clipboard",
|
LcCopyBranchNameToClipboard: "copy branch name to clipboard",
|
||||||
LcCopyFileNameToClipboard: "copy the file name to the clipboard",
|
LcCopyFileNameToClipboard: "copy the file name to the clipboard",
|
||||||
LcCopyCommitFileNameToClipboard: "copy the committed file name to the clipboard",
|
LcCopyCommitFileNameToClipboard: "copy the committed file name to the clipboard",
|
||||||
|
LcCopySelectedTexToClipboard: "copy the selected text to the clipboard",
|
||||||
LcCommitPrefixPatternError: "Error in commitPrefix pattern",
|
LcCommitPrefixPatternError: "Error in commitPrefix pattern",
|
||||||
NoFilesStagedTitle: "No files staged",
|
NoFilesStagedTitle: "No files staged",
|
||||||
NoFilesStagedPrompt: "You have not staged any files. Commit all files?",
|
NoFilesStagedPrompt: "You have not staged any files. Commit all files?",
|
||||||
@ -1000,7 +1002,7 @@ func englishTranslationSet() TranslationSet {
|
|||||||
GitFlowFinish: "Git flow finish",
|
GitFlowFinish: "Git flow finish",
|
||||||
GitFlowStart: "Git Flow start",
|
GitFlowStart: "Git Flow start",
|
||||||
CopyToClipboard: "Copy to clipboard",
|
CopyToClipboard: "Copy to clipboard",
|
||||||
CopySelectedTextToClipboard: "Copy Selected Text to clipboard",
|
CopySelectedTextToClipboard: "Copy selected text to clipboard",
|
||||||
RemovePatchFromCommit: "Remove patch from commit",
|
RemovePatchFromCommit: "Remove patch from commit",
|
||||||
MovePatchToSelectedCommit: "Move patch to selected commit",
|
MovePatchToSelectedCommit: "Move patch to selected commit",
|
||||||
MovePatchIntoIndex: "Move patch into index",
|
MovePatchIntoIndex: "Move patch into index",
|
||||||
|
Reference in New Issue
Block a user