From f3916a01581c66961c8e70f79f77c0520bc5a66d Mon Sep 17 00:00:00 2001 From: faiface Date: Fri, 1 Sep 2017 21:50:48 +0200 Subject: layout: simplify the interface even furthur --- layout/interface.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/layout/interface.go b/layout/interface.go index d203c3f..28b6a01 100644 --- a/layout/interface.go +++ b/layout/interface.go @@ -7,24 +7,17 @@ import ( ) type EventDrawer interface { - Event() <-chan EventConsume - Draw(func(draw.Image) image.Rectangle) -} - -type EventConsume struct { - Event - Consume chan<- bool + Event() <-chan Event + Draw() chan<- func(draw.Image) image.Rectangle } type Event string +func Eventf(format string, a ...interface{}) Event { + return Event(fmt.Sprintf(format, a...)) +} + func (e Event) Matches(format string, a ...interface{}) bool { _, err := fmt.Sscanf(string(e), format, a...) return err == nil } - -func SendEvent(ch chan<- EventConsume, format string, a ...interface{}) (consume <-chan bool) { - cons := make(chan bool) - ch <- EventConsume{Event(fmt.Sprintf(format, a...)), cons} - return cons -} -- cgit v1.2.3