mirror of https://github.com/mum4k/termdash.git
Updated Container API (markdown)
parent
b3d58b3f49
commit
71d5f505a3
|
@ -24,4 +24,37 @@ Given a container, developers can create sub-containers by **splitting** the con
|
|||
|
||||
This property is recursive, meaning developers can further split the sub-containers using the same rules. The following diagram demonstrates how splits are utilized to create a layout.
|
||||
|
||||
[[/images/container-api/container_splits.png|container_splits]]
|
||||
[[/images/container-api/container_splits.png|container_splits]]
|
||||
|
||||
## [container.New](https://godoc.org/github.com/mum4k/termdash/container#New):
|
||||
|
||||
The **container.New** function is used to constract a container. The API of this function uses a recursive builder patters, the complete layout of all the containers in the tree is established in a single call.
|
||||
|
||||
To create the terminal layout indicated in the diagram above, the developer can use the following call:
|
||||
|
||||
```go
|
||||
tb, err := termbox.New()
|
||||
if err != nil {
|
||||
return fmt.Errorf("termbox.New => %v", err)
|
||||
}
|
||||
|
||||
if _, err := container.New(
|
||||
tb,
|
||||
container.SplitVertical(
|
||||
container.Left(), // Container left empty in this example.
|
||||
container.Right(
|
||||
container.SplitHorizontal(
|
||||
container.Top() // Container left empty in this example.
|
||||
container.Bottom(
|
||||
container.SplitVertical(
|
||||
container.Left(), // Container left empty in this example.
|
||||
container.Right(), // Container left empty in this example.
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue