mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
@@ -995,7 +995,7 @@ func (h *BufPane) CutLine() bool {
|
|||||||
if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil {
|
if clip, err := clipboard.Read(clipboard.ClipboardReg); err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
} else {
|
} else {
|
||||||
clipboard.Write(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg)
|
clipboard.WriteMulti(clip+string(h.Cursor.GetSelection()), clipboard.ClipboardReg, h.Cursor.Num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if time.Since(h.lastCutTime)/time.Second > 10*time.Second || h.freshClip == false {
|
} else if time.Since(h.lastCutTime)/time.Second > 10*time.Second || h.freshClip == false {
|
||||||
@@ -1139,7 +1139,7 @@ func (h *BufPane) MoveLinesDown() bool {
|
|||||||
// Paste whatever is in the system clipboard into the buffer
|
// Paste whatever is in the system clipboard into the buffer
|
||||||
// Delete and paste if the user has a selection
|
// Delete and paste if the user has a selection
|
||||||
func (h *BufPane) Paste() bool {
|
func (h *BufPane) Paste() bool {
|
||||||
clip, err := clipboard.Read(clipboard.ClipboardReg)
|
clip, err := clipboard.ReadMulti(clipboard.ClipboardReg, h.Cursor.Num)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -1151,7 +1151,7 @@ func (h *BufPane) Paste() bool {
|
|||||||
|
|
||||||
// PastePrimary pastes from the primary clipboard (only use on linux)
|
// PastePrimary pastes from the primary clipboard (only use on linux)
|
||||||
func (h *BufPane) PastePrimary() bool {
|
func (h *BufPane) PastePrimary() bool {
|
||||||
clip, err := clipboard.Read(clipboard.PrimaryReg)
|
clip, err := clipboard.ReadMulti(clipboard.PrimaryReg, h.Cursor.Num)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
InfoBar.Error(err)
|
InfoBar.Error(err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ func BufMapKey(k Event, action string) {
|
|||||||
cursors := h.Buf.GetCursors()
|
cursors := h.Buf.GetCursors()
|
||||||
success := true
|
success := true
|
||||||
for i, a := range actionfns {
|
for i, a := range actionfns {
|
||||||
|
innerSuccess := true
|
||||||
for j, c := range cursors {
|
for j, c := range cursors {
|
||||||
if c == nil {
|
if c == nil {
|
||||||
continue
|
continue
|
||||||
@@ -120,13 +121,14 @@ func BufMapKey(k Event, action string) {
|
|||||||
h.Buf.SetCurCursor(c.Num)
|
h.Buf.SetCurCursor(c.Num)
|
||||||
h.Cursor = c
|
h.Cursor = c
|
||||||
if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') {
|
if i == 0 || (success && types[i-1] == '&') || (!success && types[i-1] == '|') || (types[i-1] == ',') {
|
||||||
success = h.execAction(a, names[i], j)
|
innerSuccess = innerSuccess && h.execAction(a, names[i], j)
|
||||||
} else {
|
} else {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if the action changed the current pane, update the reference
|
// if the action changed the current pane, update the reference
|
||||||
h = MainTab().CurPane()
|
h = MainTab().CurPane()
|
||||||
|
success = innerSuccess
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -689,6 +691,7 @@ var MultiActions = map[string]bool{
|
|||||||
"FindNext": true,
|
"FindNext": true,
|
||||||
"FindPrevious": true,
|
"FindPrevious": true,
|
||||||
"CopyLine": true,
|
"CopyLine": true,
|
||||||
|
"Copy": true,
|
||||||
"Cut": true,
|
"Cut": true,
|
||||||
"CutLine": true,
|
"CutLine": true,
|
||||||
"DuplicateLine": true,
|
"DuplicateLine": true,
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func (c *Cursor) End() {
|
|||||||
func (c *Cursor) CopySelection(target clipboard.Register) {
|
func (c *Cursor) CopySelection(target clipboard.Register) {
|
||||||
if c.HasSelection() {
|
if c.HasSelection() {
|
||||||
if target != clipboard.PrimaryReg || c.buf.Settings["useprimary"].(bool) {
|
if target != clipboard.PrimaryReg || c.buf.Settings["useprimary"].(bool) {
|
||||||
clipboard.Write(string(c.GetSelection()), target)
|
clipboard.WriteMulti(string(c.GetSelection()), target, c.Num)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,16 @@ func (c multiClipboard) isValid(r Register, clipboard string) bool {
|
|||||||
|
|
||||||
func (c multiClipboard) writeText(text string, r Register, num int) {
|
func (c multiClipboard) writeText(text string, r Register, num int) {
|
||||||
content := c[r]
|
content := c[r]
|
||||||
if content == nil || num >= cap(content) {
|
if content == nil {
|
||||||
content = make([]string, num+1, num+1)
|
content = make([]string, num+1, num+1)
|
||||||
|
c[r] = content
|
||||||
|
}
|
||||||
|
|
||||||
|
if num >= cap(content) {
|
||||||
|
newctnt := make([]string, num+1, num+1)
|
||||||
|
copy(newctnt, content)
|
||||||
|
content = newctnt
|
||||||
|
c[r] = content
|
||||||
}
|
}
|
||||||
|
|
||||||
content[num] = text
|
content[num] = text
|
||||||
|
|||||||
Reference in New Issue
Block a user