]> git.lizzy.rs Git - micro.git/commitdiff
Use shell job for terminal callback
authorZachary Yedidia <zyedidia@gmail.com>
Fri, 19 Aug 2022 22:46:01 +0000 (15:46 -0700)
committerZachary Yedidia <zyedidia@gmail.com>
Fri, 19 Aug 2022 22:46:01 +0000 (15:46 -0700)
Fixes #2529

cmd/micro/micro.go
internal/screen/screen.go
internal/shell/terminal.go

index 4af1d295e4d354d497f54d61b8813f62404bef75..e05902440ba2148c20459edb7d343c1eb1b3b122 100644 (file)
@@ -388,7 +388,6 @@ func DoEvent() {
        var event tcell.Event
 
        // Display everything
-       screen.DrawLock.Lock()
        screen.Screen.Fill(' ', config.DefStyle)
        screen.Screen.HideCursor()
        action.Tabs.Display()
@@ -398,7 +397,6 @@ func DoEvent() {
        action.MainTab().Display()
        action.InfoBar.Display()
        screen.Screen.Show()
-       screen.DrawLock.Unlock()
 
        // Check for new events
        select {
index 0f1cd64b0ab57afe8a0ed87c492cc0621804c531..967e8617e1c9ab7d9f9b4dbd3915323007af721d 100644 (file)
@@ -24,7 +24,6 @@ var Events chan (tcell.Event)
 
 // The lock is necessary since the screen is polled on a separate thread
 var lock sync.Mutex
-var DrawLock sync.Mutex
 
 // drawChan is a channel that will cause the screen to redraw when
 // written to even if no event user event has occurred
@@ -121,7 +120,6 @@ func TempFini() bool {
        if !screenWasNil {
                Screen.Fini()
                Lock()
-               DrawLock.Lock()
                Screen = nil
        }
        return screenWasNil
@@ -132,7 +130,6 @@ func TempStart(screenWasNil bool) {
        if !screenWasNil {
                Init()
                Unlock()
-               DrawLock.Unlock()
        }
 }
 
index 4de8de23ed92a1f4afe096312e994630d0dacadd..8dd8c088ef4db73c4f071a31f4884c95ab887f7b 100644 (file)
@@ -128,7 +128,13 @@ func (t *Terminal) Close() {
        // call the lua function that the user has given as a callback
        if t.getOutput {
                if t.callback != nil {
-                       t.callback(t.output.String())
+                       Jobs <- JobFunction{
+                               Function: func(out string, args []interface{}) {
+                                       t.callback(out)
+                               },
+                               Output: t.output.String(),
+                               Args:   nil,
+                       }
                }
        }
 }