complete_actions.go 897 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // License: GPLv3 Copyright: 2024, Kovid Goyal, <kovid at kovidgoyal.net>
  2. package at
  3. import (
  4. "fmt"
  5. "strings"
  6. "kitty"
  7. "kitty/tools/cli"
  8. "kitty/tools/utils"
  9. )
  10. var _ = fmt.Print
  11. func complete_actions(completions *cli.Completions, word string, arg_num int) {
  12. if arg_num < 2 {
  13. scanner := utils.NewLineScanner(KittyActionNames)
  14. mg := completions.AddMatchGroup("Actions")
  15. for scanner.Scan() {
  16. line := strings.TrimSpace(scanner.Text())
  17. if line != "" && strings.HasPrefix(line, word) {
  18. mg.AddMatch(line)
  19. }
  20. }
  21. }
  22. }
  23. func complete_kitty_override(completions *cli.Completions, word string, arg_num int) {
  24. mg := completions.AddMatchGroup("Config directives")
  25. mg.NoTrailingSpace = true
  26. scanner := utils.NewLineScanner(kitty.OptionNames)
  27. for scanner.Scan() {
  28. line := strings.TrimSpace(scanner.Text())
  29. if strings.HasPrefix(line, word) {
  30. mg.AddMatch(line + "=")
  31. }
  32. }
  33. }