gocui/README.md

111 lines
3.3 KiB
Markdown
Raw Permalink Normal View History

# GOCUI - Go Console User Interface
2013-12-27 21:36:26 +01:00
2021-08-14 19:11:29 +02:00
[![Go Reference](https://pkg.go.dev/badge/github.com/jroimartin/gocui.svg)](https://pkg.go.dev/github.com/jroimartin/gocui)
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.
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.
* Customizable edition mode.
2016-10-25 11:41:17 +02:00
* Easy to build reusable widgets, complex layouts...
## Installation
2016-02-01 15:36:10 +01:00
Execute:
2024-09-01 15:19:34 -03:00
```sh
go get github.com/jroimartin/gocui
2016-02-01 15:36:10 +01:00
```
## Documentation
Execute:
2024-09-01 15:19:34 -03:00
```sh
go doc github.com/jroimartin/gocui
2016-02-01 15:36:10 +01:00
```
2021-08-14 19:11:29 +02:00
Or visit [pkg.go.dev](https://pkg.go.dev/github.com/jroimartin/gocui) to read
it online.
2014-01-28 09:36:57 +01:00
2015-01-24 14:35:23 +01:00
## Example
```go
package main
import (
"fmt"
"log"
"github.com/jroimartin/gocui"
)
2015-01-24 14:35:23 +01:00
func main() {
2016-11-13 21:44:48 +01:00
g, err := gocui.NewGui(gocui.OutputNormal)
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)
}
if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
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()
if v, err := g.SetView("hello", maxX/2-7, maxY/2, maxX/2+7, maxY/2+2); err != nil {
if err != gocui.ErrUnknownView {
return err
}
fmt.Fprintln(v, "Hello world!")
}
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.
Note: if your project is not listed here, let us know! :)