Graphics debug log: also log what is drawn, optionally to a file
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019reK4DUGYqDUjniWYJvwUW
This commit is contained in:
+16
-1
@@ -197,7 +197,22 @@ func New(cfg *config.Config) *App {
|
||||
// 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") != "" {
|
||||
switch v := os.Getenv("ARR_TUI_DEBUG_GFX"); {
|
||||
case v == "":
|
||||
case strings.Contains(v, "/"):
|
||||
// A path: also append to that file, so the lines can be read without
|
||||
// leaving the view that shows the problem.
|
||||
f, err := os.OpenFile(v, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o600)
|
||||
if err != nil {
|
||||
a.logs.add(levelWarn, "ARR_TUI_DEBUG_GFX: "+err.Error())
|
||||
k.debug = func(msg string) { a.logs.add(levelInfo, msg) }
|
||||
break
|
||||
}
|
||||
k.debug = func(msg string) {
|
||||
a.logs.add(levelInfo, msg)
|
||||
fmt.Fprintf(f, "%s %s\n", time.Now().Format("15:04:05.000"), msg)
|
||||
}
|
||||
default:
|
||||
k.debug = func(msg string) { a.logs.add(levelInfo, msg) }
|
||||
}
|
||||
return k
|
||||
|
||||
@@ -259,6 +259,7 @@ type coverView struct {
|
||||
*tview.Box
|
||||
style coverStyle
|
||||
gfx *kittyGraphics // real images; nil for block characters only
|
||||
lastDrawn [5]int // id, position and size of the last real image drawn, for the debug log
|
||||
cellAspect func() float64 // height of a terminal cell divided by its width
|
||||
img *image.RGBA
|
||||
note string // shown instead of the image: "loading…", "no cover"
|
||||
@@ -405,6 +406,12 @@ func (c *coverView) drawGraphics(screen tcell.Screen, x, y, cols, rows int) bool
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
if c.gfx.debug != nil {
|
||||
if drawn := [5]int{int(id), x, y, cols, rows}; drawn != c.lastDrawn {
|
||||
c.lastDrawn = drawn
|
||||
c.gfx.debug(fmt.Sprintf("draw: id %d at column %d, row %d over %dx%d cells", id, x, y, cols, rows))
|
||||
}
|
||||
}
|
||||
for row := 0; row < rows; row++ {
|
||||
for col := 0; col < cols; col++ {
|
||||
ch, comb, style := placeholderCell(id, row, col)
|
||||
|
||||
Reference in New Issue
Block a user