mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-10 14:42:47 +09:00
36 lines
752 B
Go
36 lines
752 B
Go
// +build linux darwin dragonfly solaris openbsd netbsd freebsd
|
|
|
|
package main
|
|
|
|
import (
|
|
"syscall"
|
|
|
|
"github.com/zyedidia/micro/cmd/micro/screen"
|
|
"github.com/zyedidia/micro/cmd/micro/util"
|
|
)
|
|
|
|
// Suspend sends micro to the background. This is the same as pressing CtrlZ in most unix programs.
|
|
// This only works on linux and has no default binding.
|
|
// This code was adapted from the suspend code in nsf/godit
|
|
func (*BufActionHandler) Suspend() bool {
|
|
screenWasNil := screen.Screen == nil
|
|
|
|
if !screenWasNil {
|
|
screen.Screen.Fini()
|
|
screen.Screen = nil
|
|
}
|
|
|
|
// suspend the process
|
|
pid := syscall.Getpid()
|
|
err := syscall.Kill(pid, syscall.SIGSTOP)
|
|
if err != nil {
|
|
util.TermMessage(err)
|
|
}
|
|
|
|
if !screenWasNil {
|
|
screen.Init()
|
|
}
|
|
|
|
return false
|
|
}
|