From a57c6ce76a8b961a415b7e73a43d818b6e6c56f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=A1=D1=8B=D1=81?= =?UTF-8?q?=D0=BE=D0=B5=D0=B2?= Date: Sun, 22 Oct 2023 11:59:36 +0800 Subject: [PATCH] Adds ringing a bell if history out of range --- pkg/cli/cli.go | 2 ++ pkg/cli/editor.go | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 823b063..cb9c0fc 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -18,6 +18,8 @@ const ( MacOSDeleteKey = 127 KeyboardBufferSize = 10 + + Bell = "\a" ) type CLI struct { diff --git a/pkg/cli/editor.go b/pkg/cli/editor.go index 78f7851..3578fb4 100644 --- a/pkg/cli/editor.go +++ b/pkg/cli/editor.go @@ -64,7 +64,9 @@ func (ed *Editor) EditRequest(keyStream <-chan keyboard.KeyEvent, initBuffer str req := ed.History.GetRequst(historyIndex) if req == "" { + fmt.Print(Bell) historyIndex-- + continue } @@ -74,7 +76,9 @@ func (ed *Editor) EditRequest(keyStream <-chan keyboard.KeyEvent, initBuffer str req := ed.History.GetRequst(historyIndex) if req == "" { + fmt.Print(Bell) historyIndex++ + continue }