From a70fb9db7dff7c6fdb7e7ae108bde5ee6813801a Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Sun, 21 May 2017 10:30:26 -0400 Subject: [PATCH] Test suspend code --- cmd/micro/actions.go | 2 ++ cmd/micro/actions_linux.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 cmd/micro/actions_linux.go diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index a4aab016..05f3bd20 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -837,6 +837,8 @@ func (v *View) Find(usePlugin bool) bool { return true } +func (v *View) Suspend(usePlugin bool) bool { return false } + // FindNext searches forwards for the last used search term func (v *View) FindNext(usePlugin bool) bool { if usePlugin && !PreActionCall("FindNext", v) { diff --git a/cmd/micro/actions_linux.go b/cmd/micro/actions_linux.go new file mode 100644 index 00000000..01649f7d --- /dev/null +++ b/cmd/micro/actions_linux.go @@ -0,0 +1,33 @@ +package main + +import "syscall" + +func (v *View) Suspend(usePlugin bool) bool { + if usePlugin && !PreActionCall("Suspend", v) { + return false + } + + screenWasNil := screen == nil + + if !screenWasNil { + screen.Fini() + screen = nil + } + + // suspend the process + pid := syscall.Getpid() + tid := syscall.Gettid() + err := syscall.Tgkill(pid, tid, syscall.SIGSTOP) + if err != nil { + panic(err) + } + + if !screenWasNil { + InitScreen() + } + + if usePlugin { + return PostActionCall("Suspend", v) + } + return true +}