For speech rate in settings up/down move by 10, left/right move by 1. Easier to get settings right without having to hold doown the arrow keys lol.

This commit is contained in:
Storm Dragon committed 2026-10-28 15:44:41 -04:00
1 parent ea5d26f56d
commit 088f706cb4
13 files changed
+81 -10

No files matched your search

+1
View File
@@ -37,6 +37,7 @@ type Control struct {
Checked bool
Number float64
Min, Max, Step float64
UpDownStep float64 // Zero uses the default step of 1 for Up and Down.
Text string
Items []string
Selected int
+10 -2
View File
@@ -54,6 +54,14 @@ func New_session(form Form) (*Session, error) {
return nil, fmt.Errorf("invalid control %q", control.ID)
}
controlIDs[control.ID] = true
if control.Kind == Number {
if control.UpDownStep == 0 {
control.UpDownStep = 1
}
if math.IsNaN(control.UpDownStep) || math.IsInf(control.UpDownStep, 0) || control.UpDownStep < 0 {
return nil, fmt.Errorf("invalid vertical step %q", control.ID)
}
}
if control.Kind == Number && (math.IsNaN(control.Number) || math.IsInf(control.Number, 0) || math.IsNaN(control.Min) || math.IsInf(control.Min, 0) || math.IsNaN(control.Max) || math.IsInf(control.Max, 0) || math.IsNaN(control.Step) || math.IsInf(control.Step, 0) || control.Min > control.Max || control.Step <= 0 || control.Number < control.Min || control.Number > control.Max) {
return nil, fmt.Errorf("invalid range %q", control.ID)
}
@@ -244,9 +252,9 @@ func (s *Session) Handle(key Key) Result {
delta := 0.0
switch key.Name {
case "up":
delta = 1
delta = control.UpDownStep
case "down":
delta = -1
delta = -control.UpDownStep
case "right":
delta = control.Step
case "left":
+14 -1
View File
@@ -17,7 +17,20 @@
package interaction
import "testing"
import (
"math"
"testing"
)
func TestInvalidNumberUpDownStepRejected(t *testing.T) {
for _, step := range []float64{-1, math.NaN(), math.Inf(1), math.Inf(-1)} {
form := test_form()
form.Tabs[0].Controls[1].UpDownStep = step
if _, err := New_session(form); err == nil {
t.Fatalf("invalid Up/Down step %v accepted", step)
}
}
}
func test_form() Form {
return Form{Type: TabForm, Title: "Settings", Tabs: []Tab{