|
|
@ -245,6 +245,7 @@ type Terminal struct {
|
|
|
|
listenUnsafe bool
|
|
|
|
listenUnsafe bool
|
|
|
|
borderShape tui.BorderShape
|
|
|
|
borderShape tui.BorderShape
|
|
|
|
cleanExit bool
|
|
|
|
cleanExit bool
|
|
|
|
|
|
|
|
executor *util.Executor
|
|
|
|
paused bool
|
|
|
|
paused bool
|
|
|
|
border tui.Window
|
|
|
|
border tui.Window
|
|
|
|
window tui.Window
|
|
|
|
window tui.Window
|
|
|
@ -640,7 +641,7 @@ func evaluateHeight(opts *Options, termHeight int) int {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewTerminal returns new Terminal object
|
|
|
|
// NewTerminal returns new Terminal object
|
|
|
|
func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
func NewTerminal(opts *Options, eventBox *util.EventBox, executor *util.Executor) *Terminal {
|
|
|
|
input := trimQuery(opts.Query)
|
|
|
|
input := trimQuery(opts.Query)
|
|
|
|
var delay time.Duration
|
|
|
|
var delay time.Duration
|
|
|
|
if opts.Tac {
|
|
|
|
if opts.Tac {
|
|
|
@ -736,6 +737,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
previewLabel: nil,
|
|
|
|
previewLabel: nil,
|
|
|
|
previewLabelOpts: opts.PreviewLabel,
|
|
|
|
previewLabelOpts: opts.PreviewLabel,
|
|
|
|
cleanExit: opts.ClearOnExit,
|
|
|
|
cleanExit: opts.ClearOnExit,
|
|
|
|
|
|
|
|
executor: executor,
|
|
|
|
paused: opts.Phony,
|
|
|
|
paused: opts.Phony,
|
|
|
|
cycle: opts.Cycle,
|
|
|
|
cycle: opts.Cycle,
|
|
|
|
headerVisible: true,
|
|
|
|
headerVisible: true,
|
|
|
@ -2522,6 +2524,7 @@ type replacePlaceholderParams struct {
|
|
|
|
allItems []*Item
|
|
|
|
allItems []*Item
|
|
|
|
lastAction actionType
|
|
|
|
lastAction actionType
|
|
|
|
prompt string
|
|
|
|
prompt string
|
|
|
|
|
|
|
|
executor *util.Executor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (t *Terminal) replacePlaceholder(template string, forcePlus bool, input string, list []*Item) string {
|
|
|
|
func (t *Terminal) replacePlaceholder(template string, forcePlus bool, input string, list []*Item) string {
|
|
|
@ -2535,6 +2538,7 @@ func (t *Terminal) replacePlaceholder(template string, forcePlus bool, input str
|
|
|
|
allItems: list,
|
|
|
|
allItems: list,
|
|
|
|
lastAction: t.lastAction,
|
|
|
|
lastAction: t.lastAction,
|
|
|
|
prompt: t.promptString,
|
|
|
|
prompt: t.promptString,
|
|
|
|
|
|
|
|
executor: t.executor,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2595,7 +2599,7 @@ func replacePlaceholder(params replacePlaceholderParams) string {
|
|
|
|
case escaped:
|
|
|
|
case escaped:
|
|
|
|
return match
|
|
|
|
return match
|
|
|
|
case match == "{q}" || match == "{fzf:query}":
|
|
|
|
case match == "{q}" || match == "{fzf:query}":
|
|
|
|
return quoteEntry(params.query)
|
|
|
|
return params.executor.QuoteEntry(params.query)
|
|
|
|
case match == "{}":
|
|
|
|
case match == "{}":
|
|
|
|
replace = func(item *Item) string {
|
|
|
|
replace = func(item *Item) string {
|
|
|
|
switch {
|
|
|
|
switch {
|
|
|
@ -2608,13 +2612,13 @@ func replacePlaceholder(params replacePlaceholderParams) string {
|
|
|
|
case flags.file:
|
|
|
|
case flags.file:
|
|
|
|
return item.AsString(params.stripAnsi)
|
|
|
|
return item.AsString(params.stripAnsi)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return quoteEntry(item.AsString(params.stripAnsi))
|
|
|
|
return params.executor.QuoteEntry(item.AsString(params.stripAnsi))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case match == "{fzf:action}":
|
|
|
|
case match == "{fzf:action}":
|
|
|
|
return params.lastAction.Name()
|
|
|
|
return params.lastAction.Name()
|
|
|
|
case match == "{fzf:prompt}":
|
|
|
|
case match == "{fzf:prompt}":
|
|
|
|
return quoteEntry(params.prompt)
|
|
|
|
return params.executor.QuoteEntry(params.prompt)
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
// token type and also failover (below)
|
|
|
|
// token type and also failover (below)
|
|
|
|
rangeExpressions := strings.Split(match[1:len(match)-1], ",")
|
|
|
|
rangeExpressions := strings.Split(match[1:len(match)-1], ",")
|
|
|
@ -2648,7 +2652,7 @@ func replacePlaceholder(params replacePlaceholderParams) string {
|
|
|
|
str = strings.TrimSpace(str)
|
|
|
|
str = strings.TrimSpace(str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if !flags.file {
|
|
|
|
if !flags.file {
|
|
|
|
str = quoteEntry(str)
|
|
|
|
str = params.executor.QuoteEntry(str)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return str
|
|
|
|
return str
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2688,7 +2692,7 @@ func (t *Terminal) executeCommand(template string, forcePlus bool, background bo
|
|
|
|
return line
|
|
|
|
return line
|
|
|
|
}
|
|
|
|
}
|
|
|
|
command := t.replacePlaceholder(template, forcePlus, string(t.input), list)
|
|
|
|
command := t.replacePlaceholder(template, forcePlus, string(t.input), list)
|
|
|
|
cmd := util.ExecCommand(command, false)
|
|
|
|
cmd := t.executor.ExecCommand(command, false)
|
|
|
|
cmd.Env = t.environ()
|
|
|
|
cmd.Env = t.environ()
|
|
|
|
t.executing.Set(true)
|
|
|
|
t.executing.Set(true)
|
|
|
|
if !background {
|
|
|
|
if !background {
|
|
|
@ -2965,7 +2969,7 @@ func (t *Terminal) Loop() {
|
|
|
|
if items[0] != nil {
|
|
|
|
if items[0] != nil {
|
|
|
|
_, query := t.Input()
|
|
|
|
_, query := t.Input()
|
|
|
|
command := t.replacePlaceholder(commandTemplate, false, string(query), items)
|
|
|
|
command := t.replacePlaceholder(commandTemplate, false, string(query), items)
|
|
|
|
cmd := util.ExecCommand(command, true)
|
|
|
|
cmd := t.executor.ExecCommand(command, true)
|
|
|
|
env := t.environ()
|
|
|
|
env := t.environ()
|
|
|
|
if pwindowSize.Lines > 0 {
|
|
|
|
if pwindowSize.Lines > 0 {
|
|
|
|
lines := fmt.Sprintf("LINES=%d", pwindowSize.Lines)
|
|
|
|
lines := fmt.Sprintf("LINES=%d", pwindowSize.Lines)
|
|
|
|