(w, h int)
| 275 | } |
| 276 | |
| 277 | func 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 | |
| 301 | func drawBackgroundMenu(c *Canvas, menu *BackgroundMenu) { |
| 302 | rect := BackgroundMenuRect(c.W, c.H) |
no test coverage detected