summaryrefslogtreecommitdiff
path: root/window.go
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2021-10-20 17:33:10 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-10-24 12:57:24 +0200
commit9fb4378753ddec61a504a0dec403f40d6def7e90 (patch)
tree32955930be2d97614f3ec6290f67d0556769a16e /window.go
parentRemove draft file (diff)
Support for soju.im/bouncer-networks
This patch also disable the highlight on reconnect. This might be an issue (the user would want to know when senpai is online again?), but with multiple connections, it's bothersome to have to unread all of them on start (it wasn't a problem with only one connection since it was read instantly). Now, lastbuffer.txt also contains the network ID, otherwise the user might end up on another buffer with the same name. This patch does not extend /r to support multiple networks (it will send the message to the latest query, whatever the current displayed network is).
Diffstat (limited to 'window.go')
-rw-r--r--window.go36
1 files changed, 22 insertions, 14 deletions
diff --git a/window.go b/window.go
index ce416ed..82941a1 100644
--- a/window.go
+++ b/window.go
@@ -9,42 +9,50 @@ import (
"github.com/gdamore/tcell/v2"
)
-var Home = "home"
-
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() {
- app.win.AddBuffer(Home)
- app.win.AddLine(Home, ui.NotifyNone, ui.Line{
+ app.win.AddBuffer("", "(home)", "")
+ app.win.AddLine("", "", ui.NotifyNone, ui.Line{
Head: "--",
Body: ui.PlainString(welcomeMessage),
At: time.Now(),
})
}
-func (app *App) queueStatusLine(line ui.Line) {
+type statusLine struct {
+ netID string
+ line ui.Line
+}
+
+func (app *App) queueStatusLine(netID string, line ui.Line) {
if line.At.IsZero() {
line.At = time.Now()
}
app.events <- event{
- src: uiEvent,
- content: line,
+ src: "*",
+ content: statusLine{
+ netID: netID,
+ line: line,
+ },
}
}
-func (app *App) addStatusLine(line ui.Line) {
- buffer := app.win.CurrentBuffer()
- if buffer != Home {
- app.win.AddLine(Home, ui.NotifyNone, line)
+func (app *App) addStatusLine(netID string, line ui.Line) {
+ currentNetID, buffer := app.win.CurrentBuffer()
+ if currentNetID == netID && buffer != "" {
+ app.win.AddLine(netID, buffer, ui.NotifyNone, line)
}
- app.win.AddLine(buffer, ui.NotifyNone, line)
+ app.win.AddLine(netID, "", ui.NotifyNone, line)
}
func (app *App) setStatus() {
- if app.s == nil {
+ netID, buffer := app.win.CurrentBuffer()
+ s := app.sessions[netID]
+ if s == nil {
return
}
- ts := app.s.Typings(app.win.CurrentBuffer())
+ ts := s.Typings(buffer)
status := ""
if 3 < len(ts) {
status = "several people are typing..."