MCPcopy
hub / github.com/ayn2op/discordo / ConfigureBox

Function ConfigureBox

internal/ui/util.go:15–54  ·  view source on GitHub ↗

ConfigureBox configures the provided box according to the provided theme.

(box *tview.Box, cfg *config.Theme)

Source from the content-addressed store, hash-verified

13
14// ConfigureBox configures the provided box according to the provided theme.
15func ConfigureBox(box *tview.Box, cfg *config.Theme) *tview.Box {
16 border := cfg.Border
17 normalBorderStyle, activeBorderStyle := border.NormalStyle.Style, border.ActiveStyle.Style
18 normalBorderSet, activeBorderSet := border.NormalSet.BorderSet, border.ActiveSet.BorderSet
19
20 title := cfg.Title
21 normalTitleStyle, activeTitleStyle := title.NormalStyle.Style, title.ActiveStyle.Style
22
23 footer := cfg.Footer
24 normalFooterStyle, activeFooterStyle := footer.NormalStyle.Style, footer.ActiveStyle.Style
25
26 padding := border.Padding
27
28 box.
29 SetBorderStyle(normalBorderStyle).
30 SetBorderSet(normalBorderSet).
31 SetBorderPadding(padding[0], padding[1], padding[2], padding[3]).
32 SetTitleStyle(normalTitleStyle).
33 SetTitleAlignment(title.Alignment.Alignment).
34 SetFooterStyle(normalFooterStyle).
35 SetFooterAlignment(footer.Alignment.Alignment).
36 SetBlurFunc(func() {
37 box.
38 SetBorderStyle(normalBorderStyle).
39 SetBorderSet(normalBorderSet)
40 box.SetTitleStyle(normalTitleStyle).SetFooterStyle(normalFooterStyle)
41 }).
42 SetFocusFunc(func() {
43 box.
44 SetBorderStyle(activeBorderStyle).
45 SetBorderSet(activeBorderSet)
46 box.SetTitleStyle(activeTitleStyle).SetFooterStyle(activeFooterStyle)
47 })
48
49 if border.Enabled {
50 box.SetBorders(tview.BordersAll)
51 }
52
53 return box
54}
55
56// Centered creates a new grid with provided primitive aligned in the center.
57func Centered(m tview.Model, width, height int) tview.Model {

Callers 6

newMentionsListFunction · 0.92
newMessagesListFunction · 0.92
newComposerFunction · 0.92
ConfigurePickerFunction · 0.92
newGuildsTreeFunction · 0.92
NewModelFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected