1
0

layout.go 816 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package layout
  2. type Rect struct {
  3. x int
  4. y int
  5. width int
  6. height int
  7. }
  8. type LayoutManager struct {
  9. Workspaces []Workspace
  10. ActiveIdx int
  11. }
  12. type Workspace struct {
  13. RootContainer Container[[]int]
  14. }
  15. type SplitType int
  16. const (
  17. SplitHorizontal SplitType = iota
  18. SplitVertical
  19. )
  20. type ContainerNode interface {
  21. []int | Container[[]int]
  22. }
  23. type Container[T ContainerNode] struct {
  24. Children [2]any
  25. Split SplitType
  26. ActiveBuffer *int
  27. }
  28. func NewLayoutManager() LayoutManager {
  29. return LayoutManager{
  30. Workspaces: []Workspace{NewWorkspace()},
  31. }
  32. }
  33. func NewWorkspace() Workspace {
  34. return Workspace{
  35. RootContainer: NewContainerEmpty(),
  36. }
  37. }
  38. func NewContainerEmpty() Container[[]int] {
  39. return Container[[]int]{
  40. Children: [2]any{},
  41. Split: SplitHorizontal,
  42. ActiveBuffer: nil,
  43. }
  44. }