From 287e40855e3bceb258af247317a288d179e55c57 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Wed, 26 May 2021 12:44:35 +0200 Subject: Pick nick colors in terminal color scheme So that the colors go well with the terminal background. --- window.go | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'window.go') diff --git a/window.go b/window.go index 3633c18..3d80776 100644 --- a/window.go +++ b/window.go @@ -1,30 +1,23 @@ package senpai import ( - "math/rand" + "hash/fnv" "strings" "time" "git.sr.ht/~taiite/senpai/ui" + "github.com/gdamore/tcell/v2" ) var Home = "home" -var homeMessages = []string{ - "\x1dYou open an IRC client.", - "Welcome to the Internet Relay Network!", - "DMs & cie go here.", - "May the IRC be with you.", - "Hey! I'm senpai, you everyday IRC student!", - "Student? No, I'm an IRC \x02client\x02!", -} +const welcomeMessage = "senpai dev build. See senpai(1) for a list of keybindings and commands. Private messages and status notices go here." func (app *App) initWindow() { - hmIdx := rand.Intn(len(homeMessages)) app.win.AddBuffer(Home) app.win.AddLine(Home, false, ui.Line{ Head: "--", - Body: homeMessages[hmIdx], + Body: ui.PlainString(welcomeMessage), At: time.Now(), }) } @@ -67,3 +60,15 @@ func (app *App) setStatus() { } app.win.SetStatus(status) } + +func identColor(ident string) tcell.Color { + h := fnv.New32() + _, _ = h.Write([]byte(ident)) + return tcell.Color((h.Sum32()%15)+1) + tcell.ColorValid +} + +func identString(ident string) ui.StyledString { + color := identColor(ident) + style := tcell.StyleDefault.Foreground(color) + return ui.Styled(ident, style) +} -- cgit v1.2.3