mirror of
https://github.com/zyedidia/micro.git
synced 2024-08-17 16:00:43 +03:00
Compare commits
6 Commits
2aa3f10d05
...
df09b8a87a
Author | SHA1 | Date | |
---|---|---|---|
|
df09b8a87a | ||
|
dc7759204b | ||
|
a84aa225ab | ||
|
f05d3582b3 | ||
|
26ae1b95cc | ||
|
e559992309 |
@ -40,8 +40,7 @@ var (
|
|||||||
flagClean = flag.Bool("clean", false, "Clean configuration directory")
|
flagClean = flag.Bool("clean", false, "Clean configuration directory")
|
||||||
optionFlags map[string]*string
|
optionFlags map[string]*string
|
||||||
|
|
||||||
sigterm chan os.Signal
|
sighup chan os.Signal
|
||||||
sighup chan os.Signal
|
|
||||||
|
|
||||||
timerChan chan func()
|
timerChan chan func()
|
||||||
)
|
)
|
||||||
@ -360,9 +359,9 @@ func main() {
|
|||||||
|
|
||||||
screen.Events = make(chan tcell.Event)
|
screen.Events = make(chan tcell.Event)
|
||||||
|
|
||||||
sigterm = make(chan os.Signal, 1)
|
util.Sigterm = make(chan os.Signal, 1)
|
||||||
sighup = make(chan os.Signal, 1)
|
sighup = make(chan os.Signal, 1)
|
||||||
signal.Notify(sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
|
signal.Notify(util.Sigterm, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGABRT)
|
||||||
signal.Notify(sighup, syscall.SIGHUP)
|
signal.Notify(sighup, syscall.SIGHUP)
|
||||||
|
|
||||||
timerChan = make(chan func())
|
timerChan = make(chan func())
|
||||||
@ -437,7 +436,7 @@ func DoEvent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
case <-sigterm:
|
case <-util.Sigterm:
|
||||||
for _, b := range buffer.OpenBuffers {
|
for _, b := range buffer.OpenBuffers {
|
||||||
if !b.Modified() {
|
if !b.Modified() {
|
||||||
b.Fini()
|
b.Fini()
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
shellquote "github.com/kballard/go-shellquote"
|
shellquote "github.com/kballard/go-shellquote"
|
||||||
"github.com/zyedidia/micro/v2/internal/screen"
|
"github.com/zyedidia/micro/v2/internal/screen"
|
||||||
|
"github.com/zyedidia/micro/v2/internal/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExecCommand executes a command using exec
|
// ExecCommand executes a command using exec
|
||||||
@ -95,28 +96,30 @@ func RunInteractiveShell(input string, wait bool, getOutput bool) (string, error
|
|||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
// This is a trap for Ctrl-C so that it doesn't kill micro
|
// This is a trap for Ctrl-C so that it doesn't kill micro
|
||||||
// Instead we trap Ctrl-C to kill the program we're running
|
// micro is killed if the signal is ignored only on Windows, so it is
|
||||||
|
// received
|
||||||
c := make(chan os.Signal, 1)
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Reset(os.Interrupt)
|
||||||
signal.Notify(c, os.Interrupt)
|
signal.Notify(c, os.Interrupt)
|
||||||
go func() {
|
err = cmd.Start()
|
||||||
for range c {
|
if err == nil {
|
||||||
cmd.Process.Kill()
|
err = cmd.Wait()
|
||||||
|
if wait {
|
||||||
|
// This is just so we don't return right away and let the user press enter to return
|
||||||
|
screen.TermMessage("")
|
||||||
}
|
}
|
||||||
}()
|
} else {
|
||||||
|
screen.TermMessage(err)
|
||||||
cmd.Start()
|
}
|
||||||
err = cmd.Wait()
|
|
||||||
|
|
||||||
output := outputBytes.String()
|
output := outputBytes.String()
|
||||||
|
|
||||||
if wait {
|
|
||||||
// This is just so we don't return right away and let the user press enter to return
|
|
||||||
screen.TermMessage("")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the screen back up
|
// Start the screen back up
|
||||||
screen.TempStart(screenb)
|
screen.TempStart(screenb)
|
||||||
|
|
||||||
|
signal.Notify(util.Sigterm, os.Interrupt)
|
||||||
|
signal.Stop(c)
|
||||||
|
|
||||||
return output, err
|
return output, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ var (
|
|||||||
|
|
||||||
// Stdout is a buffer that is written to stdout when micro closes
|
// Stdout is a buffer that is written to stdout when micro closes
|
||||||
Stdout *bytes.Buffer
|
Stdout *bytes.Buffer
|
||||||
|
// Sigterm is a channel where micro exits when written
|
||||||
|
Sigterm chan os.Signal
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -193,6 +193,7 @@ DeleteSubWordLeft
|
|||||||
SelectLine
|
SelectLine
|
||||||
SelectToStartOfLine
|
SelectToStartOfLine
|
||||||
SelectToEndOfLine
|
SelectToEndOfLine
|
||||||
|
Deselect
|
||||||
InsertNewline
|
InsertNewline
|
||||||
InsertSpace
|
InsertSpace
|
||||||
Backspace
|
Backspace
|
||||||
@ -240,12 +241,16 @@ ParagraphNext
|
|||||||
ToggleHelp
|
ToggleHelp
|
||||||
ToggleDiffGutter
|
ToggleDiffGutter
|
||||||
ToggleRuler
|
ToggleRuler
|
||||||
|
ToggleKeyMenu
|
||||||
|
ToggleHighlightSearch
|
||||||
JumpLine
|
JumpLine
|
||||||
|
ClearInfo
|
||||||
ClearStatus
|
ClearStatus
|
||||||
ShellMode
|
ShellMode
|
||||||
CommandMode
|
CommandMode
|
||||||
Quit
|
Quit
|
||||||
QuitAll
|
QuitAll
|
||||||
|
ForceQuit
|
||||||
AddTab
|
AddTab
|
||||||
PreviousTab
|
PreviousTab
|
||||||
NextTab
|
NextTab
|
||||||
|
Loading…
Reference in New Issue
Block a user