test(daemon): reuse legacy render dimmers
- commit
- 384a2835064c2cb6572453268e7b318457247868
- author
- brice · · 2026-07-15 04:56 UTC
- parent
- 699a232
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
1 file · +9 -7
M internal/usecase/daemon/render_legacy_test.go +9 -7
| @@ -158,6 +158,9 @@ func composeTabFrameIntoWithLayout(tb *tab, frame renderer.Frame, area domain.Re | |||
| 158 | 158 | func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area domain.Rect, theme themeui.Theme, layoutSnap tabLayoutSnapshot, cacheValid bool, consumeDamage bool, titleGenerations map[layout.PaneID]uint64) []renderer.Damage { | |
| 159 | 159 | contentArea := domain.Rect{Width: area.Width, Height: area.Height} | |
| 160 | 160 | root := tb.tree.Root | |
| 161 | + | styles := newThemeStyles(theme) | |
| 162 | + | defaultDimmer := themeui.NewDimmer(theme) | |
| 163 | + | inactivePaneDimmer := themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming)) | |
| 161 | 164 | placements, ok := layoutSnap.placements, layoutSnap.ok && layoutSnap.root == root && layoutSnap.area == contentArea | |
| 162 | 165 | if !ok { | |
| 163 | 166 | placements, ok = layout.Solve(root, contentArea) | |
| @@ -176,7 +179,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||
| 176 | 179 | clear(titleGenerations) | |
| 177 | 180 | } | |
| 178 | 181 | if ok && !cacheValid { | |
| 179 | - | drawDividers(frame, root, area, themeui.NewDimmer(theme).Dim(newThemeStyles(theme).border)) | |
| 182 | + | drawDividers(frame, root, area, defaultDimmer.Dim(styles.border)) | |
| 180 | 183 | } | |
| 181 | 184 | var damage []renderer.Damage | |
| 182 | 185 | for _, pl := range placements { | |
| @@ -190,7 +193,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||
| 190 | 193 | focused := tb.tree.Focus == pl.ID | |
| 191 | 194 | pl = offsetPlacement(pl, area.X, area.Y) | |
| 192 | 195 | if pl.TitleBar.Height > 0 { | |
| 193 | - | generation := drawPaneTitleBar(frame, pl, p, focused, theme) | |
| 196 | + | generation := drawPaneTitleBar(frame, pl, p, focused, styles, defaultDimmer) | |
| 194 | 197 | if cacheValid && (titleGenerations == nil || titleGenerations[pl.ID] != generation) { | |
| 195 | 198 | titleDamage := pl.TitleBar | |
| 196 | 199 | titleDamage.X -= area.X | |
| @@ -222,7 +225,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||
| 222 | 225 | p.mu.Lock() | |
| 223 | 226 | paneDamage = p.screen.Damage() | |
| 224 | 227 | if !cacheValid || len(paneDamage) > 0 { | |
| 225 | - | blitPaneFrame(frame, pl.Content, p.screen.Frame, !focused, themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming))) | |
| 228 | + | blitPaneFrame(frame, pl.Content, p.screen.Frame, !focused, inactivePaneDimmer) | |
| 226 | 229 | } | |
| 227 | 230 | for _, d := range paneDamage { | |
| 228 | 231 | localContent := pl.Content | |
| @@ -234,7 +237,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||
| 234 | 237 | continue | |
| 235 | 238 | } | |
| 236 | 239 | if !cacheValid || len(paneDamage) > 0 { | |
| 237 | - | blitPaneFrame(frame, pl.Content, paneFrame, !focused, themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming))) | |
| 240 | + | blitPaneFrame(frame, pl.Content, paneFrame, !focused, inactivePaneDimmer) | |
| 238 | 241 | } | |
| 239 | 242 | for _, d := range paneDamage { | |
| 240 | 243 | localContent := pl.Content | |
| @@ -259,13 +262,12 @@ func clearFrameRect(frame renderer.Frame, r domain.Rect) { | |||
| 259 | 262 | } | |
| 260 | 263 | } | |
| 261 | 264 | ||
| 262 | - | func drawPaneTitleBar(frame renderer.Frame, pl layout.Placement, p *pane, focused bool, theme themeui.Theme) uint64 { | |
| 263 | - | styles := newThemeStyles(theme) | |
| 265 | + | func drawPaneTitleBar(frame renderer.Frame, pl layout.Placement, p *pane, focused bool, styles themeStyles, dimmer themeui.Dimmer) uint64 { | |
| 264 | 266 | style := styles.border | |
| 265 | 267 | if focused { | |
| 266 | 268 | style = styles.statusBar | |
| 267 | 269 | } else { | |
| 268 | - | style = themeui.NewDimmer(theme).Dim(style) | |
| 270 | + | style = dimmer.Dim(style) | |
| 269 | 271 | } | |
| 270 | 272 | for x := pl.TitleBar.X; x < pl.TitleBar.X+pl.TitleBar.Width && x < frame.Width; x++ { | |
| 271 | 273 | frame.Set(x, pl.TitleBar.Y, renderer.Cell{Rune: ' ', Style: style}) | |
| @@ -158,6 +158,9 @@ func composeTabFrameIntoWithLayout(tb *tab, frame renderer.Frame, area domain.Re | |||||
| 158 | func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area domain.Rect, theme themeui.Theme, layoutSnap tabLayoutSnapshot, cacheValid bool, consumeDamage bool, titleGenerations map[layout.PaneID]uint64) []renderer.Damage { | 158 | func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area domain.Rect, theme themeui.Theme, layoutSnap tabLayoutSnapshot, cacheValid bool, consumeDamage bool, titleGenerations map[layout.PaneID]uint64) []renderer.Damage { | ||
| 159 | contentArea := domain.Rect{Width: area.Width, Height: area.Height} | 159 | contentArea := domain.Rect{Width: area.Width, Height: area.Height} | ||
| 160 | root := tb.tree.Root | 160 | root := tb.tree.Root | ||
| 161 | + | styles := newThemeStyles(theme) | |||
| 162 | + | defaultDimmer := themeui.NewDimmer(theme) | |||
| 163 | + | inactivePaneDimmer := themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming)) | |||
| 161 | placements, ok := layoutSnap.placements, layoutSnap.ok && layoutSnap.root == root && layoutSnap.area == contentArea | 164 | placements, ok := layoutSnap.placements, layoutSnap.ok && layoutSnap.root == root && layoutSnap.area == contentArea | ||
| 162 | if !ok { | 165 | if !ok { | ||
| 163 | placements, ok = layout.Solve(root, contentArea) | 166 | placements, ok = layout.Solve(root, contentArea) | ||
| @@ -176,7 +179,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||||
| 176 | clear(titleGenerations) | 179 | clear(titleGenerations) | ||
| 177 | } | 180 | } | ||
| 178 | if ok && !cacheValid { | 181 | if ok && !cacheValid { | ||
| 179 | - | drawDividers(frame, root, area, themeui.NewDimmer(theme).Dim(newThemeStyles(theme).border)) | 182 | + | drawDividers(frame, root, area, defaultDimmer.Dim(styles.border)) |
| 180 | } | 183 | } | ||
| 181 | var damage []renderer.Damage | 184 | var damage []renderer.Damage | ||
| 182 | for _, pl := range placements { | 185 | for _, pl := range placements { | ||
| @@ -190,7 +193,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||||
| 190 | focused := tb.tree.Focus == pl.ID | 193 | focused := tb.tree.Focus == pl.ID | ||
| 191 | pl = offsetPlacement(pl, area.X, area.Y) | 194 | pl = offsetPlacement(pl, area.X, area.Y) | ||
| 192 | if pl.TitleBar.Height > 0 { | 195 | if pl.TitleBar.Height > 0 { | ||
| 193 | - | generation := drawPaneTitleBar(frame, pl, p, focused, theme) | 196 | + | generation := drawPaneTitleBar(frame, pl, p, focused, styles, defaultDimmer) |
| 194 | if cacheValid && (titleGenerations == nil || titleGenerations[pl.ID] != generation) { | 197 | if cacheValid && (titleGenerations == nil || titleGenerations[pl.ID] != generation) { | ||
| 195 | titleDamage := pl.TitleBar | 198 | titleDamage := pl.TitleBar | ||
| 196 | titleDamage.X -= area.X | 199 | titleDamage.X -= area.X | ||
| @@ -222,7 +225,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||||
| 222 | p.mu.Lock() | 225 | p.mu.Lock() | ||
| 223 | paneDamage = p.screen.Damage() | 226 | paneDamage = p.screen.Damage() | ||
| 224 | if !cacheValid || len(paneDamage) > 0 { | 227 | if !cacheValid || len(paneDamage) > 0 { | ||
| 225 | - | blitPaneFrame(frame, pl.Content, p.screen.Frame, !focused, themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming))) | 228 | + | blitPaneFrame(frame, pl.Content, p.screen.Frame, !focused, inactivePaneDimmer) |
| 226 | } | 229 | } | ||
| 227 | for _, d := range paneDamage { | 230 | for _, d := range paneDamage { | ||
| 228 | localContent := pl.Content | 231 | localContent := pl.Content | ||
| @@ -234,7 +237,7 @@ func composeTabFrameIntoWithLayoutOptions(tb *tab, frame renderer.Frame, area do | |||||
| 234 | continue | 237 | continue | ||
| 235 | } | 238 | } | ||
| 236 | if !cacheValid || len(paneDamage) > 0 { | 239 | if !cacheValid || len(paneDamage) > 0 { | ||
| 237 | - | blitPaneFrame(frame, pl.Content, paneFrame, !focused, themeui.NewDimmer(theme, themeui.WithForegroundDimming(inactivePaneForegroundDimming))) | 240 | + | blitPaneFrame(frame, pl.Content, paneFrame, !focused, inactivePaneDimmer) |
| 238 | } | 241 | } | ||
| 239 | for _, d := range paneDamage { | 242 | for _, d := range paneDamage { | ||
| 240 | localContent := pl.Content | 243 | localContent := pl.Content | ||
| @@ -259,13 +262,12 @@ func clearFrameRect(frame renderer.Frame, r domain.Rect) { | |||||
| 259 | } | 262 | } | ||
| 260 | } | 263 | } | ||
| 261 | 264 | ||||
| 262 | - | func drawPaneTitleBar(frame renderer.Frame, pl layout.Placement, p *pane, focused bool, theme themeui.Theme) uint64 { | 265 | + | func drawPaneTitleBar(frame renderer.Frame, pl layout.Placement, p *pane, focused bool, styles themeStyles, dimmer themeui.Dimmer) uint64 { |
| 263 | - | styles := newThemeStyles(theme) | |||
| 264 | style := styles.border | 266 | style := styles.border | ||
| 265 | if focused { | 267 | if focused { | ||
| 266 | style = styles.statusBar | 268 | style = styles.statusBar | ||
| 267 | } else { | 269 | } else { | ||
| 268 | - | style = themeui.NewDimmer(theme).Dim(style) | 270 | + | style = dimmer.Dim(style) |
| 269 | } | 271 | } | ||
| 270 | for x := pl.TitleBar.X; x < pl.TitleBar.X+pl.TitleBar.Width && x < frame.Width; x++ { | 272 | for x := pl.TitleBar.X; x < pl.TitleBar.X+pl.TitleBar.Width && x < frame.Width; x++ { | ||
| 271 | frame.Set(x, pl.TitleBar.Y, renderer.Cell{Rune: ' ', Style: style}) | 273 | frame.Set(x, pl.TitleBar.Y, renderer.Cell{Rune: ' ', Style: style}) | ||