aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--client/menu.go13
-rw-r--r--client/menu_test.go8
-rw-r--r--config/config_test.go12
-rw-r--r--config/menu.go12
-rw-r--r--config/menu_test.go14
-rw-r--r--example/complete.yaml6
6 files changed, 8 insertions, 57 deletions
diff --git a/client/menu.go b/client/menu.go
index d20b7d0..19c8992 100644
--- a/client/menu.go
+++ b/client/menu.go
@@ -5,17 +5,8 @@ import "fmt"
func (s *State) displayMenu() {
menu := s.config.Menus[s.currentMenu]
fmt.Print("\033[2J") // clear the screen
- fmt.Println(menu.Banner)
- output := ""
- prefix := ""
- for i := 0; i < menu.XOffset; i++ {
- prefix += " "
- }
- for i := 0; i < menu.YOffset; i++ {
- output += "\n"
- }
- fmt.Printf("%s", output)
+ fmt.Printf("%s\n\n", menu.Banner)
for i := 0; i < len(menu.MenuEntries); i++ {
- fmt.Printf("%s%s) %s\n", prefix, menu.MenuEntries[i].Key, menu.MenuEntries[i].Label)
+ fmt.Printf("%s) %s\n", menu.MenuEntries[i].Key, menu.MenuEntries[i].Label)
}
}
diff --git a/client/menu_test.go b/client/menu_test.go
index 224b242..aaf3d81 100644
--- a/client/menu_test.go
+++ b/client/menu_test.go
@@ -19,9 +19,7 @@ func TestDisplayMenu(t *testing.T) {
config: &config.Config{
Menus: map[string]config.Menu{
"test": config.Menu{
- Banner: "TEST TEST TEST",
- XOffset: 5,
- YOffset: 3,
+ Banner: "TEST TEST TEST",
MenuEntries: []config.MenuEntry{
config.MenuEntry{
Key: "q",
@@ -37,8 +35,8 @@ func TestDisplayMenu(t *testing.T) {
}
want := []byte("\033[2J" +
"TEST TEST TEST\n" +
- "\n\n\n" +
- " q) quit\n")
+ "\n" +
+ "q) quit\n")
state.displayMenu()
// back to normal state
w.Close()
diff --git a/config/config_test.go b/config/config_test.go
index 74c7996..98dad66 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -120,9 +120,7 @@ func TestLoadFile(t *testing.T) {
},
Menus: map[string]Menu{
"anonymous": Menu{
- Banner: "Shell Game Launcher - Anonymous access%n======================================",
- XOffset: 5,
- YOffset: 2,
+ Banner: "Shell Game Launcher - Anonymous access%n======================================",
MenuEntries: []MenuEntry{
MenuEntry{
Key: "l",
@@ -147,9 +145,7 @@ func TestLoadFile(t *testing.T) {
},
},
"logged_in": Menu{
- Banner: "Shell Game Launcher%n===================",
- XOffset: 5,
- YOffset: 2,
+ Banner: "Shell Game Launcher%n===================",
MenuEntries: []MenuEntry{
MenuEntry{
Key: "p",
@@ -189,9 +185,7 @@ func TestLoadFile(t *testing.T) {
},
},
"options": Menu{
- Banner: "Options%n=======",
- XOffset: 5,
- YOffset: 2,
+ Banner: "Options%n=======",
MenuEntries: []MenuEntry{
MenuEntry{
Key: "z",
diff --git a/config/menu.go b/config/menu.go
index a8ea7b0..7321c7b 100644
--- a/config/menu.go
+++ b/config/menu.go
@@ -14,10 +14,6 @@ var reValidKey = regexp.MustCompile(`^\w$`)
type Menu struct {
// Banner is the banner to display before the menu
Banner string `yaml:"Banner"`
- // XOffset is the X offset between the banner and the menu
- XOffset int `yaml:"XOffset"`
- // YOffset is the Y offset between the banner and the menu
- YOffset int `yaml:"YOffset"`
// Commands is the list of commands in the menu
MenuEntries []MenuEntry `yaml:"MenuEntries"`
}
@@ -38,14 +34,6 @@ func (m *Menu) validate(name string) error {
return errors.New("Invalid menu name, must be an alphanumeric word and match regex `^[\\w\\._]+$` : " + name)
}
// Banner is just any string, nothing to validate
- // XOffset
- if m.XOffset < 0 {
- return errors.New("XOffset must be a positive integer")
- }
- // YOffset
- if m.YOffset < 0 {
- return errors.New("YOffset must be a positive integer")
- }
// MenuEntries
if len(m.MenuEntries) == 0 {
return errors.New("A Menu needs MenuEntries to be valid")
diff --git a/config/menu_test.go b/config/menu_test.go
index 095b699..e9abef1 100644
--- a/config/menu_test.go
+++ b/config/menu_test.go
@@ -12,16 +12,6 @@ func TestMenuValidate(t *testing.T) {
t.Fatal("non alphanumeric menu name is not valid")
}
// Banner is just any string, nothing to validate
- // XOffset
- menu = Menu{XOffset: -1}
- if err := menu.validate("test"); err == nil {
- t.Fatal("Negative XOffset should not be valid")
- }
- // YOffset
- menu = Menu{YOffset: -1}
- if err := menu.validate("test"); err == nil {
- t.Fatal("Negative YOffset should not be valid")
- }
// MenuEntries are mostly tested bellow
menu = Menu{}
if err := menu.validate("test"); err == nil {
@@ -29,8 +19,6 @@ func TestMenuValidate(t *testing.T) {
}
// loop menu
menu = Menu{
- XOffset: 1,
- YOffset: 1,
MenuEntries: []MenuEntry{
MenuEntry{
Key: "a",
@@ -44,8 +32,6 @@ func TestMenuValidate(t *testing.T) {
}
// A valid menu
menu = Menu{
- XOffset: 1,
- YOffset: 1,
MenuEntries: []MenuEntry{
MenuEntry{
Key: "a",
diff --git a/example/complete.yaml b/example/complete.yaml
index 18a33d7..d6889d4 100644
--- a/example/complete.yaml
+++ b/example/complete.yaml
@@ -12,8 +12,6 @@ App:
Menus:
anonymous:
Banner: 'Shell Game Launcher - Anonymous access%n======================================'
- XOffset: 5
- YOffset: 2
MenuEntries:
- Key: l
Label: login
@@ -29,8 +27,6 @@ Menus:
Action: quit
logged_in:
Banner: 'Shell Game Launcher%n==================='
- XOffset: 5
- YOffset: 2
MenuEntries:
- Key: p
Label: play Nethack 3.7
@@ -55,8 +51,6 @@ Menus:
Action: quit
options:
Banner: 'Options%n======='
- XOffset: 5
- YOffset: 2
MenuEntries:
- Key: z
Label: back