diff options
author | delthas <delthas@dille.cc> | 2021-07-14 00:13:46 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-07-14 11:17:54 +0200 |
commit | 2c7bc6ac7a8adcb591a975fbc3ab3abe47fa99fa (patch) | |
tree | fc2d3f60fefd7c1b665a1d82b6202ca322b03767 /app.go | |
parent | Automatically join channels on start (diff) |
Add notify types for fine-grained control of unread/highlight state
Namely, we want the unread light to show up only on actual messages, not
commands etc.
This opens the way for not showing an unread light when printing topic
on join.
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -405,7 +405,7 @@ func (app *App) handleKeyEvent(ev *tcell.EventKey) { input := app.win.InputEnter() err := app.handleInput(buffer, input) if err != nil { - app.win.AddLine(app.win.CurrentBuffer(), false, ui.Line{ + app.win.AddLine(app.win.CurrentBuffer(), ui.NotifyUnread, ui.Line{ At: time.Now(), Head: "!!", HeadColor: tcell.ColorRed, @@ -468,7 +468,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.WriteString(" as ") body.WriteString(app.s.Nick()) } - app.win.AddLine(Home, false, ui.Line{ + app.win.AddLine(Home, ui.NotifyUnread, ui.Line{ At: msg.TimeOrNow(), Head: "--", Body: body.StyledString(), @@ -499,7 +499,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorGray)) body.WriteString(ev.User) for _, c := range app.s.ChannelsSharedWith(ev.User) { - app.win.AddLine(c, false, ui.Line{ + app.win.AddLine(c, ui.NotifyNone, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -522,7 +522,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.WriteByte('+') body.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorGray)) body.WriteString(ev.User) - app.win.AddLine(ev.Channel, false, ui.Line{ + app.win.AddLine(ev.Channel, ui.NotifyNone, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -538,7 +538,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.WriteByte('-') body.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorGray)) body.WriteString(ev.User) - app.win.AddLine(ev.Channel, false, ui.Line{ + app.win.AddLine(ev.Channel, ui.NotifyNone, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -553,7 +553,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorGray)) body.WriteString(ev.User) for _, c := range ev.Channels { - app.win.AddLine(c, false, ui.Line{ + app.win.AddLine(c, ui.NotifyNone, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -567,7 +567,7 @@ func (app *App) handleIRCEvent(ev interface{}) { body.SetStyle(tcell.StyleDefault.Foreground(tcell.ColorGray)) body.WriteString("Topic changed to: ") body.WriteString(ev.Topic) - app.win.AddLine(ev.Channel, false, ui.Line{ + app.win.AddLine(ev.Channel, ui.NotifyUnread, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -575,7 +575,13 @@ func (app *App) handleIRCEvent(ev interface{}) { }) case irc.MessageEvent: buffer, line, hlNotification := app.formatMessage(ev) - app.win.AddLine(buffer, hlNotification, line) + var notify ui.NotifyType + if hlNotification { + notify = ui.NotifyHighlight + } else { + notify = ui.NotifyUnread + } + app.win.AddLine(buffer, notify, line) if hlNotification { app.notifyHighlight(buffer, ev.User, line.Body.String()) } |