2016-01-30 02:54:26 +01:00
|
|
|
# GOCUI - Go Console User Interface
|
2013-12-27 21:36:26 +01:00
|
|
|
|
2021-08-14 19:11:29 +02:00
|
|
|
[](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.
|
2016-01-30 02:54:26 +01:00
|
|
|
* Views (the "windows" in the GUI) implement the interface io.ReadWriter.
|
2014-01-28 09:36:57 +01:00
|
|
|
* Support for overlapping views.
|
2016-01-30 02:54:26 +01:00
|
|
|
* The GUI can be modified at runtime (concurrent-safe).
|
2014-01-28 09:36:57 +01:00
|
|
|
* Global and view-level keybindings.
|
2016-01-30 02:54:26 +01:00
|
|
|
* Mouse support.
|
2016-04-28 01:22:15 +02:00
|
|
|
* Colored text.
|
2016-01-30 02:54:26 +01:00
|
|
|
* Customizable edition mode.
|
2016-10-25 11:41:17 +02:00
|
|
|
* Easy to build reusable widgets, complex layouts...
|
2016-01-30 02:54:26 +01:00
|
|
|
|
|
|
|
## 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:
|
2016-01-30 02:54:26 +01:00
|
|
|
|
2024-09-01 15:19:34 -03:00
|
|
|
```sh
|
|
|
|
go doc github.com/jroimartin/gocui
|
2016-02-01 15:36:10 +01:00
|
|
|
```
|
2016-01-30 02:54:26 +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
|
2016-01-30 02:54:26 +01:00
|
|
|
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()
|
2016-01-30 02:54:26 +01:00
|
|
|
|
2016-10-24 08:36:23 +02:00
|
|
|
g.SetManagerFunc(layout)
|
2016-01-30 02:54:26 +01:00
|
|
|
|
2015-01-24 14:35:23 +01:00
|
|
|
if err := g.SetKeybinding("", gocui.KeyCtrlC, gocui.ModNone, quit); err != nil {
|
|
|
|
log.Panicln(err)
|
|
|
|
}
|
2016-01-30 02:54:26 +01:00
|
|
|
|
|
|
|
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
|
|
|
}
|
2016-01-26 10:19:11 +01:00
|
|
|
|
2016-01-30 02:54:26 +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
|
|
|
|
}
|
2016-01-26 10:19:11 +01:00
|
|
|
|
2016-01-30 02:54:26 +01:00
|
|
|
func quit(g *gocui.Gui, v *gocui.View) error {
|
|
|
|
return gocui.ErrQuit
|
|
|
|
}
|
|
|
|
```
|
2016-01-26 10:19:11 +01:00
|
|
|
|
2015-02-01 17:23:04 +01:00
|
|
|
## Screenshots
|
|
|
|
|
2016-10-16 18:54:00 +02:00
|
|
|

|
|
|
|
|
2015-02-01 17:23:04 +01:00
|
|
|

|
|
|
|
|
2016-04-19 10:35:13 +01:00
|
|
|

|
2016-10-16 18:30:11 +02:00
|
|
|
|
|
|
|
## 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.
|
2017-12-29 08:14:27 -07:00
|
|
|
* [kcli](https://github.com/cswank/kcli): Tool for inspecting kafka topics/partitions/messages.
|
2018-01-04 11:11:58 -06:00
|
|
|
* [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.
|
2016-10-16 18:30:11 +02:00
|
|
|
|
|
|
|
Note: if your project is not listed here, let us know! :)
|