git://git.iain.cx/iain
/
pstop.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
28f3ee4
)
move termbox.Events generator into screen
author
Simon J Mudd
<sjmudd@pobox.com>
Tue, 24 Feb 2015 08:29:26 +0000
(09:29 +0100)
committer
Simon J Mudd
<sjmudd@pobox.com>
Tue, 24 Feb 2015 08:29:26 +0000
(09:29 +0100)
app/app.go
patch
|
blob
|
history
screen/screen.go
patch
|
blob
|
history
diff --git
a/app/app.go
b/app/app.go
index
c6c43bf
..
3588133
100644
(file)
--- a/
app/app.go
+++ b/
app/app.go
@@
-496,18
+496,6
@@
func (app *App) Cleanup() {
}
}
}
}
-// make chan for termbox events and run a poller to send events to the channel
-// - return the channel
-func new_tb_chan() chan termbox.Event {
- termboxChan := make(chan termbox.Event)
- go func() {
- for {
- termboxChan <- termbox.PollEvent()
- }
- }()
- return termboxChan
-}
-
// get into a run loop
func (app *App) Run() {
app.done = make(chan struct{})
// get into a run loop
func (app *App) Run() {
app.done = make(chan struct{})
@@
-518,7
+506,7
@@
func (app *App) Run() {
app.wi.SetWaitInterval(time.Second)
app.wi.SetWaitInterval(time.Second)
- termboxChan :=
new_tb_c
han()
+ termboxChan :=
app.screen.TermBoxC
han()
for !app.Finished() {
select {
for !app.Finished() {
select {
diff --git
a/screen/screen.go
b/screen/screen.go
index
c29c6ba
..
0478b46
100644
(file)
--- a/
screen/screen.go
+++ b/
screen/screen.go
@@
-114,3
+114,15
@@
func (s *TermboxScreen) SetSize(width, height int) {
func (s *TermboxScreen) Size() (int, int) {
return s.width, s.height
}
func (s *TermboxScreen) Size() (int, int) {
return s.width, s.height
}
+
+// create a channel for termbox.Events and run a poller to send
+// these events to the channel. Return the channel.
+func (s TermboxScreen) TermBoxChan() chan termbox.Event {
+ termboxChan := make(chan termbox.Event)
+ go func() {
+ for {
+ termboxChan <- termbox.PollEvent()
+ }
+ }()
+ return termboxChan
+}