Real-image posters: blocks while the window is being resized; ARR_TUI_DEBUG_GFX log
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -122,7 +122,7 @@ func New(cfg *config.Config) *App {
|
||||
blocks, graphics := resolveCovers(cfg.UI.CoverStyle, os.Getenv)
|
||||
a.coverStyle = blocks
|
||||
if graphics {
|
||||
a.gfx = newKittyGraphics(a.writeTerminal)
|
||||
a.gfx = a.newGraphics()
|
||||
}
|
||||
|
||||
a.cfg = cfg
|
||||
@@ -192,6 +192,17 @@ func New(cfg *config.Config) *App {
|
||||
return a
|
||||
}
|
||||
|
||||
// newGraphics creates the real-image drawer. With ARR_TUI_DEBUG_GFX set it also
|
||||
// writes what it does (window size, cell shape, every upload) to the Log, which
|
||||
// helps to find out why a poster is drawn wrongly in some terminal.
|
||||
func (a *App) newGraphics() *kittyGraphics {
|
||||
k := newKittyGraphics(a.writeTerminal)
|
||||
if os.Getenv("ARR_TUI_DEBUG_GFX") != "" {
|
||||
k.debug = func(msg string) { a.logs.add(levelInfo, msg) }
|
||||
}
|
||||
return k
|
||||
}
|
||||
|
||||
// noteWindow notices when the terminal's size or cell size changed. The
|
||||
// real-image posters are then uploaded and placed again from scratch instead of
|
||||
// relying on the terminal to rescale what is there.
|
||||
@@ -205,6 +216,11 @@ func (a *App) noteWindow(s tcell.Screen) {
|
||||
a.lastWindow = win
|
||||
if !first && a.gfx != nil {
|
||||
a.gfx.deleteAll()
|
||||
a.gfx.hold() // blocks while the size is changing, real images when it has settled
|
||||
time.AfterFunc(settleDelay+30*time.Millisecond, func() { a.post(func() {}) })
|
||||
}
|
||||
if a.gfx != nil && a.gfx.debug != nil {
|
||||
a.gfx.debug(fmt.Sprintf("window: %d×%d cells, cell shape %.3f", w, h, a.cellAspect))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user