|
|
|
@ -17,8 +17,7 @@ import (
|
|
|
|
|
"syscall"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/junegunn/go-runewidth"
|
|
|
|
|
"github.com/rivo/uniseg"
|
|
|
|
|
"github.com/junegunn/uniseg"
|
|
|
|
|
|
|
|
|
|
"github.com/junegunn/fzf/src/tui"
|
|
|
|
|
"github.com/junegunn/fzf/src/util"
|
|
|
|
@ -254,6 +253,7 @@ type Terminal struct {
|
|
|
|
|
hasResultActions bool
|
|
|
|
|
hasFocusActions bool
|
|
|
|
|
hasLoadActions bool
|
|
|
|
|
hasResizeActions bool
|
|
|
|
|
triggerLoad bool
|
|
|
|
|
reading bool
|
|
|
|
|
running bool
|
|
|
|
@ -534,7 +534,6 @@ func defaultKeymap() map[tui.Event][]*action {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
add(tui.Invalid, actInvalid)
|
|
|
|
|
add(tui.Resize, actClearScreen)
|
|
|
|
|
add(tui.CtrlA, actBeginningOfLine)
|
|
|
|
|
add(tui.CtrlB, actBackwardChar)
|
|
|
|
|
add(tui.CtrlC, actAbort)
|
|
|
|
@ -774,7 +773,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
|
killChan: make(chan int),
|
|
|
|
|
serverInputChan: make(chan []*action, 10),
|
|
|
|
|
serverOutputChan: make(chan string),
|
|
|
|
|
eventChan: make(chan tui.Event, 5), // (load + result + zero|one) | (focus) | (GetChar)
|
|
|
|
|
eventChan: make(chan tui.Event, 6), // (load + result + zero|one) | (focus) | (resize) | (GetChar)
|
|
|
|
|
tui: renderer,
|
|
|
|
|
initFunc: func() { renderer.Init() },
|
|
|
|
|
executing: util.NewAtomicBool(false),
|
|
|
|
@ -798,7 +797,7 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
|
t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)
|
|
|
|
|
}
|
|
|
|
|
if t.unicode {
|
|
|
|
|
t.borderWidth = runewidth.RuneWidth('│')
|
|
|
|
|
t.borderWidth = uniseg.StringWidth("│")
|
|
|
|
|
}
|
|
|
|
|
if opts.Scrollbar == nil {
|
|
|
|
|
if t.unicode && t.borderWidth == 1 {
|
|
|
|
@ -818,6 +817,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var resizeActions []*action
|
|
|
|
|
resizeActions, t.hasResizeActions = t.keymap[tui.Resize.AsEvent()]
|
|
|
|
|
if t.tui.ShouldEmitResizeEvent() {
|
|
|
|
|
t.keymap[tui.Resize.AsEvent()] = append(toActions(actClearScreen), resizeActions...)
|
|
|
|
|
}
|
|
|
|
|
_, t.hasResultActions = t.keymap[tui.Result.AsEvent()]
|
|
|
|
|
_, t.hasFocusActions = t.keymap[tui.Focus.AsEvent()]
|
|
|
|
|
_, t.hasLoadActions = t.keymap[tui.Load.AsEvent()]
|
|
|
|
@ -2852,14 +2856,16 @@ func (t *Terminal) Loop() {
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
resizeChan := make(chan os.Signal, 1)
|
|
|
|
|
notifyOnResize(resizeChan) // Non-portable
|
|
|
|
|
go func() {
|
|
|
|
|
for {
|
|
|
|
|
<-resizeChan
|
|
|
|
|
t.reqBox.Set(reqResize, nil)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
if !t.tui.ShouldEmitResizeEvent() {
|
|
|
|
|
resizeChan := make(chan os.Signal, 1)
|
|
|
|
|
notifyOnResize(resizeChan) // Non-portable
|
|
|
|
|
go func() {
|
|
|
|
|
for {
|
|
|
|
|
<-resizeChan
|
|
|
|
|
t.reqBox.Set(reqResize, nil)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t.mutex.Lock()
|
|
|
|
|
t.initFunc()
|
|
|
|
@ -3130,6 +3136,9 @@ func (t *Terminal) Loop() {
|
|
|
|
|
if wasHidden && t.hasPreviewWindow() {
|
|
|
|
|
refreshPreview(t.previewOpts.command)
|
|
|
|
|
}
|
|
|
|
|
if req == reqResize && t.hasResizeActions {
|
|
|
|
|
t.eventChan <- tui.Resize.AsEvent()
|
|
|
|
|
}
|
|
|
|
|
case reqClose:
|
|
|
|
|
exit(func() int {
|
|
|
|
|
if t.output() {
|
|
|
|
@ -3212,7 +3221,11 @@ func (t *Terminal) Loop() {
|
|
|
|
|
}
|
|
|
|
|
select {
|
|
|
|
|
case event = <-t.eventChan:
|
|
|
|
|
needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero)
|
|
|
|
|
if t.tui.ShouldEmitResizeEvent() {
|
|
|
|
|
needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero)
|
|
|
|
|
} else {
|
|
|
|
|
needBarrier = !event.Is(tui.Load, tui.Result, tui.Focus, tui.One, tui.Zero, tui.Resize)
|
|
|
|
|
}
|
|
|
|
|
case serverActions := <-t.serverInputChan:
|
|
|
|
|
event = tui.Invalid.AsEvent()
|
|
|
|
|
if t.listenAddr == nil || t.listenAddr.IsLocal() || t.listenUnsafe {
|
|
|
|
|