mirror of
https://github.com/mum4k/termdash.git
synced 2025-04-25 13:48:50 +08:00
Updated Termbox API (markdown)
parent
6b9760d989
commit
60fe055ab5
@ -2,7 +2,7 @@
|
||||
|
||||
[](https://godoc.org/github.com/mum4k/termdash/terminal/termbox)
|
||||
|
||||
The [termbox](https://github.com/mum4k/termdash/tree/master/terminal/termbox) package is a shim layer over the [termbox-go](https://github.com/nsf/termbox-go) library that provides cell based access to the terminal.
|
||||
The [termbox](https://github.com/mum4k/termdash/tree/master/terminal/termbox) package implements the [[Terminal API|terminal-api]] using the [termbox-go](https://github.com/nsf/termbox-go). Termbox provides cell based access to the terminal.
|
||||
|
||||
The public API surface of this package consists of the following:
|
||||
|
||||
@ -23,7 +23,7 @@ This interface is used to provide optional arguments to **New**.
|
||||
|
||||
### [termbox.ColorMode](https://github.com/mum4k/termdash/blob/614d6ed82014e343ca40f25ee1bed8dfbd452830/terminal/termbox/termbox.go#L45-L51)
|
||||
|
||||
Used to set the color mode in which the terminal will be initialised. The available color modes are documented in the [[Terminal API|terminal-api]]. The following example sets the color mode to support 256 colors.
|
||||
Used to set the color mode in which the terminal will be initialised. The available color modes are documented in the [[Terminal API|terminal-api]]. The following example sets the color mode to grayscale. Note that when no options are provided, Termbox is initialised in a color mode that supports all 256 terminal colors. Refer to the [[Cell API|cell-api]] for an explanation of terminal colors.
|
||||
|
||||
```go
|
||||
tb, err := termbox.New(termbox.ColorMode(terminalapi.ColorMode256))
|
||||
@ -34,4 +34,12 @@ if err != nil {
|
||||
|
||||
## [termbox.Close](https://github.com/mum4k/termdash/blob/ffbf88caeddb1735dcf2a5f735eec80dc9cf9fe7/terminal/termbox/termbox.go#L158-L164)
|
||||
|
||||
This function should be used to close the terminal and return it to a sane state once the Termbox instance isn't needed anymore.
|
||||
This function should be used to close the terminal and return it to a sane state once the Termbox instance isn't needed anymore. A good practice is to defer the call right after Termbox instance is created:
|
||||
|
||||
```go
|
||||
tb, err := termbox.New(termbox.ColorMode(terminalapi.ColorMode256))
|
||||
if err != nil {
|
||||
return fmt.Errorf("termbox.New => %v", err)
|
||||
}
|
||||
defer tb.Close()
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user