border.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 "light":
  20. *p = borderPresetLight()
  21. case "hidden":
  22. *p = BorderPreset{
  23. Horizontal: ' ',
  24. Vertical: ' ',
  25. TopLeft: ' ',
  26. TopRight: ' ',
  27. BottomLeft: ' ',
  28. BottomRight: ' ',
  29. }
  30. }
  31. return nil
  32. }
  33. func borderPresetDouble() BorderPreset {
  34. return BorderPreset{
  35. Horizontal: tview.BoxDrawingsDoubleHorizontal,
  36. Vertical: tview.BoxDrawingsDoubleVertical,
  37. TopLeft: tview.BoxDrawingsDoubleDownAndRight,
  38. TopRight: tview.BoxDrawingsDoubleDownAndLeft,
  39. BottomLeft: tview.BoxDrawingsDoubleUpAndRight,
  40. BottomRight: tview.BoxDrawingsDoubleUpAndLeft,
  41. }
  42. }
  43. func borderPresetThick() BorderPreset {
  44. return BorderPreset{
  45. Horizontal: tview.BoxDrawingsHeavyHorizontal,
  46. Vertical: tview.BoxDrawingsHeavyVertical,
  47. TopLeft: tview.BoxDrawingsHeavyDownAndRight,
  48. TopRight: tview.BoxDrawingsHeavyDownAndLeft,
  49. BottomLeft: tview.BoxDrawingsHeavyUpAndRight,
  50. BottomRight: tview.BoxDrawingsHeavyUpAndLeft,
  51. }
  52. }
  53. func borderPresetRound() BorderPreset {
  54. return BorderPreset{
  55. Horizontal: tview.BoxDrawingsLightHorizontal,
  56. Vertical: tview.BoxDrawingsLightVertical,
  57. TopLeft: tview.BoxDrawingsLightArcDownAndRight,
  58. TopRight: tview.BoxDrawingsLightArcDownAndLeft,
  59. BottomLeft: tview.BoxDrawingsLightArcUpAndRight,
  60. BottomRight: tview.BoxDrawingsLightArcUpAndLeft,
  61. }
  62. }
  63. func borderPresetLight() BorderPreset {
  64. return BorderPreset{
  65. Horizontal: tview.BoxDrawingsLightHorizontal,
  66. Vertical: tview.BoxDrawingsLightVertical,
  67. TopLeft: tview.BoxDrawingsLightDownAndRight,
  68. TopRight: tview.BoxDrawingsLightDownAndLeft,
  69. BottomLeft: tview.BoxDrawingsLightUpAndRight,
  70. BottomRight: tview.BoxDrawingsLightUpAndLeft,
  71. }
  72. }