Add Event
Port termbox-go Event Hide away termbox-go event dependency Add Event channel multiplexer Adjuest examples Next event system commit will work on fully concurrency on a different branch, master will stay on single rountine
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gizak/termui"
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -32,5 +31,5 @@ func main() {
|
||||
|
||||
termui.Render(bc)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import ui "github.com/gizak/termui"
|
||||
import tm "github.com/nsf/termbox-go"
|
||||
import "math"
|
||||
|
||||
import "time"
|
||||
@@ -128,18 +127,13 @@ func main() {
|
||||
ui.Render(p, list, g, sp, lc, bc, lc1, p1)
|
||||
}
|
||||
|
||||
evt := make(chan tm.Event)
|
||||
go func() {
|
||||
for {
|
||||
evt <- tm.PollEvent()
|
||||
}
|
||||
}()
|
||||
evt := ui.EventCh()
|
||||
|
||||
i := 0
|
||||
for {
|
||||
select {
|
||||
case e := <-evt:
|
||||
if e.Type == tm.EventKey && e.Ch == 'q' {
|
||||
if e.Type == ui.EventKey && e.Ch == 'q' {
|
||||
return
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gizak/termui"
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -50,5 +49,5 @@ func main() {
|
||||
|
||||
termui.Render(g0, g1, g2)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import ui "github.com/gizak/termui"
|
||||
import tm "github.com/nsf/termbox-go"
|
||||
import "math"
|
||||
|
||||
import "time"
|
||||
@@ -99,21 +98,16 @@ func main() {
|
||||
ui.Render(ui.Body)
|
||||
}
|
||||
|
||||
evt := make(chan tm.Event)
|
||||
go func() {
|
||||
for {
|
||||
evt <- tm.PollEvent()
|
||||
}
|
||||
}()
|
||||
evt := ui.EventCh()
|
||||
|
||||
i := 0
|
||||
for {
|
||||
select {
|
||||
case e := <-evt:
|
||||
if e.Type == tm.EventKey && e.Ch == 'q' {
|
||||
if e.Type == ui.EventKey && e.Ch == 'q' {
|
||||
return
|
||||
}
|
||||
if e.Type == tm.EventResize {
|
||||
if e.Type == ui.EventResize {
|
||||
ui.Body.Width = ui.TermWidth()
|
||||
ui.Body.Align()
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
|
||||
"github.com/gizak/termui"
|
||||
)
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -65,5 +64,5 @@ func main() {
|
||||
|
||||
termui.Render(lc0, lc1, lc2)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gizak/termui"
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -38,5 +37,5 @@ func main() {
|
||||
|
||||
termui.Render(ls)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gizak/termui"
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -45,5 +44,5 @@ func main() {
|
||||
|
||||
termui.Render(par0, par1, par2, par3)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import "github.com/gizak/termui"
|
||||
import "github.com/nsf/termbox-go"
|
||||
|
||||
func main() {
|
||||
err := termui.Init()
|
||||
@@ -62,5 +61,5 @@ func main() {
|
||||
|
||||
termui.Render(spls0, spls1, spls2)
|
||||
|
||||
termbox.PollEvent()
|
||||
<-termui.EventCh()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
package main
|
||||
|
||||
import ui "github.com/gizak/termui"
|
||||
import tm "github.com/nsf/termbox-go"
|
||||
import "math"
|
||||
|
||||
import "time"
|
||||
@@ -124,18 +123,12 @@ func main() {
|
||||
ui.Render(p, list, g, sp, lc, bc, lc1, p1)
|
||||
}
|
||||
|
||||
evt := make(chan tm.Event)
|
||||
go func() {
|
||||
for {
|
||||
evt <- tm.PollEvent()
|
||||
}
|
||||
}()
|
||||
|
||||
evt := EventCh()
|
||||
i := 0
|
||||
for {
|
||||
select {
|
||||
case e := <-evt:
|
||||
if e.Type == tm.EventKey && e.Ch == 'q' {
|
||||
if e.Type == ui.EventKey && e.Ch == 'q' {
|
||||
return
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user