697baf37a8
When building forms the label field is typically quite short, just one or two words. For checkboxes it is often desirable to have a longer descriptive piece of text. This is not practical to use as a label and in many applications would more commonly be placed to the right of the checkbox. This adds support for a "SetMessage()" method which provides support for text adjacent to the checkbox As an example, this form shows one usage pattern, where the checkbox is used to require case sensitive matching of the author name query. In this case the checkbox label is an empty string, and the message text is used instead: ╔════════════ User filtering ════════════════════╗ ║ ║ ║ Age: ________ ║ ║ ║ ║ Author: ______________ ║ ║ ║ ║ X Case sensitive ║ ║ ║ ║ Apply Cancel ║ ╚════════════════════════════════════════════════╝ Another pattern is where there are a series of checkboxes, all related to the same attribute. Thus they have a common form label but different message text ╔════════════ Request filtering ═════════════════╗ ║ ║ ║ State: X Opened ║ ║ ║ ║ _ Closed ║ ║ ║ ║ _ Merged ║ ║ ║ ║ X Locked ║ ║ ║ ║ Apply Cancel ║ ╚════════════════════════════════════════════════╝ Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> |
||
---|---|---|
.builds | ||
demos | ||
.gitignore | ||
CHANGELOG | ||
CONTRIBUTING.md | ||
FORK.md | ||
LICENSE | ||
README.md | ||
ansi.go | ||
application.go | ||
borders.go | ||
box.go | ||
button.go | ||
checkbox.go | ||
cview.gif | ||
doc.go | ||
dropdown.go | ||
events.go | ||
flex.go | ||
focusable.go | ||
form.go | ||
frame.go | ||
go.mod | ||
go.sum | ||
grid.go | ||
inputfield.go | ||
list.go | ||
modal.go | ||
pages.go | ||
primitive.go | ||
semigraphics.go | ||
styles.go | ||
table.go | ||
textview.go | ||
treeview.go | ||
util.go |
README.md
cview
Terminal-based user interface toolkit
This package is a fork of tview. See FORK.md for more information.
Demo
Try the demo: ssh cview.rocketnine.space -p 20000
Features
Available widgets:
- Input forms (including input/password fields, drop-down selections, checkboxes, and buttons)
- Navigable multi-color text views
- Sophisticated navigable table views
- Flexible tree views
- Selectable lists
- Grid, Flexbox and page layouts
- Modal message windows
- An application wrapper
Widgets may be customized and extended to suit any application.
Initial mouse support has been implemented.
Installation
go get git.sr.ht/~tslocum/cview
Hello World
This basic example creates a box titled "Hello, World!" and displays it in your terminal:
package main
import (
"git.sr.ht/~tslocum/cview"
)
func main() {
box := cview.NewBox().SetBorder(true).SetTitle("Hello, world!")
if err := cview.NewApplication().SetRoot(box, true).Run(); err != nil {
panic(err)
}
}
Examples are available in the "demos" subdirectory.
For a presentation highlighting the features of this package, compile and run the program in the "demos/presentation" subdirectory.
Documentation
Package documentation is available on godoc.
Dependencies
This package is based on github.com/gdamore/tcell (and its dependencies) and github.com/rivo/uniseg.
Support
CONTRIBUTING.md describes how to share issues, suggestions and patches (pull requests).
cview has two mailing lists:
- cview-discuss for general discussion
- cview-dev for development discussion