mirror of https://github.com/mum4k/termdash.git
Created Container style (markdown)
parent
510703513b
commit
59af89df3e
|
@ -0,0 +1,86 @@
|
|||
This section describes container options that specify its style or look.
|
||||
|
||||
## Borders for containers
|
||||
|
||||
Containers don't have any borders by default, use one of the following options to instruct Termdash to draw a border around a container.
|
||||
|
||||
[[/images/container-api/border_styles.png|border_styles]]
|
||||
|
||||
The following code shows two containers with different border styles as shown above. The right container has the keyboard focus so its border is highlighted.
|
||||
|
||||
```go
|
||||
tb, err := termbox.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer tb.Close()
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.SplitVertical(
|
||||
container.Left(
|
||||
container.Border(linestyle.Light),
|
||||
),
|
||||
container.Right(
|
||||
container.Border(linestyle.Double),
|
||||
),
|
||||
),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("container.New => %v", err)
|
||||
}
|
||||
```
|
||||
|
||||
### [container.Border](https://godoc.org/github.com/mum4k/termdash/container#Border):
|
||||
|
||||
The **container.Border** option is used to enable the border and specify its line style. Refer to the [[Linestyle API|linestyle-api]] for the available line styles.
|
||||
|
||||
### [container.BorderColor](https://godoc.org/github.com/mum4k/termdash/container#BorderColor):
|
||||
|
||||
The **container.BorderColor** option sets the color of the border. This option takes no effect when the container has no border.
|
||||
|
||||
### [container.FocusedColor](https://godoc.org/github.com/mum4k/termdash/container#FocusedColor):
|
||||
|
||||
The **container.FocusedColor** option sets the color of the border when the container is focused. This option takes no effect when the container has no border.
|
||||
|
||||
### Titles for containers
|
||||
|
||||
Containers that have a border can also have a text title displayed in the border. The title isn't visible on a container without border.
|
||||
|
||||
[[/images/container-api/border_title.png|border_title]]
|
||||
|
||||
The following code shows a container with a title in the border that is aligned to the right.
|
||||
|
||||
```go
|
||||
tb, err := termbox.New()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer tb.Close()
|
||||
|
||||
c, err := container.New(
|
||||
t,
|
||||
container.Border(linestyle.Light),
|
||||
container.BorderTitle("hello world"),
|
||||
container.BorderTitleAlignRight(),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("container.New => %v", err)
|
||||
}
|
||||
```
|
||||
|
||||
### [container.BorderTitle](https://godoc.org/github.com/mum4k/termdash/container#BorderTitle):
|
||||
|
||||
The **container.BorderTitle** option sets the title to display on the container. The title is displayed above the container and aligned according to the following alignment options.
|
||||
|
||||
### [container.BorderTitleAlignLeft](https://godoc.org/github.com/mum4k/termdash/container#BorderTitleAlignLeft):
|
||||
|
||||
The **container.BorderTitleAlignLeft** option indicates that the container title should be aligned at the top left corner.
|
||||
|
||||
### [container.BorderTitleAlignCenter](https://godoc.org/github.com/mum4k/termdash/container#BorderTitleAlignCenter):
|
||||
|
||||
The **container.BorderTitleAlignCenter** option indicates that the container title should be aligned at the top and center above the container.
|
||||
|
||||
### [container.BorderTitleAlignRight](https://godoc.org/github.com/mum4k/termdash/container#BorderTitleAlignRight):
|
||||
|
||||
The **container.BorderTitleAlignRight** option indicates that the container title should be aligned at the top right corner.
|
Loading…
Reference in New Issue