diff options
author | Hubert Hirtz <hubert@hirtz.pm> | 2021-09-01 13:01:54 +0200 |
---|---|---|
committer | Hubert Hirtz <hubert@hirtz.pm> | 2021-09-01 13:01:54 +0200 |
commit | 526eb96db874951a8ad6f66e300ac8e7e5b809b9 (patch) | |
tree | b73c2a8f37bf0144284213e772fdf377096ee662 /ui | |
parent | Fetch missed messages on reconnect (diff) |
Channel list is horizontal by default
Diffstat (limited to 'ui')
-rw-r--r-- | ui/buffers.go | 31 | ||||
-rw-r--r-- | ui/ui.go | 37 |
2 files changed, 61 insertions, 7 deletions
diff --git a/ui/buffers.go b/ui/buffers.go index 681918c..b2f0930 100644 --- a/ui/buffers.go +++ b/ui/buffers.go @@ -413,6 +413,37 @@ func (bs *BufferList) DrawVerticalBufferList(screen tcell.Screen, x0, y0, width, } } +func (bs *BufferList) DrawHorizontalBufferList(screen tcell.Screen, x0, y0, width int) { + x := x0 + + for i, b := range bs.list { + if width <= x-x0 { + break + } + st := tcell.StyleDefault + if b.unread { + st = st.Bold(true) + } else if i == bs.current { + st = st.Underline(true) + } + if i == bs.clicked { + st = st.Reverse(true) + } + title := truncate(b.title, width-x, "\u2026") + printString(screen, &x, y0, Styled(title, st)) + if 0 < b.highlights { + st = st.Foreground(tcell.ColorRed).Reverse(true) + screen.SetContent(x, y0, ' ', nil, st) + x++ + printNumber(screen, &x, y0, st, b.highlights) + screen.SetContent(x, y0, ' ', nil, st) + x++ + } + screen.SetContent(x, y0, ' ', nil, tcell.StyleDefault) + x++ + } +} + func (bs *BufferList) DrawVerticalMemberList(screen tcell.Screen, x0, y0, width, height int, members []irc.Member, offset *int) { st := tcell.StyleDefault @@ -273,7 +273,11 @@ func (ui *UI) Resize() { w, h := ui.screen.Size() innerWidth := w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth - ui.config.MemberColWidth ui.e.Resize(innerWidth) - ui.bs.ResizeTimeline(innerWidth, h-2) + if ui.config.ChanColWidth == 0 { + ui.bs.ResizeTimeline(innerWidth, h-3) + } else { + ui.bs.ResizeTimeline(innerWidth, h-2) + } } func (ui *UI) Size() (int, int) { @@ -283,17 +287,36 @@ func (ui *UI) Size() (int, int) { func (ui *UI) Draw(members []irc.Member) { w, h := ui.screen.Size() - ui.e.Draw(ui.screen, 9+ui.config.ChanColWidth+ui.config.NickColWidth, h-1) + if ui.config.ChanColWidth == 0 { + ui.e.Draw(ui.screen, 9+ui.config.NickColWidth, h-2) + } else { + ui.e.Draw(ui.screen, 9+ui.config.ChanColWidth+ui.config.NickColWidth, h-1) + } ui.bs.DrawTimeline(ui.screen, ui.config.ChanColWidth, 0, ui.config.NickColWidth) - ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, ui.config.ChanColWidth, h) + if ui.config.ChanColWidth == 0 { + ui.bs.DrawHorizontalBufferList(ui.screen, 0, h-1, w-ui.config.MemberColWidth) + } else { + ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, ui.config.ChanColWidth, h) + } ui.bs.DrawVerticalMemberList(ui.screen, w-ui.config.MemberColWidth, 0, ui.config.MemberColWidth, h, members, &ui.memberOffset) - ui.drawStatusBar(ui.config.ChanColWidth, h-2, w-ui.config.ChanColWidth-ui.config.MemberColWidth) + if ui.config.ChanColWidth == 0 { + ui.drawStatusBar(ui.config.ChanColWidth, h-3, w-ui.config.MemberColWidth) + } else { + ui.drawStatusBar(ui.config.ChanColWidth, h-2, w-ui.config.ChanColWidth-ui.config.MemberColWidth) + } - for x := ui.config.ChanColWidth; x < 9+ui.config.ChanColWidth+ui.config.NickColWidth; x++ { - ui.screen.SetContent(x, h-1, ' ', nil, tcell.StyleDefault) + if ui.config.ChanColWidth == 0 { + for x := 0; x < 9+ui.config.NickColWidth; x++ { + ui.screen.SetContent(x, h-2, ' ', nil, tcell.StyleDefault) + } + printIdent(ui.screen, 7, h-2, ui.config.NickColWidth, ui.prompt) + } else { + for x := ui.config.ChanColWidth; x < 9+ui.config.ChanColWidth+ui.config.NickColWidth; x++ { + ui.screen.SetContent(x, h-1, ' ', nil, tcell.StyleDefault) + } + printIdent(ui.screen, ui.config.ChanColWidth+7, h-1, ui.config.NickColWidth, ui.prompt) } - printIdent(ui.screen, ui.config.ChanColWidth+7, h-1, ui.config.NickColWidth, ui.prompt) ui.screen.Show() } |