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

Function drawBackgroundMenuAt

internal/app/menu.go:306–401  ·  view source on GitHub ↗
(c *Canvas, x, y int, menu *BackgroundMenu)

Source from the content-addressed store, hash-verified

304}
305
306func drawBackgroundMenuAt(c *Canvas, x, y int, menu *BackgroundMenu) {
307 rect := BackgroundMenuRect(c.W, c.H)
308 w, h := rect.W, rect.H
309
310 c.BlankRect(x, y, w, h)
311
312 bdCol := PinRed
313 for dx := 0; dx < w; dx++ {
314 c.SetRune(x+dx, y, '─', bdCol, 0)
315 c.SetRune(x+dx, y+h-1, '─', bdCol, 0)
316 }
317 for dy := 0; dy < h; dy++ {
318 c.SetRune(x, y+dy, '│', bdCol, 0)
319 c.SetRune(x+w-1, y+dy, '│', bdCol, 0)
320 }
321 c.SetRune(x, y, '╭', bdCol, AttrBold)
322 c.SetRune(x+w-1, y, '╮', bdCol, AttrBold)
323 c.SetRune(x, y+h-1, '╰', bdCol, AttrBold)
324 c.SetRune(x+w-1, y+h-1, '╯', bdCol, AttrBold)
325
326 title := " ◈ background "
327 c.WriteText(x+2, y, title, PinRed, AttrBold)
328
329 swatchX := x + w - 9
330 drawRow := func(row int, selected bool, name string, nameCol RGB, right func()) {
331 arrow := ' '
332 if selected {
333 arrow = '›'
334 }
335 c.SetRune(x+2, row, arrow, PinRed, AttrBold)
336 col := nameCol
337 attr := uint8(0)
338 if selected {
339 col = Flash
340 attr = AttrBold
341 }
342 c.WriteText(x+4, row, name, col, attr)
343 if right != nil {
344 right()
345 }
346 }
347 solidSwatch := func(row int, col RGB) func() {
348 return func() {
349 for k := 0; k < 6; k++ {
350 c.SetRune(swatchX+k, row, '█', col, 0)
351 }
352 }
353 }
354
355 // Row 0: cork toggle.
356 corkRow := y + 1
357 {
358 val := "‹ off ›"
359 valCol := Footer
360 if menu.Cork {
361 val = "‹ on ›"
362 valCol = Flash
363 }

Callers 1

drawBackgroundMenuFunction · 0.85

Calls 8

BackgroundMenuRectFunction · 0.85
runeLenFunction · 0.85
ParseHexColorFunction · 0.85
BlankRectMethod · 0.80
SetRuneMethod · 0.80
WriteTextMethod · 0.80
OnCorkMethod · 0.80
OnCustomMethod · 0.80

Tested by

no test coverage detected