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

Function drawNoteFrame

internal/app/draw.go:117–257  ·  view source on GitHub ↗

drawNoteFrame draws only the frame (tape, borders, title row, separator, inner flourish, fold glyph) — NOT the body. Used in edit mode where a live textarea occupies the body. `liveTitle` overrides n.Title if set. `borderOverride` — if non-nil, forces the border color (used in edit mode to use the n

(c *Canvas, rect Rect, n *Note, selected bool, textMode TextStyleMode, liveTitle string, borderOverride *RGB)

Source from the content-addressed store, hash-verified

115// `borderOverride` — if non-nil, forces the border color (used in edit mode
116// to use the note's tint instead of the "selected" red).
117func drawNoteFrame(c *Canvas, rect Rect, n *Note, selected bool, textMode TextStyleMode, liveTitle string, borderOverride *RGB) {
118 tint := GetTint(n.Tint)
119 paper := tint.Paper
120 ink := tint.Ink
121 tape := tint.Tape
122
123 border := paper.Dimmed(0.8)
124 if selected {
125 border = PinRed
126 }
127 if borderOverride != nil {
128 border = *borderOverride
129 }
130 borderAttr := uint8(0)
131 if selected {
132 borderAttr = AttrBold
133 }
134
135 x0, y0, w, h := rect.X, rect.Y, rect.W, rect.H
136 if w < 6 || h < 4 {
137 return
138 }
139
140 // Clear interior
141 for dy := 0; dy < h; dy++ {
142 for dx := 0; dx < w; dx++ {
143 c.SetBlank(x0+dx, y0+dy)
144 }
145 }
146
147 // Tape
148 drawTapeStrip(c, x0, y0, w, tape, border, borderAttr, selected)
149
150 // Vertical borders
151 seed := hash(n.ID)
152 for dy := 1; dy < h-1; dy++ {
153 leftCh := vertBorderChar(seed, dy)
154 rightCh := vertBorderChar(seed^0xA5A5, dy)
155 c.SetRune(x0, y0+dy, leftCh, border, borderAttr)
156 c.SetRune(x0+w-1, y0+dy, rightCh, border, borderAttr)
157 }
158
159 // Bottom border
160 for dx := 0; dx < w; dx++ {
161 x := x0 + dx
162 var r rune
163 switch {
164 case dx == 0:
165 r = '╰'
166 case dx == w-1:
167 r = '╯'
168 default:
169 switch (dx + x0) % 6 {
170 case 0, 3:
171 r = '━'
172 default:
173 r = '─'
174 }

Callers 1

ViewMethod · 0.85

Calls 13

GetTintFunction · 0.85
drawTapeStripFunction · 0.85
hashFunction · 0.85
vertBorderCharFunction · 0.85
StyleTextFunction · 0.85
ModeAttrFunction · 0.85
runeLenFunction · 0.85
trimRunesFunction · 0.85
DimmedMethod · 0.80
SetBlankMethod · 0.80
SetRuneMethod · 0.80
WriteTextMethod · 0.80

Tested by

no test coverage detected