diff options
author | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-04 11:53:45 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtzfr.eu> | 2020-08-04 11:53:45 +0200 |
commit | 65852518bfc1ec61d3aa0a39fc25a837c6cf150c (patch) | |
tree | 2abb99a9ff13c2f07bf6b7c512c0d8b119e63de4 /ui | |
parent | Show channels as bold on unread messages (diff) |
Show nick highlights
Diffstat (limited to 'ui')
-rw-r--r-- | ui/buffers.go | 15 | ||||
-rw-r--r-- | ui/ui.go | 6 |
2 files changed, 16 insertions, 5 deletions
diff --git a/ui/buffers.go b/ui/buffers.go index 068894e..0592b65 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -334,7 +334,7 @@ func (bs *bufferList) Remove(title string) (ok bool) { return } -func (bs *bufferList) AddLine(title string, line Line) { +func (bs *bufferList) AddLine(title string, line Line, isHighlight bool) { idx := bs.idx(title) if idx < 0 { return @@ -359,6 +359,9 @@ func (bs *bufferList) AddLine(title string, line Line) { if !line.isStatus && idx != bs.current { b.unread = true } + if isHighlight && idx != bs.current { + b.highlights++ + } } func (bs *bufferList) AddLines(title string, lines []Line) { @@ -504,7 +507,7 @@ func (bs *bufferList) drawTitleList(screen tcell.Screen, y int) { for _, b := range bs.list { width := StringWidth(b.title) if 0 < b.highlights { - width += int(math.Log10(float64(b.highlights))) + 1 + width += int(math.Log10(float64(b.highlights))) + 3 } widths = append(widths, width) } @@ -529,7 +532,11 @@ func (bs *bufferList) drawTitleList(screen tcell.Screen, y int) { printString(screen, &x, y, st, b.title) if 0 < b.highlights { st = st.Foreground(tcell.ColorRed).Reverse(true) + screen.SetContent(x, y, ' ', nil, st) + x++ printNumber(screen, &x, y, st, b.highlights) + screen.SetContent(x, y, ' ', nil, st) + x++ } x += 2 i = (i + 1) % len(bs.list) @@ -547,7 +554,11 @@ func (bs *bufferList) drawTitleList(screen tcell.Screen, y int) { printString(screen, &x, y, st, b.title) if 0 < b.highlights { st = st.Foreground(tcell.ColorRed).Reverse(true) + screen.SetContent(x, y, ' ', nil, st) + x++ printNumber(screen, &x, y, st, b.highlights) + screen.SetContent(x, y, ' ', nil, st) + x++ } x -= widths[i] i = (i - 1 + len(bs.list)) % len(bs.list) @@ -46,7 +46,7 @@ func New() (ui *UI, err error) { hmIdx := rand.Intn(len(homeMessages)) ui.bs = newBufferList(w, h) ui.bs.Add(Home) - ui.bs.AddLine("", NewLineNow("--", homeMessages[hmIdx])) + ui.bs.AddLine("", NewLineNow("--", homeMessages[hmIdx]), false) ui.e = newEditor(w) @@ -113,8 +113,8 @@ func (ui *UI) RemoveBuffer(title string) { } } -func (ui *UI) AddLine(buffer string, line Line) { - ui.bs.AddLine(buffer, line) +func (ui *UI) AddLine(buffer string, line Line, isHighlight bool) { + ui.bs.AddLine(buffer, line, isHighlight) ui.draw() } |