]> git.lizzy.rs Git - micro.git/commitdiff
Don't expose draw channel to outside packages
authorZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 01:39:26 +0000 (20:39 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Wed, 12 Feb 2020 01:39:26 +0000 (20:39 -0500)
cmd/micro/micro.go
internal/screen/screen.go

index 19ab25d583a7db6fd4137020f339fe36b20b53fe..950e88888ec211b2876d96a39d3ffbba8dc0d053 100644 (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 {
index f601af1cc6f01cc9c45af2d7df9a02c08412ba3a..19f9bd8c62ab35825cd08bcd3bcba6bf89eff805 100644 (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"