mirror of https://github.com/mum4k/termdash.git
Updated Termdash API (markdown)
parent
3000d49344
commit
547e27f6e2
|
@ -2,7 +2,7 @@
|
|||
|
||||
[![Doc Status](https://godoc.org/github.com/mum4k/termdash?status.png)](https://godoc.org/github.com/mum4k/termdash)
|
||||
|
||||
The [termdash](https://github.com/mum4k/termdash/blob/master/termdash) package provides the developer with the main entry point to Termdash. This package is used to:
|
||||
The [termdash](https://godoc.org/github.com/mum4k/termdash) package provides the developer with the main entry point to Termdash. This package is used to:
|
||||
|
||||
- Start and stop the application.
|
||||
- Control screen redraw.
|
||||
|
@ -34,7 +34,7 @@ The developer might want to also subscribe to events so that the application can
|
|||
|
||||
The public API surface of this package consists of the following:
|
||||
|
||||
## [termdash.Run](https://github.com/mum4k/termdash/blob/c861ecef303ac648f926597f28c9f44994a1ca8b/termdash.go#L91-L103):
|
||||
## [termdash.Run](https://godoc.org/github.com/mum4k/termdash#Run):
|
||||
|
||||
The **Run** function provides the simplest way to run a Termdash based application. Run blocks until the provided context expires, therefore we need a trigger to close the context, e.g. a keyboard shortcut or a timeout. When Termdash is started using this function, the screen is redrawn periodically.
|
||||
|
||||
|
@ -62,7 +62,7 @@ if err := termdash.Run(ctx, t, c); err != nil {
|
|||
}
|
||||
```
|
||||
|
||||
## [termdash.RedrawInterval](https://github.com/mum4k/termdash/blob/275d95ad418b6ecca8817de4b013b440fc9abbe6/termdash.go#L55-L62)
|
||||
## [termdash.RedrawInterval](https://godoc.org/github.com/mum4k/termdash#RedrawInterval)
|
||||
|
||||
The **termdash.RedrawInterval** is used to specify how often will the screen redraw when starting Termdash via the **termdash.Run** function. This option is ignored when using the **termdash.NewController**.
|
||||
|
||||
|
@ -75,7 +75,7 @@ if err := termdash.Run(ctx, t, c, termdash.RedrawInterval(3 * time.Second)); err
|
|||
}
|
||||
```
|
||||
|
||||
## [termdash.NewController](https://github.com/mum4k/termdash/blob/ffbf88caeddb1735dcf2a5f735eec80dc9cf9fe7/termdash.go#L113-L130):
|
||||
## [termdash.NewController](https://godoc.org/github.com/mum4k/termdash#NewController):
|
||||
|
||||
The **NewController** function creates a new **Controller** instance which allows the user to manually trigger a screen redraw. Periodic redraws are disabled in this mode. Termdash will still redraw the screen each time an input event happens, e.g. a keyboard, a mouse event or a terminal resize.
|
||||
|
||||
|
@ -109,7 +109,7 @@ if err := ctrl.Redraw(); err != nil {
|
|||
}
|
||||
```
|
||||
|
||||
## [termdash.ErrorHandler](https://github.com/mum4k/termdash/blob/1c6947618b08ae236959763efd07278be5f03211/termdash.go#L64-L71):
|
||||
## [termdash.ErrorHandler](https://godoc.org/github.com/mum4k/termdash#ErrorHandler):
|
||||
|
||||
The **termdash.ErrorHandler** function is used to provide a custom error handler. If not provided, the application will panic on all runtime errors. An error handler is a function (a callback) that receives the error and decides what to do. This function must be thread-safe, since Termdash delivers events concurrently.
|
||||
|
||||
|
@ -136,7 +136,7 @@ if err != nil {
|
|||
defer ctrl.Close()
|
||||
```
|
||||
|
||||
## [termdash.KeyboardSubscriber](https://github.com/mum4k/termdash/blob/275d95ad418b6ecca8817de4b013b440fc9abbe6/termdash.go#L74-L81):
|
||||
## [termdash.KeyboardSubscriber](https://godoc.org/github.com/mum4k/termdash#KeyboardSubscriber):
|
||||
|
||||
The **termdash.KeyboardSubscriber** function can be used by the developer to provide an additional subscriber to keyboard events. A keyboard subscriber is a function (a callback) that processes keyboard events. This function must be thread-safe, since Termdash delivers events concurrently. Providing an additional keyboard subscriber is completely optional and doesn't affect any of Termdash functionalities.
|
||||
|
||||
|
@ -162,7 +162,7 @@ if err := termdash.Run(ctx, t, c, termdash.KeyboardSubscriber(quitter)); err !=
|
|||
}
|
||||
```
|
||||
|
||||
## [termdash.MouseSubscriber](https://github.com/mum4k/termdash/blob/275d95ad418b6ecca8817de4b013b440fc9abbe6/termdash.go#L83-L90):
|
||||
## [termdash.MouseSubscriber](https://godoc.org/github.com/mum4k/termdash#MouseSubscriber):
|
||||
|
||||
The **termdash.MouseSubscriber** function can be used by the developer to provide an additional subscriber to mouse events. A mouse subscriber is a function (a callback) that processes mouse events. This function must be thread-safe, since Termdash delivers events concurrently. Providing an additional mouse subscriber is completely optional and doesn't affect any of Termdash functionalities.
|
||||
|
||||
|
|
Loading…
Reference in New Issue