Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge jesseduffields master #8

Merged
merged 37 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f50da5a
Visually wide character support
frizinak Nov 5, 2016
8e407b7
default to input mode of InputEsc
jesseduffield Jun 5, 2018
d1cbd48
Ignore char keys when in an editable panel
jesseduffield Jun 5, 2018
d9a7952
bold highlighted text
jesseduffield Jun 5, 2018
8d3fcc6
support collapsed edges (WIP)
jesseduffield Aug 5, 2018
e572e63
revert bolding of box character
jesseduffield Aug 5, 2018
1dc2347
disable overlapping views for now
jesseduffield Aug 5, 2018
c50a372
defining overlapping edge support in the Gui constructor
jesseduffield Aug 5, 2018
2fb90d3
make view dimensions accessible
jesseduffield Aug 12, 2018
a80ffd8
use dimensions method rather than function
jesseduffield Aug 12, 2018
6c1b364
flush the gui before polling for any events
jesseduffield Aug 13, 2018
f27fbaa
enforce that keybindings can only be handled by a single handler, pri…
jesseduffield Aug 21, 2018
b2e97d2
ignore global rune keybindings on editable views
jesseduffield Aug 24, 2018
32c5b9b
move cursor directly rather than through function because the old way…
jesseduffield Sep 5, 2018
4ff4056
support subtitles on panels
jesseduffield Sep 5, 2018
d6ff636
use jesse's fork of termbox which handles poll event errors
jesseduffield Sep 19, 2018
6aacc83
view.go: add ViewLinesHeight()
remyabel2 Sep 17, 2018
44898ff
missed a couple of imports that I need to switch to my fork of termbox
jesseduffield Sep 19, 2018
4869a57
use LinesHeight instead of ViewLinesHeight
jesseduffield Sep 21, 2018
9673d56
convert tab runes to 4 spaces
jesseduffield Dec 9, 2018
6c25764
don't truncate lines on wrapped views
jesseduffield Jan 15, 2019
219f0b0
use go-errors package to give stack traces to new errors
jesseduffield Feb 11, 2019
53e7c0b
use standard errors when defining package level errors and wrap when …
jesseduffield Feb 15, 2019
605f01c
add loader animations to views with the HasLoader bool set
jesseduffield Feb 15, 2019
569bfa3
stop polling termbox events after closing the gui
jesseduffield Mar 3, 2019
106cbe4
fix performance issue causing high cpu drain
jesseduffield Mar 5, 2019
b2f96ac
don't write subtitle outside of view's bounds
jesseduffield Apr 9, 2019
95d85f5
support views of height 1 or even negative height
jesseduffield Apr 26, 2019
62396a4
Merge remote-tracking branch 'origin/master' into merge-jesseduffield…
mjarkk Apr 27, 2019
14f6d58
Changed the user imports to the organizations it's repo
mjarkk Apr 27, 2019
fb41ca5
Made examples compilable
mjarkk Apr 27, 2019
563a1c8
Most examples work but there are still problems
mjarkk Apr 27, 2019
8bdd321
The examples now don't error on exit
mjarkk Apr 28, 2019
76fa877
The examples now don't error on exit
mjarkk Apr 28, 2019
059fa98
Made the gobot happy
mjarkk Apr 28, 2019
9a62783
Added note at the top of the stdin example
mjarkk Apr 28, 2019
c62d980
Moved to loader to component
mjarkk Apr 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Or visit [godoc.org](https://godoc.org/github.com/awesome-gocui/gocui) to read i
online.

## Example
See the [_example](./_example/) folder for more examples

```go
package main
Expand All @@ -60,18 +61,21 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}

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 {
if !gocui.IsUnknownView(err) {
return err
}
fmt.Fprintln(v, "Hello world!")
if _, err := g.SetCurrentView("hello"); err != nil {
return err
}
}
return nil
}
Expand Down
20 changes: 10 additions & 10 deletions _examples/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func nextView(g *gocui.Gui, v *gocui.View) error {

func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("v1", 0, 0, maxX/2-1, maxY/2-1); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("v1", 0, 0, maxX/2-1, maxY/2-1, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Title = "v1 (editable)"
Expand All @@ -62,25 +62,25 @@ func layout(g *gocui.Gui) error {
}
}

if v, err := g.SetView("v2", maxX/2-1, 0, maxX-1, maxY/2-1); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("v2", maxX/2-1, 0, maxX-1, maxY/2-1, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Title = "v2"
v.Wrap = true
v.Autoscroll = true
}
if v, err := g.SetView("v3", 0, maxY/2-1, maxX/2-1, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("v3", 0, maxY/2-1, maxX/2-1, maxY-1, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Title = "v3"
v.Wrap = true
v.Autoscroll = true
fmt.Fprint(v, "Press TAB to change current view")
}
if v, err := g.SetView("v4", maxX/2, maxY/2, maxX-1, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("v4", maxX/2, maxY/2, maxX-1, maxY-1, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Title = "v4 (editable)"
Expand All @@ -94,7 +94,7 @@ func quit(g *gocui.Gui, v *gocui.View) error {
}

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -113,7 +113,7 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}
8 changes: 4 additions & 4 deletions _examples/bufs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func overwrite(g *gocui.Gui, v *gocui.View) error {

func layout(g *gocui.Gui) error {
_, maxY := g.Size()
if v, err := g.SetView("main", 0, 0, 20, maxY-1); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("main", 0, 0, 20, maxY-1, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Editable = true
Expand All @@ -42,7 +42,7 @@ func layout(g *gocui.Gui) error {
}

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -59,7 +59,7 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}

Expand Down
11 changes: 7 additions & 4 deletions _examples/colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -24,22 +24,25 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}

func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("colors", maxX/2-7, maxY/2-12, maxX/2+7, maxY/2+13); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("colors", maxX/2-7, maxY/2-12, maxX/2+7, maxY/2+13, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
for i := 0; i <= 7; i++ {
for _, j := range []int{1, 4, 7} {
fmt.Fprintf(v, "Hello \033[3%d;%dmcolors!\033[0m\n", i, j)
}
}
if _, err := g.SetCurrentView("colors"); err != nil {
return err
}
}
return nil
}
Expand Down
11 changes: 7 additions & 4 deletions _examples/colors256.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func main() {
g, err := gocui.NewGui(gocui.Output256)
g, err := gocui.NewGui(gocui.Output256, true)

if err != nil {
log.Panicln(err)
Expand All @@ -25,15 +25,15 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}

func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("colors", -1, -1, maxX, maxY); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("colors", -1, -1, maxX, maxY, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}

Expand Down Expand Up @@ -65,6 +65,9 @@ func layout(g *gocui.Gui) error {
ctr++
}
}
if _, err := g.SetCurrentView("colors"); err != nil {
return err
}
}
return nil
}
Expand Down
16 changes: 8 additions & 8 deletions _examples/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func getLine(g *gocui.Gui, v *gocui.View) error {
}

maxX, maxY := g.Size()
if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("msg", maxX/2-30, maxY/2, maxX/2+30, maxY/2+2, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
fmt.Fprintln(v, l)
Expand Down Expand Up @@ -159,8 +159,8 @@ func saveVisualMain(g *gocui.Gui, v *gocui.View) error {

func layout(g *gocui.Gui) error {
maxX, maxY := g.Size()
if v, err := g.SetView("side", -1, -1, 30, maxY); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("side", -1, -1, 30, maxY, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
v.Highlight = true
Expand All @@ -172,8 +172,8 @@ func layout(g *gocui.Gui) error {
fmt.Fprint(v, "\rWill be")
fmt.Fprint(v, "deleted\rItem 4\nItem 5")
}
if v, err := g.SetView("main", 30, -1, maxX, maxY); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("main", 30, -1, maxX, maxY, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
b, err := ioutil.ReadFile("Mark.Twain-Tom.Sawyer.txt")
Expand All @@ -191,7 +191,7 @@ func layout(g *gocui.Gui) error {
}

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -205,7 +205,7 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}
14 changes: 7 additions & 7 deletions _examples/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
)

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -39,16 +39,16 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}

func layout(g *gocui.Gui) error {
maxX, _ := g.Size()
v, err := g.SetView("help", maxX-25, 0, maxX-1, 9)
v, err := g.SetView("help", maxX-25, 0, maxX-1, 9, 0)
if err != nil {
if err != gocui.ErrUnknownView {
if !gocui.IsUnknownView(err) {
return err
}
fmt.Fprintln(v, "KEYBINDINGS")
Expand Down Expand Up @@ -132,9 +132,9 @@ func initKeybindings(g *gocui.Gui) error {
func newView(g *gocui.Gui) error {
maxX, maxY := g.Size()
name := fmt.Sprintf("v%v", idxView)
v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5)
v, err := g.SetView(name, maxX/2-5, maxY/2-5, maxX/2+5, maxY/2+5, 0)
if err != nil {
if err != gocui.ErrUnknownView {
if !gocui.IsUnknownView(err) {
return err
}
v.Wrap = true
Expand Down Expand Up @@ -183,7 +183,7 @@ func moveView(g *gocui.Gui, v *gocui.View, dx, dy int) error {
if err != nil {
return err
}
if _, err := g.SetView(name, x0+dx, y0+dy, x1+dx, y1+dy); err != nil {
if _, err := g.SetView(name, x0+dx, y0+dy, x1+dx, y1+dy, 0); err != nil {
return err
}
return nil
Expand Down
15 changes: 9 additions & 6 deletions _examples/flow_layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ func NewLabel(name string, body string) *Label {
}

func (w *Label) Layout(g *gocui.Gui) error {
v, err := g.SetView(w.name, 0, 0, w.w, w.h)
v, err := g.SetView(w.name, 0, 0, w.w, w.h, 0)
if err != nil {
if err != gocui.ErrUnknownView {
if !gocui.IsUnknownView(err) {
return err
}
fmt.Fprint(v, w.body)
if _, err := g.SetCurrentView(w.name); err != nil {
return err
}
}
return nil
}
Expand All @@ -49,8 +52,8 @@ func flowLayout(g *gocui.Gui) error {
x := 0
for _, v := range views {
w, h := v.Size()
_, err := g.SetView(v.Name(), x, 0, x+w+1, h+1)
if err != nil && err != gocui.ErrUnknownView {
_, err := g.SetView(v.Name(), x, 0, x+w+1, h+1, 0)
if err != nil && !gocui.IsUnknownView(err) {
return err
}
x += w + 2
Expand All @@ -59,7 +62,7 @@ func flowLayout(g *gocui.Gui) error {
}

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -77,7 +80,7 @@ func main() {
log.Panicln(err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}
}
Expand Down
11 changes: 7 additions & 4 deletions _examples/goroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var (
)

func main() {
g, err := gocui.NewGui(gocui.OutputNormal)
g, err := gocui.NewGui(gocui.OutputNormal, true)
if err != nil {
log.Panicln(err)
}
Expand All @@ -41,19 +41,22 @@ func main() {
go counter(g)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
if err := g.MainLoop(); err != nil && !gocui.IsQuit(err) {
log.Panicln(err)
}

wg.Wait()
}

func layout(g *gocui.Gui) error {
if v, err := g.SetView("ctr", 2, 2, 12, 4); err != nil {
if err != gocui.ErrUnknownView {
if v, err := g.SetView("ctr", 2, 2, 12, 4, 0); err != nil {
if !gocui.IsUnknownView(err) {
return err
}
fmt.Fprintln(v, "0")
if _, err := g.SetCurrentView("ctr"); err != nil {
return err
}
}
return nil
}
Expand Down
Loading