issue-9: moved keybindings out into a separate type

Also started working on a service which can be used to rebind keys using reflection.
This commit is contained in:
Leon Mika 2022-08-24 22:06:29 +10:00
parent cb31da3806
commit 2f89610c51
5 changed files with 102 additions and 15 deletions

View file

@ -0,0 +1,32 @@
package keybindings
import "reflect"
type Service struct {
keyBindingValue reflect.Value
}
func NewService(keyBinding any) *Service {
v := reflect.ValueOf(keyBinding)
if v.Kind() != reflect.Pointer {
panic("keyBinding must be a pointer to a struct")
}
return &Service{
keyBindingValue: v.Elem(),
}
}
func (s *Service) Rebind(name string, key string) error {
}
func (s *Service) findFieldForBinding(name string) reflect.Value {
}
func (s *Service) findFieldForBindingInGroup(group reflect.Value, name string) reflect.Value {
for i := 0; i < group.NumField(); i++ {
group.Field(i).Type().
}
}