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

Method View

internal/app/edit.go:99–166  ·  view source on GitHub ↗

View composes: blurred backdrop → ornate canvas frame at target rect → textarea spliced inside the frame → footer.

(w, h int, n *Note, stars []Star, textMode TextStyleMode, board *Board, bgColor *RGB)

Source from the content-addressed store, hash-verified

97// View composes: blurred backdrop → ornate canvas frame at target rect →
98// textarea spliced inside the frame → footer.
99func (e Editor) View(w, h int, n *Note, stars []Star, textMode TextStyleMode, board *Board, bgColor *RGB) string {
100 if n == nil {
101 return ""
102 }
103 rect := TargetRect(w, h)
104
105 // 1. Backdrop — board dimmed so the card pops. The focused note is
106 // OMITTED so the card appears on a cleaner background (no echo of
107 // itself behind the frame). Strings touching the focused note are
108 // re-anchored to the card's pin position so they stay attached
109 // where the transition left them, instead of snapping back.
110 //
111 // Order matters: behind-strings → other notes → in-front-strings,
112 // then dim the whole thing. This keeps `InFront=true` strings on top
113 // of notes even after the blur is applied (without it, they'd sit
114 // underneath because everything was being drawn before the notes).
115 c := NewCanvas(w, h-1)
116 if bgColor != nil {
117 c.DefaultBg = bgColor
118 }
119 drawCork(c, stars)
120 editPin := &PinOverride{
121 NoteID: n.ID,
122 X: rect.X + rect.W/2,
123 Y: rect.Y,
124 }
125 // Behind-strings: respect InFront flag; strings touching the focus
126 // are deferred to the in-front pass via attachToTopID.
127 drawStringsBehind(c, board, -1, n.ID, editPin)
128 for _, bn := range board.Notes {
129 if bn.ID == n.ID {
130 continue
131 }
132 drawShadow(c, bn, board.Zoom)
133 drawNote(c, bn, false, textMode, board.Zoom)
134 }
135 // In-front-strings (incl. those touching focus): drawn AFTER notes
136 // so they sit on top of cards even when dimmed.
137 drawStringsInFront(c, board, nil, -1, n.ID, editPin)
138 c.Dim(0.38)
139
140 // 2. Ornate frame — border in the note's own tint (not red).
141 tint := GetTint(n.Tint)
142 borderCol := tint.Paper
143 liveTitle, _ := e.Split()
144 frame := NewCanvas(rect.W, rect.H)
145 drawNoteFrame(frame, Rect{X: 0, Y: 0, W: rect.W, H: rect.H},
146 n, true, textMode, liveTitle, &borderCol)
147 bg := c.Serialize()
148 bg = SpliceOverlay(bg, frame.Serialize(), rect.X, rect.Y)
149
150 // 3. Textarea inside the frame body area. The textarea stores plain
151 // ASCII internally; we apply the board's font as a display-only pass
152 // so that what's visible matches the rest of the board. ANSI escapes
153 // (cursor highlight) are preserved verbatim.
154 bodyY := rect.Y + 3
155 bodyX := rect.X + 2
156 taView := StyleViewText(e.Ta.View(), textMode)

Callers

nothing calls this directly

Calls 15

DimMethod · 0.95
SplitMethod · 0.95
SerializeMethod · 0.95
TargetRectFunction · 0.85
NewCanvasFunction · 0.85
drawCorkFunction · 0.85
drawStringsBehindFunction · 0.85
drawShadowFunction · 0.85
drawNoteFunction · 0.85
drawStringsInFrontFunction · 0.85
GetTintFunction · 0.85
drawNoteFrameFunction · 0.85

Tested by

no test coverage detected