fix: UI for filtering config options

Also added vim-like movement (hjkl, g, shift+g)
  h -> left
  j -> down
  k -> up
  l -> right
  g -> Go to first config
  shift+g -> Go to last config
This commit is contained in:
2024-12-19 12:49:49 +02:00
parent 7b03fa0d86
commit 96389610ed
3 changed files with 90 additions and 37 deletions
+31 -1
View File
@@ -26,7 +26,7 @@ type ParsedConfig struct {
CRF string
}
func find(cfgs map[int]Config, name string) Config {
func find(cfgs []Config, name string) Config {
for _, cfg := range cfgs {
if cfg.Name == name {
return cfg
@@ -36,3 +36,33 @@ func find(cfgs map[int]Config, name string) Config {
err := fmt.Sprintf("Couldn't find requested cfg: %s", name)
panic(err)
}
func filter(cfgs []Config, names ...string) []Config {
filtered := make([]Config, 0)
cfgloop:
for _, cfg := range cfgs {
for _, name := range names {
if cfg.Name == name {
continue cfgloop
}
}
filtered = append(filtered, cfg)
}
return filtered
}
func getVisibleConfigs(cfgs []Config) []Config {
parsed := parseConfig(cfgs)
switch parsed.VideoEncoder {
case "copy", "librav1e":
return filter(cfgs, "Preset", "Constant Rate Factor (CRF)")
case "libvpx-vp9", "libsvtav1":
return filter(cfgs, "Preset")
}
return cfgs
}