tangled
alpha
login
or
join now
moth11.net
/
spc
4
fork
atom
stream.place chat terminal ui
4
fork
atom
overview
issues
pulls
pipelines
added colors
moth11.net
6 months ago
b11dedc6
b86e23da
+11
-4
1 changed file
expand all
collapse all
unified
split
beeper.go
+11
-4
beeper.go
···
15
15
"github.com/gopxl/beep"
16
16
"github.com/gopxl/beep/speaker"
17
17
"github.com/gopxl/beep/wav"
18
18
+
"hash/fnv"
18
19
"log/slog"
19
20
"os"
20
21
"time"
···
63
64
np,
64
65
tp,
65
66
}
66
66
-
fmt.Println("starting!!")
67
67
go consumeLoop(context.Background(), ns)
68
68
ns.tp.Run()
69
69
}
···
216
216
}
217
217
218
218
func (m model) View() string {
219
219
-
s := ""
219
219
+
s := "\n"
220
220
for _, record := range m.records {
221
221
str := "invalid handle"
222
222
if record.handle != nil {
223
223
str = fmt.Sprintf("%s ", *record.handle)
224
224
}
225
225
-
bold := lipgloss.NewStyle().Bold(true)
226
226
-
225
225
+
bold := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(hashStringToColor(str)))
227
226
bdy := ""
228
227
if record.text != nil {
229
228
bdy = fmt.Sprintf("%s", *record.text)
···
232
231
}
233
232
return s
234
233
}
234
234
+
235
235
+
func hashStringToColor(s string) string {
236
236
+
h := fnv.New32a()
237
237
+
h.Write([]byte(s))
238
238
+
ui := h.Sum32()
239
239
+
guess := fmt.Sprintf("#%06x", ui)
240
240
+
return guess[0:7]
241
241
+
}