gocui/README.md

140 lines
4.9 KiB
Markdown
Raw Normal View History

# GOCUI - Go Console User Interface
2020-12-24 14:45:26 +11:00
[![CircleCI](https://circleci.com/gh/awesome-gocui/gocui/tree/master.svg?style=svg)](https://circleci.com/gh/awesome-gocui/gocui/tree/master)
[![CodeCov](https://codecov.io/gh/awesome-gocui/gocui/branch/master/graph/badge.svg)](https://codecov.io/gh/awesome-gocui/gocui)
[![Go Report Card](https://goreportcard.com/badge/github.com/awesome-gocui/gocui)](https://goreportcard.com/report/github.com/awesome-gocui/gocui)
[![GolangCI](https://golangci.com/badges/github.com/awesome-gocui/gocui.svg)](https://golangci.com/badges/github.com/awesome-gocui/gocui.svg)
[![GoDoc](https://godoc.org/github.com/awesome-gocui/gocui?status.svg)](https://godoc.org/github.com/awesome-gocui/gocui)
![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/awesome-gocui/gocui.svg)
2016-02-01 15:36:10 +01:00
2014-01-28 09:36:57 +01:00
Minimalist Go package aimed at creating Console User Interfaces.
2020-12-24 14:45:26 +11:00
A community fork based on the amazing work of [jroimartin](https://github.com/jroimartin/gocui)
2014-01-04 03:48:48 +01:00
2015-01-24 14:35:23 +01:00
## Features
2014-01-19 17:42:51 +01:00
2014-01-28 09:36:57 +01:00
* Minimalist API.
* Views (the "windows" in the GUI) implement the interface io.ReadWriter.
2014-01-28 09:36:57 +01:00
* Support for overlapping views.
* The GUI can be modified at runtime (concurrent-safe).
2014-01-28 09:36:57 +01:00
* Global and view-level keybindings.
* Mouse support.
2016-04-28 01:22:15 +02:00
* Colored text.
2020-12-24 14:45:26 +11:00
* Customizable editing mode.
2016-10-25 11:41:17 +02:00
* Easy to build reusable widgets, complex layouts...
2020-12-24 14:45:26 +11:00
## About fork
This fork has many improvements over the original work from [jroimartin](https://github.com/jroimartin/gocui).
* Written ontop of TCell
* Better wide character support
* Support for 1 Line height views
* Better support for running in docker container
* Customize frame colors
* Improved code comments and quality
* Many small improvements
* Change Visibility of views
For information about this org see: [awesome-gocui/about](https://github.com/awesome-gocui/about).
## Installation
2016-02-01 15:36:10 +01:00
Execute:
```
2020-12-24 14:45:26 +11:00
$ go get github.com/awesome-gocui/gocui
2016-02-01 15:36:10 +01:00
```
## Documentation
Execute:
2016-02-01 15:36:10 +01:00
```
2020-12-24 14:45:26 +11:00
$ go doc github.com/awesome-gocui/gocui
2016-02-01 15:36:10 +01:00
```
2020-12-24 14:45:26 +11:00
Or visit [godoc.org](https://godoc.org/github.com/awesome-gocui/gocui) to read it
2016-02-01 15:39:59 +01:00
online.
2014-01-28 09:36:57 +01:00
2015-01-24 14:35:23 +01:00
## Example
2020-12-24 14:45:26 +11:00
See the [_example](./_example/) folder for more examples
2015-01-24 14:35:23 +01:00
```go
package main
import (
"fmt"
"log"
2020-12-24 14:45:26 +11:00
"github.com/awesome-gocui/gocui"
)
2015-01-24 14:35:23 +01:00
func main() {
2020-12-24 14:45:26 +11:00
g, err := gocui.NewGui(gocui.OutputNormal, true)
2016-10-24 07:26:59 +02:00
if err != nil {
2015-01-24 14:35:23 +01:00
log.Panicln(err)
2014-01-19 17:42:51 +01:00
}
2015-01-24 14:35:23 +01:00
defer g.Close()
g.SetManagerFunc(layout)
2015-01-24 14:35:23 +01:00
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
log.Panicln(err)
}
2020-12-24 14:45:26 +11:00
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
2015-01-24 14:35:23 +01:00
log.Panicln(err)
2014-01-19 17:42:51 +01:00
}
2015-01-24 14:35:23 +01:00
}
func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
2020-12-24 14:45:26 +11:00
if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
2020-12-24 14:45:26 +11:00
if _, err := g.SetCurrentView("hello"); err != nil {
return err
}
fmt.Fprintln(v, "Hello world!")
}
2020-12-24 14:45:26 +11:00
return nil
}
func quit(g *gocui.Gui, v *gocui.View) error {
return gocui.ErrQuit
}
```
2015-02-01 17:23:04 +01:00
## Screenshots
2016-10-16 18:54:00 +02:00
![r2cui](https://cloud.githubusercontent.com/assets/1223476/19418932/63645052-93ce-11e6-867c-da5e97e37237.png)
2015-02-01 17:23:04 +01:00
![_examples/demo.go](https://cloud.githubusercontent.com/assets/1223476/5992750/720b84f0-aa36-11e4-88ec-296fa3247b52.png)
![_examples/dynamic.go](https://cloud.githubusercontent.com/assets/1223476/5992751/76ad5cc2-aa36-11e4-8204-6a90269db827.png)
## Projects using gocui
2017-08-19 20:43:14 +02:00
* [komanda-cli](https://github.com/mephux/komanda-cli): IRC Client For Developers.
* [vuls](https://github.com/future-architect/vuls): Agentless vulnerability scanner for Linux/FreeBSD.
2017-02-10 22:59:00 +01:00
* [wuzz](https://github.com/asciimoo/wuzz): Interactive cli tool for HTTP inspection.
2017-03-07 08:45:14 +01:00
* [httplab](https://github.com/gchaincl/httplab): Interactive web server.
* [domainr](https://github.com/MichaelThessel/domainr): Tool that checks the availability of domains based on keywords.
2017-08-15 21:52:03 +02:00
* [gotime](https://github.com/nanohard/gotime): Time tracker for projects and tasks.
2017-08-17 00:04:36 +02:00
* [claws](https://github.com/thehowl/claws): Interactive command line client for testing websockets.
2017-08-19 20:43:14 +02:00
* [terminews](http://github.com/antavelos/terminews): Terminal based RSS reader.
2017-08-20 15:22:33 +02:00
* [diagram](https://github.com/esimov/diagram): Tool to convert ascii arts into hand drawn diagrams.
2017-08-27 16:52:36 +02:00
* [pody](https://github.com/JulienBreux/pody): CLI app to manage Pods in a Kubernetes cluster.
2018-03-11 18:15:46 +01:00
* [kubexp](https://github.com/alitari/kubexp): Kubernetes client.
* [kcli](https://github.com/cswank/kcli): Tool for inspecting kafka topics/partitions/messages.
* [fac](https://github.com/mkchoi212/fac): git merge conflict resolver
2018-04-01 16:17:21 +02:00
* [jsonui](https://github.com/gulyasm/jsonui): Interactive JSON explorer for your terminal.
2018-04-02 10:05:22 -07:00
* [cointop](https://github.com/miguelmota/cointop): Interactive terminal based UI application for tracking cryptocurrencies.
2020-12-24 14:45:26 +11:00
* [lazygit](https://github.com/jesseduffield/lazygit): simple terminal UI for git commands.
* [lazydocker](https://github.com/jesseduffield/lazydocker): The lazier way to manage everything docker.
Note: if your project is not listed here, let us know! :)