diff options
Diffstat (limited to 'app.go')
-rw-r--r-- | app.go | 85 |
1 files changed, 62 insertions, 23 deletions
@@ -144,8 +144,11 @@ func NewApp(cfg Config) (app *App, err error) { app.mergeLine(former, addition) }, Colors: ui.ConfigColors{ - Unread: cfg.Colors.Unread, - Nicks: cfg.Colors.Nicks, + Unread: cfg.Colors.Unread, + Nicks: cfg.Colors.Nicks, + ServerForeground: cfg.Colors.ServerForeground, + ChanForegroundInactive: cfg.Colors.ChanForegroundInactive, + ChanForegroundActive: cfg.Colors.ChanForegroundActive, }, }) if err != nil { @@ -347,8 +350,10 @@ func (app *App) ircLoop(netID string) { content: nil, } app.queueStatusLine(netID, ui.Line{ - Head: "!!", + Head: ":(", + HeadTag: ":(", HeadColor: tcell.ColorRed, + Temporary: true, Body: ui.PlainString("Connection lost"), }) } @@ -356,8 +361,11 @@ func (app *App) ircLoop(netID string) { func (app *App) connect(netID string) net.Conn { app.queueStatusLine(netID, ui.Line{ - Head: "--", - Body: ui.PlainSprintf("Connecting to %s...", app.cfg.Addr), + Head: "﹒﹒﹒", + HeadTag: "﹒﹒﹒", + HeadColor: tcell.ColorOrange, + Temporary: true, + Body: ui.PlainSprintf("Connecting to %s…", app.cfg.Addr), }) conn, err := app.tryConnect() if err == nil { @@ -365,7 +373,9 @@ func (app *App) connect(netID string) net.Conn { } app.queueStatusLine(netID, ui.Line{ Head: "!!", + HeadTag: "!!", HeadColor: tcell.ColorRed, + Temporary: true, Body: ui.PlainSprintf("Connection failed: %v", err), }) return nil @@ -751,10 +761,11 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) { if s.Nick() != app.cfg.Nick { body = fmt.Sprintf("Connected to the server as %s", s.Nick()) } - app.addStatusLine(netID, ui.Line{ - At: msg.TimeOrNow(), - Head: "--", - Body: ui.PlainString(body), + app.addTemporaryStatusLine(netID, ui.Line{ + At: msg.TimeOrNow(), + Head: ":)", + HeadColor: tcell.ColorGreen, + Body: ui.PlainString(body), }) for target := range app.monitor[s.NetID()] { // TODO: batch MONITOR + @@ -768,7 +779,7 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) { body.AddStyle(0, textStyle) body.AddStyle(len(ev.FormerNick), arrowStyle) body.AddStyle(body.Len()-len(s.Nick()), textStyle) - app.addStatusLine(netID, ui.Line{ + app.addTemporaryStatusLine(netID, ui.Line{ At: msg.TimeOrNow(), Head: "--", HeadColor: tcell.ColorGray, @@ -991,32 +1002,55 @@ func (app *App) handleIRCEvent(netID string, ev interface{}) { } if ev.Code == "372" { app.win.AddLine(netID, "", ui.Line{ - At: msg.TimeOrNow(), - Head: "MOTD --", - Body: ui.PlainString(ev.Message), + At: msg.TimeOrNow(), + Head: "MOTD", + HeadTag: "motd", + HeadColor: tcell.ColorWhiteSmoke, + Body: ui.PlainString(ev.Message), + }) + break + } + if ev.Code == "396" { + app.win.AddLine(netID, "", ui.Line{ + At: msg.TimeOrNow(), + Head: "server", + HeadTag: "server", + HeadColor: tcell.ColorGray, + Body: ui.PlainString(ev.Message), }) break } var head string var body string + headColor := tcell.ColorGray + statusLine := false switch ev.Severity { case irc.SeverityFail: head = "--" + headColor = tcell.ColorRed body = fmt.Sprintf("Error (code %s): %s", ev.Code, ev.Message) case irc.SeverityWarn: head = "--" + headColor = tcell.ColorYellow body = fmt.Sprintf("Warning (code %s): %s", ev.Code, ev.Message) case irc.SeverityNote: - head = ev.Code + " --" + head = ev.Code body = ev.Message default: panic("unreachable") } - app.addStatusLine(netID, ui.Line{ - At: msg.TimeOrNow(), - Head: head, - Body: ui.PlainString(body), - }) + line := ui.Line{ + At: msg.TimeOrNow(), + Head: head, + HeadTag: head, + HeadColor: headColor, + Body: ui.PlainString(body), + } + if statusLine { + app.addStatusLine(netID, line) + } else { + app.win.AddLine(netID, "", line) + } } } @@ -1091,7 +1125,7 @@ func (app *App) notifyHighlight(buffer, nick, content string) { // if default path unreachable, simple bail if app.cfg.OnHighlightPath != "" { body := fmt.Sprintf("Unable to find on-highlight command at path: %q", path) - app.addStatusLine(netID, ui.Line{ + app.addTemporaryStatusLine(netID, ui.Line{ At: time.Now(), Head: "!!", HeadColor: tcell.ColorRed, @@ -1323,7 +1357,8 @@ func (app *App) formatMessage(s *irc.Session, ev irc.MessageEvent) (buffer strin head := ev.User headColor := tcell.ColorWhite if isAction || isNotice { - head = "*" + head = "﹡" + headColor = ui.IdentColor(app.cfg.Colors.Nicks, ev.User) } else { headColor = ui.IdentColor(app.cfg.Colors.Nicks, head) } @@ -1338,11 +1373,12 @@ func (app *App) formatMessage(s *irc.Session, ev irc.MessageEvent) (buffer strin body.WriteStyledString(ui.IRCString(content)) } else if isAction { color := ui.IdentColor(app.cfg.Colors.Nicks, ev.User) - body.SetStyle(tcell.StyleDefault.Foreground(color)) + body.SetStyle(tcell.StyleDefault.Italic(true).Foreground(color)) body.WriteString(ev.User) - body.SetStyle(tcell.StyleDefault) + body.SetStyle(tcell.StyleDefault.Italic(true)) body.WriteString(" ") body.WriteStyledString(ui.IRCString(content)) + body.SetStyle(tcell.StyleDefault) } else { body.WriteStyledString(ui.IRCString(content)) } @@ -1350,6 +1386,7 @@ func (app *App) formatMessage(s *irc.Session, ev irc.MessageEvent) (buffer strin line = ui.Line{ At: ev.Time, Head: head, + HeadTag: head, HeadColor: headColor, Notify: notification, Body: body.StyledString(), @@ -1496,6 +1533,7 @@ func (app *App) printTopic(netID, buffer string) (ok bool) { At: time.Now(), Head: "topic", HeadColor: tcell.ColorGray, + HeadTag: "topic", Body: ui.Styled(topic, tcell.StyleDefault.Foreground(tcell.ColorWhite)), }) if who != nil { @@ -1507,6 +1545,7 @@ func (app *App) printTopic(netID, buffer string) (ok bool) { At: time.Now(), Head: "—", HeadColor: tcell.ColorGray, + HeadTag: "topicby", Body: ui.Styled(body, tcell.StyleDefault.Foreground(tcell.ColorGray)), }) return true |