Consolidate shared UI, hardware transport, and translation tooling
This commit is contained in:
1 parent
ed6951f4cd
commit
2c612de63b
61 files changed
+2417
-1573
No files matched your search
+11
-11
@@ -13,29 +13,29 @@ import (
|
||||
|
||||
// Grid selections index Choices, even while the visible results are filtered.
|
||||
// Choice IDs remain opaque to the model and can carry a host-owned value.
|
||||
func (s *Session) grid_matches(c Control) []int {
|
||||
func (s *Session) gridMatches(c Control) []int {
|
||||
var matches []int
|
||||
prefix := strings.ToLower(c.Text)
|
||||
for index, choice := range c.Choices {
|
||||
if !choice.Disabled && strings.HasPrefix(strings.ToLower(s.choice_label(choice)), prefix) {
|
||||
if !choice.Disabled && strings.HasPrefix(strings.ToLower(s.choiceLabel(choice)), prefix) {
|
||||
matches = append(matches, index)
|
||||
}
|
||||
}
|
||||
return matches
|
||||
}
|
||||
|
||||
func (s *Session) filter_grid(c *Control) {
|
||||
func (s *Session) filterGrid(c *Control) {
|
||||
c.Selected = -1
|
||||
if matches := s.grid_matches(*c); len(matches) > 0 {
|
||||
if matches := s.gridMatches(*c); len(matches) > 0 {
|
||||
c.Selected = matches[0]
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Session) describe_grid(c Control) string {
|
||||
matches := s.grid_matches(c)
|
||||
func (s *Session) describeGrid(c Control) string {
|
||||
matches := s.gridMatches(c)
|
||||
for position, index := range matches {
|
||||
if index == c.Selected {
|
||||
label := s.choice_label(c.Choices[index])
|
||||
label := s.choiceLabel(c.Choices[index])
|
||||
return gridmodel.Describe(label, position, len(matches), c.Columns, s.announceGridCoordinates, s.announceItemPosition, s.messages)
|
||||
}
|
||||
}
|
||||
@@ -69,14 +69,14 @@ func (s *Session) grid(c *Control, key Key) Result {
|
||||
runes = append(runes, []rune(key.Text)...)
|
||||
}
|
||||
c.Text = string(runes)
|
||||
s.filter_grid(c)
|
||||
s.filterGrid(c)
|
||||
query := s.messages.T("Search cleared")
|
||||
if c.Text != "" {
|
||||
query = s.messages.Format("Search {0}", c.Text)
|
||||
}
|
||||
return Result{Speech: query + ". " + s.describe_grid(*c)}
|
||||
return Result{Speech: query + ". " + s.describeGrid(*c)}
|
||||
}
|
||||
matches := s.grid_matches(*c)
|
||||
matches := s.gridMatches(*c)
|
||||
if len(matches) == 0 {
|
||||
return Result{Speech: s.messages.T("No matches")}
|
||||
}
|
||||
@@ -103,5 +103,5 @@ func (s *Session) grid(c *Control, key Key) Result {
|
||||
}
|
||||
|
||||
c.Selected = matches[position]
|
||||
return Result{Speech: s.describe_grid(*c)}
|
||||
return Result{Speech: s.describeGrid(*c)}
|
||||
}
|
||||
Reference in new issue
Block a user