1 // +build linux darwin dragonfly openbsd_amd64 freebsd
6 shellquote "github.com/kballard/go-shellquote"
7 "github.com/zyedidia/micro/v2/internal/shell"
10 // TermEmuSupported is a constant that marks if the terminal emulator is supported
11 const TermEmuSupported = true
13 // RunTermEmulator starts a terminal emulator from a bufpane with the given input (command)
14 // if wait is true it will wait for the user to exit by pressing enter once the executable has terminated
15 // if getOutput is true it will redirect the stdout of the process to a pipe which will be passed to the
16 // callback which is a function that takes a string and a list of optional user arguments
17 func RunTermEmulator(h *BufPane, input string, wait bool, getOutput bool, callback func(out string, userargs []interface{}), userargs []interface{}) error {
18 args, err := shellquote.Split(input)
26 t := new(shell.Terminal)
27 err = t.Start(args, getOutput, wait, callback, userargs)
33 id := MainTab().Panes[0].ID()
37 tp, err := NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
41 MainTab().Panes[0] = tp
42 MainTab().SetActive(0)