Add shell command support

This commit is contained in:
Zachary Yedidia
2019-01-10 16:37:05 -05:00
parent 0febfd2c80
commit c479c9d91a
9 changed files with 186 additions and 36 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/zyedidia/micro/cmd/micro/buffer"
"github.com/zyedidia/micro/cmd/micro/config"
"github.com/zyedidia/micro/cmd/micro/screen"
"github.com/zyedidia/micro/cmd/micro/shell"
"github.com/zyedidia/micro/cmd/micro/util"
"github.com/zyedidia/tcell"
)
@@ -370,16 +371,6 @@ func (h *BufHandler) SelectToEnd() bool {
return true
}
// InsertSpace inserts a space
func (h *BufHandler) InsertSpace() bool {
if h.Cursor.HasSelection() {
h.Cursor.DeleteSelection()
h.Cursor.ResetSelection()
}
h.Buf.Insert(h.Cursor.Loc, " ")
return true
}
// InsertNewline inserts a newline plus possible some whitespace if autoindent is on
func (h *BufHandler) InsertNewline() bool {
if h.Buf.Type == buffer.BTInfo {
@@ -984,6 +975,13 @@ func (h *BufHandler) ToggleKeyMenu() bool {
// ShellMode opens a terminal to run a shell command
func (h *BufHandler) ShellMode() bool {
InfoBar.Prompt("$ ", "", "Shell", nil, func(resp string, canceled bool) {
if !canceled {
// The true here is for openTerm to make the command interactive
shell.RunInteractiveShell(resp, true, false)
}
})
return false
}