mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-05 22:50:21 +09:00
Merge branch 'duplicate' of https://github.com/onodera-punpun/micro into onodera-punpun-duplicate
This commit is contained in:
@@ -58,6 +58,7 @@ func InitBindings() {
|
||||
"Copy": (*View).Copy,
|
||||
"Cut": (*View).Cut,
|
||||
"CutLine": (*View).CutLine,
|
||||
"DuplicateLine": (*View).DuplicateLine,
|
||||
"Paste": (*View).Paste,
|
||||
"SelectAll": (*View).SelectAll,
|
||||
"OpenFile": (*View).OpenFile,
|
||||
@@ -284,18 +285,20 @@ func DefaultBindings() map[string]string {
|
||||
"CtrlC": "Copy",
|
||||
"CtrlX": "Cut",
|
||||
"CtrlK": "CutLine",
|
||||
"CtrlD": "DuplicateLine",
|
||||
"CtrlV": "Paste",
|
||||
"CtrlA": "SelectAll",
|
||||
"Home": "Start",
|
||||
"End": "End",
|
||||
"PgUp": "PageUp",
|
||||
"PgDn": "PageDown",
|
||||
"CtrlU": "HalfPageUp",
|
||||
"CtrlD": "HalfPageDown",
|
||||
"CtrlR": "ToggleRuler",
|
||||
"CtrlL": "JumpLine",
|
||||
"Delete": "Delete",
|
||||
"Esc": "ClearStatus",
|
||||
// Find alternative key
|
||||
// "CtrlU": "HalfPageUp",
|
||||
// "CtrlD": "HalfPageDown",
|
||||
"CtrlR": "ToggleRuler",
|
||||
"CtrlL": "JumpLine",
|
||||
"Delete": "Delete",
|
||||
"Esc": "ClearStatus",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,12 +664,14 @@ func (v *View) FindPrevious() bool {
|
||||
// Undo undoes the last action
|
||||
func (v *View) Undo() bool {
|
||||
v.eh.Undo()
|
||||
messenger.Message("Undid action")
|
||||
return true
|
||||
}
|
||||
|
||||
// Redo redoes the last action
|
||||
func (v *View) Redo() bool {
|
||||
v.eh.Redo()
|
||||
messenger.Message("Redid action")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -675,7 +680,7 @@ func (v *View) Copy() bool {
|
||||
if v.Cursor.HasSelection() {
|
||||
clipboard.WriteAll(v.Cursor.GetSelection())
|
||||
v.freshClip = true
|
||||
messenger.Message("Copied selection to clipboard")
|
||||
messenger.Message("Copied selection")
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -684,7 +689,6 @@ func (v *View) Copy() bool {
|
||||
func (v *View) CutLine() bool {
|
||||
v.Cursor.SelectLine()
|
||||
if v.freshClip == true {
|
||||
|
||||
if v.Cursor.HasSelection() {
|
||||
if clip, err := clipboard.ReadAll(); err != nil {
|
||||
messenger.Error(err)
|
||||
@@ -699,6 +703,7 @@ func (v *View) CutLine() bool {
|
||||
v.lastCutTime = time.Now()
|
||||
v.Cursor.DeleteSelection()
|
||||
v.Cursor.ResetSelection()
|
||||
messenger.Message("Cut line")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -709,10 +714,20 @@ func (v *View) Cut() bool {
|
||||
v.Cursor.DeleteSelection()
|
||||
v.Cursor.ResetSelection()
|
||||
v.freshClip = true
|
||||
messenger.Message("Cut selection")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// DuplicateLine duplicates the current line
|
||||
func (v *View) DuplicateLine() bool {
|
||||
v.Cursor.End()
|
||||
v.eh.Insert(v.Cursor.Loc(), "\n"+v.Buf.Lines[v.Cursor.y])
|
||||
v.Cursor.Right()
|
||||
messenger.Message("Duplicated line")
|
||||
return true
|
||||
}
|
||||
|
||||
// Paste whatever is in the system clipboard into the buffer
|
||||
// Delete and paste if the user has a selection
|
||||
func (v *View) Paste() bool {
|
||||
@@ -724,6 +739,7 @@ func (v *View) Paste() bool {
|
||||
v.eh.Insert(v.Cursor.Loc(), clip)
|
||||
v.Cursor.SetLoc(v.Cursor.Loc() + Count(clip))
|
||||
v.freshClip = false
|
||||
messenger.Message("Pasted clipboard")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -820,8 +836,10 @@ func (v *View) HalfPageDown() bool {
|
||||
func (v *View) ToggleRuler() bool {
|
||||
if settings["ruler"] == false {
|
||||
settings["ruler"] = true
|
||||
messenger.Message("Enabled ruler")
|
||||
} else {
|
||||
settings["ruler"] = false
|
||||
messenger.Message("Disabled ruler")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -41,9 +41,8 @@ These are the default keybindings, along with their actions.
|
||||
* Ctrl-c: Copy
|
||||
* Ctrl-x: Cut
|
||||
* Ctrl-k: Cut line
|
||||
* Ctrl-d: Duplicate line
|
||||
* Ctrl-v: Paste
|
||||
* Ctrl-u: Half page up
|
||||
* Ctrl-d: Half page down
|
||||
* PageUp: Page up
|
||||
* PageDown: Page down
|
||||
* Home: Go to beginning of line
|
||||
@@ -108,6 +107,7 @@ Here are the defaults:
|
||||
"CtrlC": "Copy",
|
||||
"CtrlX": "Cut",
|
||||
"CtrlK": "CutLine",
|
||||
"CtrlD": "DuplicateLine",
|
||||
"CtrlV": "Paste",
|
||||
"CtrlA": "SelectAll",
|
||||
"Home": "Start",
|
||||
|
||||
Reference in New Issue
Block a user