"strings"
"unicode/utf8"
- luar "layeh.com/gopher-luar"
-
shellquote "github.com/kballard/go-shellquote"
- lua "github.com/yuin/gopher-lua"
"github.com/zyedidia/micro/internal/buffer"
"github.com/zyedidia/micro/internal/config"
- ulua "github.com/zyedidia/micro/internal/lua"
"github.com/zyedidia/micro/internal/screen"
"github.com/zyedidia/micro/internal/shell"
"github.com/zyedidia/micro/internal/util"
// MakeCommand is a function to easily create new commands
// This can be called by plugins in Lua so that plugins can define their own commands
-func LuaMakeCommand(name, function string, completer buffer.Completer) {
- action := LuaFunctionCommand(function)
- commands[name] = Command{action, completer}
-}
-
-// LuaFunctionCommand returns a normal function
-// so that a command can be bound to a lua function
-func LuaFunctionCommand(fn string) func(*BufPane, []string) {
- luaFn := strings.Split(fn, ".")
- if len(luaFn) <= 1 {
- return nil
- }
- plName, plFn := luaFn[0], luaFn[1]
- pl := config.FindPlugin(plName)
- if pl == nil {
- return nil
- }
- return func(bp *BufPane, args []string) {
- luaArgs := []lua.LValue{luar.New(ulua.L, bp), luar.New(ulua.L, args)}
- _, err := pl.Call(plFn, luaArgs...)
- if err != nil {
- screen.TermMessage(err)
- }
+func MakeCommand(name string, action func(bp *BufPane, args []string), completer buffer.Completer) {
+ if action != nil {
+ commands[name] = Command{action, completer}
}
}
func (h *BufPane) RawCmd(args []string) {
width, height := screen.Screen.Size()
iOffset := config.GetInfoBarOffset()
- tp := NewTabFromPane(0, 0, width, height-iOffset, NewRawPane())
+ tp := NewTabFromPane(0, 0, width, height-iOffset, NewRawPane(nil))
Tabs.AddTab(tp)
Tabs.SetActive(len(Tabs.List) - 1)
}
} else {
screen.Screen.EnableMouse()
}
- // autosave option has been removed
- // } else if option == "autosave" {
- // if nativeValue.(float64) > 0 {
- // config.SetAutoTime(int(nativeValue.(float64)))
- // config.StartAutoSave()
- // } else {
- // config.SetAutoTime(0)
- // }
+ } else if option == "autosave" {
+ if nativeValue.(float64) > 0 {
+ config.SetAutoTime(int(nativeValue.(float64)))
+ config.StartAutoSave()
+ } else {
+ config.SetAutoTime(0)
+ }
} else if option == "paste" {
screen.Screen.SetPaste(nativeValue.(bool))
} else {
// TermCmd opens a terminal in the current view
func (h *BufPane) TermCmd(args []string) {
- ps := MainTab().Panes
+ ps := h.tab.Panes
+
+ if !TermEmuSupported {
+ InfoBar.Error("Terminal emulator not supported on this system")
+ return
+ }
if len(args) == 0 {
sh := os.Getenv("SHELL")
term := func(i int, newtab bool) {
t := new(shell.Terminal)
- t.Start(args, false, true, "", nil)
+ t.Start(args, false, true, nil, nil)
id := h.ID()
if newtab {
}
v := h.GetView()
- MainTab().Panes[i] = NewTermPane(v.X, v.Y, v.Width, v.Height, t, id)
+ tp, err := NewTermPane(v.X, v.Y, v.Width, v.Height, t, id, MainTab())
+ if err != nil {
+ InfoBar.Error(err)
+ return
+ }
+ MainTab().Panes[i] = tp
MainTab().SetActive(i)
}