- // Display everything
- screen.Screen.Fill(' ', config.DefStyle)
- screen.Screen.HideCursor()
- action.Tabs.Display()
- for _, ep := range action.MainTab().Panes {
- ep.Display()
- }
- action.MainTab().Display()
- action.InfoBar.Display()
- screen.Screen.Show()
-
- event = nil
-
- // Check for new events
- select {
- case f := <-shell.Jobs:
- // If a new job has finished while running in the background we should execute the callback
- f.Function(f.Output, f.Args...)
- case <-config.Autosave:
- for _, b := range buffer.OpenBuffers {
- b.Save()
+ DoEvent()
+ }
+}
+
+// DoEvent runs the main action loop of the editor
+func DoEvent() {
+ var event tcell.Event
+
+ // recover from errors without crashing the editor
+ defer func() {
+ if err := recover(); err != nil {
+ if e, ok := err.(*lua.ApiError); ok {
+ screen.TermMessage("Lua API error:", e)
+ } else {
+ screen.TermMessage("Micro encountered an error:", errors.Wrap(err, 2).ErrorStack(), "\nIf you can reproduce this error, please report it at https://github.com/zyedidia/micro/issues")