commit 27060a9
Hubert Hirtz
·
2020-11-07 10:41:19 +0000 UTC
parent e967d02
Configurable channel list width
M
app.go
+1,
-0
1@@ -37,6 +37,7 @@ func NewApp(cfg Config) (app *App, err error) {
2
3 app.win, err = ui.New(ui.Config{
4 NickColWidth: cfg.NickColWidth,
5+ ChanColWidth: cfg.ChanColWidth,
6 AutoComplete: func(cursorIdx int, text []rune) []ui.Completion {
7 return app.completions(cursorIdx, text)
8 },
+4,
-0
1@@ -16,6 +16,7 @@ type Config struct {
2 Highlights []string
3 OnHighlight string `yaml:"on-highlight"`
4 NickColWidth int `yaml:"nick-column-width"`
5+ ChanColWidth int `yaml:"chan-column-width"`
6
7 Debug bool
8 }
9@@ -25,6 +26,9 @@ func ParseConfig(buf []byte) (cfg Config, err error) {
10 if cfg.NickColWidth <= 0 {
11 cfg.NickColWidth = 16
12 }
13+ if cfg.ChanColWidth <= 0 {
14+ cfg.ChanColWidth = 16
15+ }
16 return
17 }
18
M
ui/ui.go
+9,
-8
1@@ -9,6 +9,7 @@ import (
2
3 type Config struct {
4 NickColWidth int
5+ ChanColWidth int
6 AutoComplete func(cursorIdx int, text []rune) []Completion
7 }
8
9@@ -178,24 +179,24 @@ func (ui *UI) InputEnter() (content string) {
10
11 func (ui *UI) Resize() {
12 w, h := ui.screen.Size()
13- ui.e.Resize(w - 25 - ui.config.NickColWidth)
14- ui.bs.ResizeTimeline(w-16, h-2, ui.config.NickColWidth)
15+ ui.e.Resize(w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth)
16+ ui.bs.ResizeTimeline(w-ui.config.ChanColWidth, h-2, ui.config.NickColWidth)
17 }
18
19 func (ui *UI) Draw() {
20 w, h := ui.screen.Size()
21
22- ui.e.Draw(ui.screen, 25+ui.config.NickColWidth, h-1)
23+ ui.e.Draw(ui.screen, 9+ui.config.ChanColWidth+ui.config.NickColWidth, h-1)
24
25- ui.bs.DrawTimeline(ui.screen, 16, 0, ui.config.NickColWidth)
26- ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, 16, h)
27- ui.drawStatusBar(16, h-2, w-16)
28+ ui.bs.DrawTimeline(ui.screen, ui.config.ChanColWidth, 0, ui.config.NickColWidth)
29+ ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, ui.config.ChanColWidth, h)
30+ ui.drawStatusBar(ui.config.ChanColWidth, h-2, w-ui.config.ChanColWidth)
31
32- for x := 16; x < 25+ui.config.NickColWidth; x++ {
33+ for x := ui.config.ChanColWidth; x < 9+ui.config.ChanColWidth+ui.config.NickColWidth; x++ {
34 ui.screen.SetContent(x, h-1, ' ', nil, tcell.StyleDefault)
35 }
36 st := tcell.StyleDefault.Foreground(colorFromCode(IdentColor(ui.prompt)))
37- printIdent(ui.screen, 23, h-1, ui.config.NickColWidth, st, ui.prompt)
38+ printIdent(ui.screen, ui.config.ChanColWidth+7, h-1, ui.config.NickColWidth, st, ui.prompt)
39
40 ui.screen.Show()
41 }