From afcfd8fc48833d02e9c29353bcfb9fa355739211 Mon Sep 17 00:00:00 2001 From: Vladislav Ananev Date: Mon, 12 Dec 2022 20:02:00 +0400 Subject: [PATCH] fixed exitting on q press --- .gitignore | 5 ++++- pkg/controller/controller.go | 12 ++++-------- pkg/view/view.go | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index b425dd5..18aaecf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ etcd-walker.log -build/ \ No newline at end of file +build/ + + +.idea/ diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 0882c9e..e5468c5 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -36,7 +36,7 @@ func NewController( ) *Controller { m := model.NewModel(host, port) v := view.NewView() - v.Frame.AddText(fmt.Sprintf("Etcd-walker v.0.0.7 (on %s:%s)", host, port), true, tview.AlignCenter, tcell.ColorGreen) + v.Frame.AddText(fmt.Sprintf("Etcd-walker v.0.0.8 (on %s:%s)", host, port), true, tview.AlignCenter, tcell.ColorGreen) controller := Controller{ debug: debug, @@ -128,13 +128,9 @@ func (c *Controller) getPosition(element string, slice []string) int { func (c *Controller) setInput() { c.view.App.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Key() { - case tcell.KeyRune: - switch event.Rune() { - case 'q': - c.Stop() - return nil - } - + case tcell.KeyCtrlQ: + c.Stop() + return nil } return event }) diff --git a/pkg/view/view.go b/pkg/view/view.go index 9d207af..0cfa23e 100644 --- a/pkg/view/view.go +++ b/pkg/view/view.go @@ -51,7 +51,7 @@ func NewView() *View { } frame := tview.NewFrame(pages) - frame.AddText("[::b][↓,↑][::-] Down/Up [::b][Enter,l/u][::-] Lower/Upper [::b][c[][::-] Create [::b][d[][::-] Delete [::b][e[][::-] Edit value [::b][/][::-] Search [::b][q[][::-] Quit", false, tview.AlignCenter, tcell.ColorWhite) + frame.AddText("[::b][↓,↑][::-] Down/Up [::b][Enter,l/u][::-] Lower/Upper [::b][c[][::-] Create [::b][d[][::-] Delete [::b][e[][::-] Edit value [::b][/][::-] Search [::b][Ctrl+q][::-] Quit", false, tview.AlignCenter, tcell.ColorWhite) app.SetRoot(frame, true)