summaryrefslogtreecommitdiff
path: root/ui/ui.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-07-14 00:03:27 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-07-14 11:40:38 +0200
commitb680d6ccd1d8223ceb353987457098d86b7909e0 (patch)
treef3b9b2ae14e83aa77d6fafee9c12ee72a1c144af /ui/ui.go
parentPrint the channel topic on join (diff)
ui: Introduce a vertical member list on channels
Also, fix the UI timeline clearing too much, as well as the status line. Also, remove the width in the editor and buffer list constructors. We were initializing them with wrong values, only to overwrite these values with correct ones later in Resize().
Diffstat (limited to 'ui/ui.go')
-rw-r--r--ui/ui.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/ui/ui.go b/ui/ui.go
index ef8fea6..fe18d0e 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -5,14 +5,17 @@ import (
"sync/atomic"
"time"
+ "git.sr.ht/~taiite/senpai/irc"
+
"github.com/gdamore/tcell/v2"
)
type Config struct {
- NickColWidth int
- ChanColWidth int
- AutoComplete func(cursorIdx int, text []rune) []Completion
- Mouse bool
+ NickColWidth int
+ ChanColWidth int
+ MemberColWidth int
+ AutoComplete func(cursorIdx int, text []rune) []Completion
+ Mouse bool
}
type UI struct {
@@ -46,7 +49,7 @@ func New(config Config) (ui *UI, err error) {
}
ui.screen.EnablePaste()
- w, h := ui.screen.Size()
+ _, h := ui.screen.Size()
ui.screen.Clear()
ui.screen.ShowCursor(0, h-2)
@@ -59,8 +62,8 @@ func New(config Config) (ui *UI, err error) {
}
}()
- ui.bs = NewBufferList(w, h, ui.config.NickColWidth)
- ui.e = NewEditor(w, ui.config.AutoComplete)
+ ui.bs = NewBufferList()
+ ui.e = NewEditor(ui.config.AutoComplete)
ui.Resize()
return
@@ -242,18 +245,20 @@ func (ui *UI) InputClear() bool {
func (ui *UI) Resize() {
w, h := ui.screen.Size()
- ui.e.Resize(w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth)
- ui.bs.ResizeTimeline(w-ui.config.ChanColWidth, h-2, ui.config.NickColWidth)
+ innerWidth := w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth - ui.config.MemberColWidth
+ ui.e.Resize(innerWidth)
+ ui.bs.ResizeTimeline(innerWidth, h-2)
}
-func (ui *UI) Draw() {
+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)
ui.bs.DrawTimeline(ui.screen, ui.config.ChanColWidth, 0, ui.config.NickColWidth)
ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, ui.config.ChanColWidth, h)
- ui.drawStatusBar(ui.config.ChanColWidth, h-2, w-ui.config.ChanColWidth)
+ ui.bs.DrawVerticalMemberList(ui.screen, w-ui.config.MemberColWidth, 0, ui.config.MemberColWidth, h, members)
+ 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)
@@ -264,6 +269,8 @@ func (ui *UI) Draw() {
}
func (ui *UI) drawStatusBar(x0, y, width int) {
+ width--
+
st := tcell.StyleDefault.Dim(true)
for x := x0; x < x0+width; x++ {