summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtz.pm>2020-11-07 11:41:19 +0100
committerHubert Hirtz <hubert@hirtz.pm>2020-11-07 11:41:19 +0100
commit27060a93cafc28e47929e776d54a64725f7b8b03 (patch)
treee0c0fbe0a632dcb1d02540ce76d206066cc3f817
parentDefault user/real to nickname if unspecified (diff)
Configurable channel list width
-rw-r--r--app.go1
-rw-r--r--config.go4
-rw-r--r--ui/ui.go17
3 files changed, 14 insertions, 8 deletions
diff --git a/app.go b/app.go
index 2c8e7d7..128e319 100644
--- a/app.go
+++ b/app.go
@@ -37,6 +37,7 @@ func NewApp(cfg Config) (app *App, err error) {
app.win, err = ui.New(ui.Config{
NickColWidth: cfg.NickColWidth,
+ ChanColWidth: cfg.ChanColWidth,
AutoComplete: func(cursorIdx int, text []rune) []ui.Completion {
return app.completions(cursorIdx, text)
},
diff --git a/config.go b/config.go
index 65ca203..2515e57 100644
--- a/config.go
+++ b/config.go
@@ -16,6 +16,7 @@ type Config struct {
Highlights []string
OnHighlight string `yaml:"on-highlight"`
NickColWidth int `yaml:"nick-column-width"`
+ ChanColWidth int `yaml:"chan-column-width"`
Debug bool
}
@@ -25,6 +26,9 @@ func ParseConfig(buf []byte) (cfg Config, err error) {
if cfg.NickColWidth <= 0 {
cfg.NickColWidth = 16
}
+ if cfg.ChanColWidth <= 0 {
+ cfg.ChanColWidth = 16
+ }
return
}
diff --git a/ui/ui.go b/ui/ui.go
index 3acbe1e..79c30af 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -9,6 +9,7 @@ import (
type Config struct {
NickColWidth int
+ ChanColWidth int
AutoComplete func(cursorIdx int, text []rune) []Completion
}
@@ -178,24 +179,24 @@ func (ui *UI) InputEnter() (content string) {
func (ui *UI) Resize() {
w, h := ui.screen.Size()
- ui.e.Resize(w - 25 - ui.config.NickColWidth)
- ui.bs.ResizeTimeline(w-16, h-2, ui.config.NickColWidth)
+ ui.e.Resize(w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth)
+ ui.bs.ResizeTimeline(w-ui.config.ChanColWidth, h-2, ui.config.NickColWidth)
}
func (ui *UI) Draw() {
w, h := ui.screen.Size()
- ui.e.Draw(ui.screen, 25+ui.config.NickColWidth, h-1)
+ ui.e.Draw(ui.screen, 9+ui.config.ChanColWidth+ui.config.NickColWidth, h-1)
- ui.bs.DrawTimeline(ui.screen, 16, 0, ui.config.NickColWidth)
- ui.bs.DrawVerticalBufferList(ui.screen, 0, 0, 16, h)
- ui.drawStatusBar(16, h-2, w-16)
+ 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)
- for x := 16; x < 25+ui.config.NickColWidth; x++ {
+ for x := ui.config.ChanColWidth; x < 9+ui.config.ChanColWidth+ui.config.NickColWidth; x++ {
ui.screen.SetContent(x, h-1, ' ', nil, tcell.StyleDefault)
}
st := tcell.StyleDefault.Foreground(colorFromCode(IdentColor(ui.prompt)))
- printIdent(ui.screen, 23, h-1, ui.config.NickColWidth, st, ui.prompt)
+ printIdent(ui.screen, ui.config.ChanColWidth+7, h-1, ui.config.NickColWidth, st, ui.prompt)
ui.screen.Show()
}