Steve Thielemann 3 years ago
parent
commit
7f417456e9
1 changed files with 23 additions and 0 deletions
  1. 23 0
      door/input.go

+ 23 - 0
door/input.go

@@ -5,6 +5,7 @@ import (
 	"strconv"
 	"strings"
 	"time"
+	"unicode"
 )
 
 // This is the current list of Extended keys we support:
@@ -334,3 +335,25 @@ func (d *Door) Input(max int) string {
 	// this is never reached
 	return line
 }
+
+func (d *Door) GetOneOf(possible string) int {
+	var c int
+
+	for {
+		c = d.WaitKey(Inactivity, 0)
+		if c < 0 {
+			return c
+		}
+		r := unicode.ToUpper(rune(c))
+		if strings.ContainsRune(possible, r) {
+			// return upper case rune
+			return int(r)
+		}
+		/*
+			c = strings.IndexRune(possible, r)
+			if c != -1 {
+				return c
+			}
+		*/
+	}
+}