Fix EventStream.match randomness behaviour
This commit is contained in:
parent
e89b10ff4f
commit
1cb28b0a3c
@ -1,19 +0,0 @@
|
|||||||
// +build ignore
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "github.com/gizak/termui"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
termui.Init()
|
|
||||||
|
|
||||||
termui.UseTheme("helloworld")
|
|
||||||
b := termui.NewBlock()
|
|
||||||
b.Width = 20
|
|
||||||
b.Height = 30
|
|
||||||
b.BorderLabel = "[HELLO](fg-red,bg-white) [WORLD](fg-blue,bg-green)"
|
|
||||||
|
|
||||||
termui.Render(b)
|
|
||||||
<-termui.EventCh()
|
|
||||||
termui.Close()
|
|
||||||
}
|
|
||||||
125
events.go
125
events.go
@ -9,8 +9,8 @@
|
|||||||
package termui
|
package termui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -145,32 +145,12 @@ func NewSysEvtCh() chan Event {
|
|||||||
|
|
||||||
var DefaultEvtStream = NewEvtStream()
|
var DefaultEvtStream = NewEvtStream()
|
||||||
|
|
||||||
/*
|
|
||||||
type evtCtl struct {
|
|
||||||
in chan Event
|
|
||||||
out chan Event
|
|
||||||
suspend chan int
|
|
||||||
recover chan int
|
|
||||||
close chan int
|
|
||||||
}
|
|
||||||
|
|
||||||
func newEvtCtl() evtCtl {
|
|
||||||
ec := evtCtl{}
|
|
||||||
ec.in = make(chan Event)
|
|
||||||
ec.suspend = make(chan int)
|
|
||||||
ec.recover = make(chan int)
|
|
||||||
ec.close = make(chan int)
|
|
||||||
ec.out = make(chan Event)
|
|
||||||
return ec
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
type EvtStream struct {
|
type EvtStream struct {
|
||||||
|
sync.RWMutex
|
||||||
srcMap map[string]chan Event
|
srcMap map[string]chan Event
|
||||||
stream chan Event
|
stream chan Event
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
sigStopLoop chan int
|
sigStopLoop chan Event
|
||||||
Handlers map[string]func(Event)
|
Handlers map[string]func(Event)
|
||||||
}
|
}
|
||||||
|
|
||||||