Fix Windows build

Fix #3598
This commit is contained in:
Junegunn Choi 2024-01-24 15:59:54 +09:00
parent beb2de2dd9
commit da752fc9a4
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
5 changed files with 30 additions and 10 deletions

View File

@ -817,7 +817,11 @@ func NewTerminal(opts *Options, eventBox *util.EventBox) *Terminal {
}
}
_, t.hasResizeActions = t.keymap[tui.Resize.AsEvent()]
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,6 +2856,7 @@ func (t *Terminal) Loop() {
}
}()
if !t.tui.ShouldEmitResizeEvent() {
resizeChan := make(chan os.Signal, 1)
notifyOnResize(resizeChan) // Non-portable
go func() {
@ -2860,6 +2865,7 @@ func (t *Terminal) Loop() {
t.reqBox.Set(reqResize, nil)
}
}()
}
t.mutex.Lock()
t.initFunc()
@ -3215,7 +3221,11 @@ func (t *Terminal) Loop() {
}
select {
case event = <-t.eventChan:
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 {

View File

@ -36,6 +36,7 @@ func (r *FullscreenRenderer) Resume(bool, bool) {}
func (r *FullscreenRenderer) PassThrough(string) {}
func (r *FullscreenRenderer) Clear() {}
func (r *FullscreenRenderer) NeedScrollbarRedraw() bool { return false }
func (r *FullscreenRenderer) ShouldEmitResizeEvent() bool { return false }
func (r *FullscreenRenderer) Refresh() {}
func (r *FullscreenRenderer) Close() {}
func (r *FullscreenRenderer) Size() TermSize { return TermSize{} }

View File

@ -694,6 +694,10 @@ func (r *LightRenderer) NeedScrollbarRedraw() bool {
return false
}
func (r *LightRenderer) ShouldEmitResizeEvent() bool {
return false
}
func (r *LightRenderer) RefreshWindows(windows []Window) {
r.flush()
}

View File

@ -202,6 +202,10 @@ func (r *FullscreenRenderer) NeedScrollbarRedraw() bool {
return true
}
func (r *FullscreenRenderer) ShouldEmitResizeEvent() bool {
return true
}
func (r *FullscreenRenderer) Refresh() {
// noop
}

View File

@ -494,6 +494,7 @@ type Renderer interface {
Close()
PassThrough(string)
NeedScrollbarRedraw() bool
ShouldEmitResizeEvent() bool
GetChar() Event