border.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package config
  2. import "github.com/rivo/tview"
  3. type BorderPreset struct {
  4. Horizontal rune
  5. Vertical rune
  6. TopLeft rune
  7. TopRight rune
  8. BottomLeft rune
  9. BottomRight rune
  10. }
  11. func (p *BorderPreset) UnmarshalTOML(v any) error {
  12. switch v.(string) {
  13. case "double":
  14. *p = borderPresetDouble()
  15. case "thick":
  16. *p = borderPresetThick()
  17. case "round":
  18. *p = borderPresetRound()
  19. case "hidden":
  20. *p = BorderPreset{
  21. Horizontal: ' ',
  22. Vertical: ' ',
  23. TopLeft: ' ',
  24. TopRight: ' ',
  25. BottomLeft: ' ',
  26. BottomRight: ' ',
  27. }
  28. }
  29. return nil
  30. }
  31. func borderPresetDouble() BorderPreset {
  32. return BorderPreset{
  33. Horizontal: tview.BoxDrawingsDoubleHorizontal,
  34. Vertical: tview.BoxDrawingsDoubleVertical,
  35. TopLeft: tview.BoxDrawingsDoubleDownAndRight,
  36. TopRight: tview.BoxDrawingsDoubleDownAndLeft,
  37. BottomLeft: tview.BoxDrawingsDoubleUpAndRight,
  38. BottomRight: tview.BoxDrawingsDoubleUpAndLeft,
  39. }
  40. }
  41. func borderPresetThick() BorderPreset {
  42. return BorderPreset{
  43. Horizontal: tview.BoxDrawingsHeavyHorizontal,
  44. Vertical: tview.BoxDrawingsHeavyVertical,
  45. TopLeft: tview.BoxDrawingsHeavyDownAndRight,
  46. TopRight: tview.BoxDrawingsHeavyDownAndLeft,
  47. BottomLeft: tview.BoxDrawingsHeavyUpAndRight,
  48. BottomRight: tview.BoxDrawingsHeavyUpAndLeft,
  49. }
  50. }
  51. func borderPresetRound() BorderPreset {
  52. return BorderPreset{
  53. Horizontal: tview.BoxDrawingsLightHorizontal,
  54. Vertical: tview.BoxDrawingsLightVertical,
  55. TopLeft: tview.BoxDrawingsLightArcDownAndRight,
  56. TopRight: tview.BoxDrawingsLightArcDownAndLeft,
  57. BottomLeft: tview.BoxDrawingsLightArcUpAndRight,
  58. BottomRight: tview.BoxDrawingsLightArcUpAndLeft,
  59. }
  60. }