mirror of https://github.com/gizak/termui.git
Remove custom docs; replaced with wiki
This commit is contained in:
parent
3f25d964d3
commit
16b302dba6
|
@ -1,32 +0,0 @@
|
|||
Overview
|
||||
---
|
||||
|
||||
Bufferer
|
||||
---
|
||||
|
||||
Block
|
||||
---
|
||||
|
||||
BarChart
|
||||
---
|
||||
|
||||
Canvas
|
||||
---
|
||||
|
||||
Gauge
|
||||
---
|
||||
|
||||
LineChart
|
||||
---
|
||||
|
||||
MBarChart
|
||||
---
|
||||
|
||||
Par
|
||||
---
|
||||
|
||||
Sparkline
|
||||
---
|
||||
|
||||
Sparklines
|
||||
---
|
|
@ -1,14 +0,0 @@
|
|||
Event System
|
||||
---
|
||||
|
||||
Keyboard Events
|
||||
---
|
||||
|
||||
Mouse Events
|
||||
---
|
||||
|
||||
Window Events
|
||||
---
|
||||
|
||||
Custom Events
|
||||
---
|
Binary file not shown.
Before Width: | Height: | Size: 152 KiB |
Binary file not shown.
Before Width: | Height: | Size: 125 KiB |
|
@ -1,15 +0,0 @@
|
|||
[termui]() is a cross-platform, easy-to-compile, and fully-customizable terminal dashboard. It aims to provide a terminal front end for your applications with less struggle:
|
||||
|
||||
> ![dashboard](img/dashboard.gif)
|
||||
>
|
||||
> _cast under osx 10.10; Terminal.app; Menlo Regular 12pt._
|
||||
|
||||
This guide describes the essential parts used to build a interface, which includes:
|
||||
|
||||
- Installation & Usage
|
||||
- Layout System
|
||||
- Event System
|
||||
- Theming
|
||||
- Components
|
||||
|
||||
[Quickstart](quickstart.md) is the way to go for starters and [Recipes](recipes.md) contains some practical resolutions you might need.
|
|
@ -1,26 +0,0 @@
|
|||
Overview
|
||||
---
|
||||
|
||||
termui offers two layout system: [Absolute]() and [Grid](). The two concept actually spawned from Web:
|
||||
|
||||
- The __Absolute layout__ is a plain coordination system, like [CSS position property](https://developer.mozilla.org/en/docs/Web/CSS/position) `position: absolute`. You will need manually assign `.X`, `.Y`, `.Width` and `.Height` to a component.
|
||||
- The __Grid system__ actually is a simplified version of [the 12 columns CSS grid system](http://www.w3schools.com/bootstrap/bootstrap_grid_system.asp) on terminal. You do not need to bother setting positions and width properties, these values will be synced up according to their containers.
|
||||
|
||||
!!! note
|
||||
`Align` property can help you set your component position based on terminal window. Find more at [Magic Variables](#magic-variables)
|
||||
|
||||
__Cons and pros:__
|
||||
|
||||
- Use of Absolute layout gives you maximum control over how to arrange your components, while you have
|
||||
to put a little more effort to set things up. Fortunately there are some "magic variables" may help you out.
|
||||
- Grid layout can save you some time, it adjusts components location and size based on it's container. But note that you do need to set `.Height` property to each components because termui can not decide it for you.
|
||||
|
||||
|
||||
Absolute Layout
|
||||
---
|
||||
|
||||
Grid Layout
|
||||
---
|
||||
|
||||
Magic Variables
|
||||
---
|
|
@ -1,80 +0,0 @@
|
|||
Installation
|
||||
---
|
||||
|
||||
Since [termui](https://github.com/gizak/termui) is a Go lib, we will need a working Go environment to begin with. If you have not set it up, there is a great intro you can follow up: [How to write Go code](https://golang.org/doc/code.html).
|
||||
|
||||
Once you have the environment set up, you can proceed to install termui by the following command:
|
||||
|
||||
`go get github.com/gizak/termui`
|
||||
|
||||
The current version of termui is v2. If you are working with the old version of termui or the new version does not seem right to you, you can always go back to v1 version by:
|
||||
|
||||
`go get gopkg.in/gizak/termui.v1`
|
||||
|
||||
!!! note
|
||||
v2 has many features implemented which you can not find in v1, such as new event system and asynchronous rendering. To find more about versions difference in section [Versions](versions.md).
|
||||
|
||||
|
||||
Usage
|
||||
---
|
||||
|
||||
Let's throw an simple example to get our feet wet:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import ui "github.com/gizak/termui" // use ui as an alias
|
||||
|
||||
func main() {
|
||||
err := ui.Init()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer ui.Close()
|
||||
|
||||
p := ui.NewPar(":PRESS q TO QUIT DEMO")
|
||||
p.Height = 3
|
||||
p.Width = 50
|
||||
p.TextFgColor = ui.ColorWhite
|
||||
p.BorderLabel = "Text Box"
|
||||
p.BorderFg = ui.ColorCyan
|
||||
|
||||
ui.Render(p) // feel free to call Render, it's async and non-block
|
||||
|
||||
ui.Handle("/sys/kbd/q",func(e ui.Event){
|
||||
ui.StopLoop()
|
||||
})
|
||||
|
||||
ui.Loop()
|
||||
}
|
||||
```
|
||||
There are only around 20 lines for the main function. Break this down into 4 parts:
|
||||
|
||||
1. __Init termui__:
|
||||
`ui.Init()` initializes the termui. From this point, termui will take over your terminal display.
|
||||
`ui.Close()` closes resources and cleans up your terminal content. Make sure it is called before exit or you will end up with a messed up looking terminal.
|
||||
|
||||
2. __Build your component__:
|
||||
`ui.NewPar(:PRESS q TO QUIT DEMO)` returns a structure representing a paragraph component. You can assign position, size, text colour, border and many other properties to a component.
|
||||
|
||||
3. __Draw your component on display__:
|
||||
`ui.Render(p)` renders p onto terminal display.
|
||||
|
||||
4. __Handle events__:
|
||||
`ui.Handle("/sys/kbd/q", func(e Event))` registers an event handler for event: key q is pressed.
|
||||
`ui.StopLoop()` exits the event listening loop invoked by `ui.Loop()`.
|
||||
`ui.Loop()` makes the program stops at here and start listening & handling events. Call
|
||||
`ui.StopLoop()` to leave the circle.
|
||||
|
||||
The example code gives us:
|
||||
|
||||
> ![example screenshot](img/demo1.png)
|
||||
|
||||
Now you can press q to quit the program.
|
||||
|
||||
After knowing of some basics, next we can discover more about:
|
||||
|
||||
1. how to set component location in [Layouts](layouts.md)
|
||||
2. how to capture and handle events in [Events](events.md)
|
||||
3. the different [components](components.md)
|
||||
4. check out some real world examples in [recipes](recipes.md)
|
|
@ -1 +0,0 @@
|
|||
_Sorry, it is still Work in Progress..._
|
28
mkdocs.yml
28
mkdocs.yml
|
@ -1,28 +0,0 @@
|
|||
pages:
|
||||
- Home: 'index.md'
|
||||
- Quickstart: 'quickstart.md'
|
||||
- Recipes: 'recipes.md'
|
||||
- References:
|
||||
- Layouts: 'layouts.md'
|
||||
- Components: 'components.md'
|
||||
- Events: 'events.md'
|
||||
- Themes: 'themes.md'
|
||||
- Versions: 'versions.md'
|
||||
- About: 'about.md'
|
||||
|
||||
site_name: termui
|
||||
repo_url: https://github.com/gizak/termui/
|
||||
site_description: 'termui user guide'
|
||||
site_author: gizak
|
||||
|
||||
docs_dir: '_docs'
|
||||
|
||||
theme: readthedocs
|
||||
|
||||
markdown_extensions:
|
||||
- smarty
|
||||
- admonition
|
||||
- toc
|
||||
|
||||
extra:
|
||||
version: 1.0
|
Loading…
Reference in New Issue