summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-05-26 12:44:35 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-05-26 17:43:29 +0200
commit287e40855e3bceb258af247317a288d179e55c57 (patch)
tree063ac47fada92281fc82a3e4b36a4d6a402c461d /window.go
parentDo not go into infinite loops on TLS mismatch (diff)
Pick nick colors in terminal color scheme
So that the colors go well with the terminal background.
Diffstat (limited to 'window.go')
-rw-r--r--window.go27
1 files changed, 16 insertions, 11 deletions
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)
+}