diff options
-rw-r--r-- | config.go | 4 | ||||
-rw-r--r-- | doc/senpai.5.scd | 3 | ||||
-rw-r--r-- | ui/buffers.go | 31 | ||||
-rw-r--r-- | ui/ui.go | 37 |
4 files changed, 65 insertions, 10 deletions
@@ -91,8 +91,8 @@ func ParseConfig(buf []byte) (cfg Config, err error) { if cfg.NickColWidth <= 0 { cfg.NickColWidth = 16 } - if cfg.ChanColWidth <= 0 { - cfg.ChanColWidth = 16 + if cfg.ChanColWidth < 0 { + cfg.ChanColWidth = 0 } if cfg.MemberColWidth <= 0 { cfg.MemberColWidth = 16 diff --git a/doc/senpai.5.scd b/doc/senpai.5.scd index 6ad15ba..a25c337 100644 --- a/doc/senpai.5.scd +++ b/doc/senpai.5.scd @@ -76,7 +76,8 @@ on-highlight: | By default, 16. *chan-column-width* - The number of cells that the column for channels occupies. By default, 16. + Make the channel list vertical, with a width equals to the given amount of + cells. By default, the channel list is horizontal. *member-column-width* The number of cells that the column for members occupies. By default, 16. 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() } |