Don't expose draw channel to outside packages

This commit is contained in:
Zachary Yedidia 2020-02-11 20:39:26 -05:00
parent 7c77927913
commit 1a64ffb88b
2 changed files with 12 additions and 7 deletions

View File

@ -278,8 +278,8 @@ func main() {
// clear the drawchan so we don't redraw excessively
// if someone requested a redraw before we started displaying
for len(screen.DrawChan) > 0 {
<-screen.DrawChan
for len(screen.DrawChan()) > 0 {
<-screen.DrawChan()
}
// wait for initial resize event
@ -334,7 +334,7 @@ func DoEvent() {
}
case <-shell.CloseTerms:
case event = <-events:
case <-screen.DrawChan:
case <-screen.DrawChan():
}
if action.InfoBar.HasPrompt {

View File

@ -21,9 +21,9 @@ var Screen tcell.Screen
// The lock is necessary since the screen is polled on a separate thread
var lock sync.Mutex
// DrawChan is a channel that will cause the screen to redraw when
// drawChan is a channel that will cause the screen to redraw when
// written to even if no event user event has occurred
var DrawChan chan bool
var drawChan chan bool
// Lock locks the screen lock
func Lock() {
@ -38,12 +38,17 @@ func Unlock() {
// Redraw schedules a redraw with the draw channel
func Redraw() {
select {
case DrawChan <- true:
case drawChan <- true:
default:
// channel is full
}
}
// DrawChan returns the draw channel
func DrawChan() chan bool {
return drawChan
}
type screenCell struct {
x, y int
r rune
@ -122,7 +127,7 @@ func TempStart(screenWasNil bool) {
// Init creates and initializes the tcell screen
func Init() {
DrawChan = make(chan bool)
drawChan = make(chan bool)
// Should we enable true color?
truecolor := os.Getenv("MICRO_TRUECOLOR") == "1"