From 016ad0544482a196382eaf4f948d64b13eee7c94 Mon Sep 17 00:00:00 2001 From: chiefnoah Date: Wed, 9 Aug 2017 09:05:10 -0500 Subject: [PATCH] Added HOME and END support to all editor boxes. --- wuzz.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/wuzz.go b/wuzz.go index 7f0241d..22e9a7d 100644 --- a/wuzz.go +++ b/wuzz.go @@ -378,6 +378,30 @@ func (e *ViewEditor) Edit(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modif return } } + if key == gocui.KeyHome { + _, cY := v.Cursor() + _, oY := v.Origin() + v.SetCursor(0, cY) + v.SetOrigin(0, oY) + + } + if key == gocui.KeyEnd { + width, _ := v.Size() + _, cY := v.Cursor() + l, err := v.Line(cY) + if err != nil { + return + } + lineWidth := len(l) + if lineWidth > width { + _, oY := v.Origin() + v.SetOrigin(lineWidth-width, oY) + lineWidth = width - 1 + } + v.SetCursor(lineWidth, cY) + return + } + e.origEditor.Edit(v, key, ch, mod) }