]> git.lizzy.rs Git - micro.git/commitdiff
Adds CopyLine action, the new default action for CtrlC if cursor has no selection
authorJeff Warner <jeff@develops.software>
Thu, 30 Apr 2020 04:06:54 +0000 (21:06 -0700)
committerJeff Warner <jeff@develops.software>
Thu, 30 Apr 2020 04:06:54 +0000 (21:06 -0700)
internal/action/actions.go
internal/action/bufpane.go
internal/action/defaults_darwin.go
internal/action/defaults_other.go
runtime/help/keybindings.md

index fd363281560513910c2009eb55b1ed77af413cbc..79ce8cf34e1b7eb7daaaf933509b282cc5902385 100644 (file)
@@ -930,6 +930,25 @@ func (h *BufPane) Copy() bool {
        return true
 }
 
+// Copy the current line to the clipboard
+func (h *BufPane) CopyLine() bool {
+    if h.Cursor.HasSelection() {
+       return false
+    } else {
+       h.Cursor.SelectLine()
+       h.Cursor.CopySelection("clipboard")
+       h.freshClip = true
+       if clipboard.Unsupported {
+               InfoBar.Message("Copied line (install xclip for external clipboard)")
+       } else {
+               InfoBar.Message("Copied line")
+       }
+    }
+    h.Cursor.Deselect(true)
+    h.Relocate()
+    return true
+}
+
 // CutLine cuts the current line to the clipboard
 func (h *BufPane) CutLine() bool {
        h.Cursor.SelectLine()
index 31e53e32c0ca38ab4a9b7ca2b8e1e9d82dc9509b..e60ead55a5efe7511339df2e5ecb399499a2407f 100644 (file)
@@ -558,6 +558,7 @@ var BufKeyActions = map[string]BufKeyAction{
        "Undo":                     (*BufPane).Undo,
        "Redo":                     (*BufPane).Redo,
        "Copy":                     (*BufPane).Copy,
+       "CopyLine":                 (*BufPane).CopyLine,
        "Cut":                      (*BufPane).Cut,
        "CutLine":                  (*BufPane).CutLine,
        "DuplicateLine":            (*BufPane).DuplicateLine,
@@ -669,6 +670,7 @@ var MultiActions = map[string]bool{
        "InsertTab":                 true,
        "FindNext":                  true,
        "FindPrevious":              true,
+       "CopyLine":                  true,
        "Cut":                       true,
        "CutLine":                   true,
        "DuplicateLine":             true,
index 89f03290114b44b06ff2e2fd1dda4ff6cb32439b..b80e07d770a64bf60151cccba5d9776a7aab33bb 100644 (file)
@@ -43,7 +43,7 @@ func DefaultBindings() map[string]string {
                "CtrlP":          "FindPrevious",
                "CtrlZ":          "Undo",
                "CtrlY":          "Redo",
-               "CtrlC":          "Copy",
+               "CtrlC":          "CopyLine|Copy",
                "CtrlX":          "Cut",
                "CtrlK":          "CutLine",
                "CtrlD":          "DuplicateLine",
index e63c1ee1284dc4f817fdc8dd87b3d4ab85220412..fca4a8d7ca80bcab8851d7b4f462db2291180255 100644 (file)
@@ -45,7 +45,7 @@ func DefaultBindings() map[string]string {
                "CtrlP":          "FindPrevious",
                "CtrlZ":          "Undo",
                "CtrlY":          "Redo",
-               "CtrlC":          "Copy",
+               "CtrlC":          "CopyLine|Copy",
                "CtrlX":          "Cut",
                "CtrlK":          "CutLine",
                "CtrlD":          "DuplicateLine",
index f303e8a280ad9eb091cfdcdc1fab9cc01235e008..b8f67064edde8e3fae9c4e3047471e6bae3aefa3 100644 (file)
@@ -190,6 +190,7 @@ FindPrevious
 Undo
 Redo
 Copy
+CopyLine
 Cut
 CutLine
 DuplicateLine
@@ -455,7 +456,7 @@ conventions for text editing defaults.
     "CtrlP":          "FindPrevious",
     "CtrlZ":          "Undo",
     "CtrlY":          "Redo",
-    "CtrlC":          "Copy",
+    "CtrlC":          "CopyLine|Copy",
     "CtrlX":          "Cut",
     "CtrlK":          "CutLine",
     "CtrlD":          "DuplicateLine",