This commit is contained in:
Mark Zaytsev 2025-06-03 14:25:57 +07:00 committed by GitHub
commit 179313c41f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 38 additions and 9 deletions

View File

@ -1394,11 +1394,37 @@ func (h *BufPane) Cut() bool {
// CutLine cuts the current line to the clipboard. If there is a selection,
// CutLine cuts all the lines that are (fully or partially) in the selection.
// CutLine will replace the clipboard's current buffer.
func (h *BufPane) CutLine() bool {
totalLines := h.selectLines()
if totalLines == 0 {
return false
}
h.Cursor.CopySelection(clipboard.ClipboardReg)
h.freshClip = true
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
h.Cursor.StoreVisualX()
if totalLines > 1 {
InfoBar.Message(fmt.Sprintf("Cut %d lines", totalLines))
} else {
InfoBar.Message("Cut line")
}
h.Relocate()
return true
}
// CutLineAppend cuts the current line to the clipboard. If there is a selection,
// CutLineAppend cuts all the lines that are (fully or partially) in the selection.
// CutLineAppend will append the selection to the clipboard's buffer.
func (h *BufPane) CutLineAppend() bool {
nlines := h.selectLines()
if nlines == 0 {
return false
}
totalLines := nlines
if h.freshClip {
if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil {
@ -1411,15 +1437,17 @@ func (h *BufPane) CutLine() bool {
} else {
h.Cursor.CopySelection(clipboard.ClipboardReg)
}
h.freshClip = true
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
h.Cursor.StoreVisualX()
if totalLines > 1 {
InfoBar.Message(fmt.Sprintf("Cut %d lines", totalLines))
if nlines > 1 {
InfoBar.Message(fmt.Sprintf("Cut %d lines. Total lines in buffer: %d.", nlines, totalLines))
} else {
InfoBar.Message("Cut line")
InfoBar.Message(fmt.Sprintf("Cut line. Total lines in buffer: %d.", totalLines))
}
h.Relocate()
return true
}

View File

@ -781,6 +781,7 @@ var BufKeyActions = map[string]BufKeyAction{
"CopyLine": (*BufPane).CopyLine,
"Cut": (*BufPane).Cut,
"CutLine": (*BufPane).CutLine,
"CutLineAppend": (*BufPane).CutLineAppend,
"Duplicate": (*BufPane).Duplicate,
"DuplicateLine": (*BufPane).DuplicateLine,
"DeleteLine": (*BufPane).DeleteLine,

View File

@ -47,7 +47,7 @@ var bufdefaults = map[string]string{
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
@ -148,7 +148,7 @@ var infodefaults = map[string]string{
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",
"End": "EndOfLine",

View File

@ -50,7 +50,7 @@ var bufdefaults = map[string]string{
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
@ -151,7 +151,7 @@ var infodefaults = map[string]string{
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",
"End": "EndOfLine",

View File

@ -524,7 +524,7 @@ conventions for text editing defaults.
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-d": "Duplicate|DuplicateLine",
"Ctrl-v": "Paste",
"Ctrl-a": "SelectAll",
@ -650,7 +650,7 @@ are given below:
"Ctrl-y": "Redo",
"Ctrl-c": "Copy|CopyLine",
"Ctrl-x": "Cut|CutLine",
"Ctrl-k": "CutLine",
"Ctrl-k": "CutLineAppend",
"Ctrl-v": "Paste",
"Home": "StartOfTextToggle",
"End": "EndOfLine",