From c84bed67cfbcc1af518725fe653be09981b14c2e Mon Sep 17 00:00:00 2001 From: qowevisa Date: Fri, 18 Oct 2024 07:22:28 +0300 Subject: [PATCH] Add UsingEscapeCodes to Menu and MenuConfig --- simple/menu.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/simple/menu.go b/simple/menu.go index 57a32b4..2c0e9cf 100644 --- a/simple/menu.go +++ b/simple/menu.go @@ -31,14 +31,16 @@ func (c *Command) Print() { } type MenuConfig struct { - Title string - BackKey string + Title string + BackKey string + UsingEscapeCodes bool } func getDefConfig() *MenuConfig { return &MenuConfig{ - Title: "Default Menu Title", - BackKey: "<", + Title: "Default Menu Title", + BackKey: "<", + UsingEscapeCodes: false, } } @@ -84,6 +86,10 @@ func createCommandTree() *commandTree { type Menu struct { Title string BackKey string + // Escape Code part + // + usingEscapeCodes bool + lineCounter uint // counterForIDs uint cmdTree *commandTree @@ -97,10 +103,12 @@ func CreateMenu(options ...SimpleMenuOption) *Menu { } return &Menu{ - Title: conf.Title, - BackKey: conf.BackKey, - counterForIDs: 1, - cmdTree: createCommandTree(), + Title: conf.Title, + BackKey: conf.BackKey, + usingEscapeCodes: conf.UsingEscapeCodes, + lineCounter: 0, + counterForIDs: 1, + cmdTree: createCommandTree(), } }