gitea源码

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package indexer
  4. type SearchModeType string
  5. const (
  6. SearchModeExact SearchModeType = "exact"
  7. SearchModeWords SearchModeType = "words"
  8. SearchModeFuzzy SearchModeType = "fuzzy"
  9. SearchModeRegexp SearchModeType = "regexp"
  10. )
  11. type SearchMode struct {
  12. ModeValue SearchModeType
  13. TooltipTrKey string
  14. TitleTrKey string
  15. }
  16. func SearchModesExactWords() []SearchMode {
  17. return []SearchMode{
  18. {
  19. ModeValue: SearchModeExact,
  20. TooltipTrKey: "search.exact_tooltip",
  21. TitleTrKey: "search.exact",
  22. },
  23. {
  24. ModeValue: SearchModeWords,
  25. TooltipTrKey: "search.words_tooltip",
  26. TitleTrKey: "search.words",
  27. },
  28. }
  29. }
  30. func SearchModesExactWordsFuzzy() []SearchMode {
  31. return append(SearchModesExactWords(), []SearchMode{
  32. {
  33. ModeValue: SearchModeFuzzy,
  34. TooltipTrKey: "search.fuzzy_tooltip",
  35. TitleTrKey: "search.fuzzy",
  36. },
  37. }...)
  38. }
  39. func GitGrepSupportedSearchModes() []SearchMode {
  40. return append(SearchModesExactWords(), []SearchMode{
  41. {
  42. ModeValue: SearchModeRegexp,
  43. TooltipTrKey: "search.regexp_tooltip",
  44. TitleTrKey: "search.regexp",
  45. },
  46. }...)
  47. }