From bd0fa7b6c21f40ab3fa96e36bcbc4a9e40933ed2 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Tue, 7 Jun 2016 21:47:34 -0400 Subject: [PATCH] Add DeleteLine binding Ref #135 --- cmd/micro/bindings.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/micro/bindings.go b/cmd/micro/bindings.go index 89cd2702..c97c96e0 100644 --- a/cmd/micro/bindings.go +++ b/cmd/micro/bindings.go @@ -54,6 +54,7 @@ var bindingActions = map[string]func(*View) bool{ "Cut": (*View).Cut, "CutLine": (*View).CutLine, "DuplicateLine": (*View).DuplicateLine, + "DeleteLine": (*View).DeleteLine, "Paste": (*View).Paste, "SelectAll": (*View).SelectAll, "OpenFile": (*View).OpenFile, @@ -859,6 +860,18 @@ func (v *View) DuplicateLine() bool { return true } +// DeleteLine deletes the current line +func (v *View) DeleteLine() bool { + v.Cursor.SelectLine() + if !v.Cursor.HasSelection() { + return false + } + v.Cursor.DeleteSelection() + v.Cursor.ResetSelection() + messenger.Message("Deleted 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 {