MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / BackgroundMenuRect

Function BackgroundMenuRect

internal/app/menu.go:277–299  ·  view source on GitHub ↗
(w, h int)

Source from the content-addressed store, hash-verified

275}
276
277func BackgroundMenuRect(w, h int) Rect {
278 maxName := runeLen("terminal (transparent)")
279 for _, ch := range BackgroundColors {
280 if runeLen(ch.Name) > maxName {
281 maxName = runeLen(ch.Name)
282 }
283 }
284 mw := maxName + 18 // name + gap + swatch + padding
285 if mw < 36 {
286 mw = 36
287 }
288 // rows: cork + spacer + colors + custom, plus top/bottom borders.
289 mh := len(BackgroundColors) + 5
290 mx := w - mw - 2
291 if mx < 2 {
292 mx = 2
293 }
294 my := (h - mh) / 2
295 if my < 1 {
296 my = 1
297 }
298 return Rect{X: mx, Y: my, W: mw, H: mh}
299}
300
301func drawBackgroundMenu(c *Canvas, menu *BackgroundMenu) {
302 rect := BackgroundMenuRect(c.W, c.H)

Callers 2

drawBackgroundMenuFunction · 0.85
drawBackgroundMenuAtFunction · 0.85

Calls 1

runeLenFunction · 0.85

Tested by

no test coverage detected