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
"github.com/gopxl/beep"
16
"github.com/gopxl/beep/speaker"
17
"github.com/gopxl/beep/wav"
0
18
"log/slog"
19
"os"
20
"time"
···
63
np,
64
tp,
65
}
66
-
fmt.Println("starting!!")
67
go consumeLoop(context.Background(), ns)
68
ns.tp.Run()
69
}
···
216
}
217
218
func (m model) View() string {
219
-
s := ""
220
for _, record := range m.records {
221
str := "invalid handle"
222
if record.handle != nil {
223
str = fmt.Sprintf("%s ", *record.handle)
224
}
225
-
bold := lipgloss.NewStyle().Bold(true)
226
-
227
bdy := ""
228
if record.text != nil {
229
bdy = fmt.Sprintf("%s", *record.text)
···
232
}
233
return s
234
}
0
0
0
0
0
0
0
0
···
15
"github.com/gopxl/beep"
16
"github.com/gopxl/beep/speaker"
17
"github.com/gopxl/beep/wav"
18
+
"hash/fnv"
19
"log/slog"
20
"os"
21
"time"
···
64
np,
65
tp,
66
}
0
67
go consumeLoop(context.Background(), ns)
68
ns.tp.Run()
69
}
···
216
}
217
218
func (m model) View() string {
219
+
s := "\n"
220
for _, record := range m.records {
221
str := "invalid handle"
222
if record.handle != nil {
223
str = fmt.Sprintf("%s ", *record.handle)
224
}
225
+
bold := lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(hashStringToColor(str)))
0
226
bdy := ""
227
if record.text != nil {
228
bdy = fmt.Sprintf("%s", *record.text)
···
231
}
232
return s
233
}
234
+
235
+
func hashStringToColor(s string) string {
236
+
h := fnv.New32a()
237
+
h.Write([]byte(s))
238
+
ui := h.Sum32()
239
+
guess := fmt.Sprintf("#%06x", ui)
240
+
return guess[0:7]
241
+
}