summaryrefslogtreecommitdiffstats
path: root/src/terminal.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-01-27 17:46:56 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-01-27 18:56:41 +0900
commit421b9b271ac263057c81eb58f98d5a96c04ce941 (patch)
treea79c584958acc6272699a48510c4a7ad3948d00e /src/terminal.go
parented57dcb924112192636260fb31d0db54352c517a (diff)
Add execute-silent action
Close #823
Diffstat (limited to 'src/terminal.go')
-rw-r--r--src/terminal.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 43d21d88..ee678f5c 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -204,7 +204,8 @@ const (
actPreviousHistory
actNextHistory
actExecute
- actExecuteMulti
+ actExecuteSilent
+ actExecuteMulti // Deprecated
)
func toActions(types ...actionType) []action {
@@ -1126,22 +1127,26 @@ func replacePlaceholder(template string, stripAnsi bool, delimiter Delimiter, fo
})
}
-func (t *Terminal) executeCommand(template string, forcePlus bool) {
+func (t *Terminal) executeCommand(template string, forcePlus bool, background bool) {
valid, list := t.buildPlusList(template, forcePlus)
if !valid {
return
}
command := replacePlaceholder(template, t.ansi, t.delimiter, forcePlus, string(t.input), list)
cmd := util.ExecCommand(command)
- cmd.Stdin = os.Stdin
- cmd.Stdout = os.Stdout
- cmd.Stderr = os.Stderr
- t.tui.Pause()
- cmd.Run()
- if t.tui.Resume() {
- t.printAll()
- }
- t.refresh()
+ if !background {
+ cmd.Stdin = os.Stdin
+ cmd.Stdout = os.Stdout
+ cmd.Stderr = os.Stderr
+ t.tui.Pause()
+ cmd.Run()
+ if t.tui.Resume() {
+ t.printAll()
+ }
+ t.refresh()
+ } else {
+ cmd.Run()
+ }
}
func (t *Terminal) hasPreviewer() bool {
@@ -1390,10 +1395,10 @@ func (t *Terminal) Loop() {
doAction = func(a action, mapkey int) bool {
switch a.t {
case actIgnore:
- case actExecute:
- t.executeCommand(a.a, false)
+ case actExecute, actExecuteSilent:
+ t.executeCommand(a.a, false, a.t == actExecuteSilent)
case actExecuteMulti:
- t.executeCommand(a.a, true)
+ t.executeCommand(a.a, true, false)
case actInvalid:
t.mutex.Unlock()
return false