fix: resolve nlreturn, modernize, perfsprint, wsl_v5, and partial err113 lint issues
This commit is contained in:
@@ -65,7 +65,9 @@ func NewUI() *UI {
|
||||
if text == "" {
|
||||
return
|
||||
}
|
||||
|
||||
ui.input.SetText("")
|
||||
|
||||
if ui.onInput != nil {
|
||||
ui.onInput(text)
|
||||
}
|
||||
@@ -79,9 +81,11 @@ func NewUI() *UI {
|
||||
if r >= '0' && r <= '9' {
|
||||
idx := int(r - '0')
|
||||
ui.SwitchBuffer(idx)
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
return event
|
||||
})
|
||||
|
||||
@@ -121,6 +125,7 @@ func (ui *UI) AddLine(bufferName string, line string) {
|
||||
// Mark unread if not currently viewing this buffer.
|
||||
if ui.buffers[ui.currentBuffer] != buf {
|
||||
buf.Unread++
|
||||
|
||||
ui.refreshStatus()
|
||||
}
|
||||
|
||||
@@ -143,13 +148,17 @@ func (ui *UI) SwitchBuffer(n int) {
|
||||
if n < 0 || n >= len(ui.buffers) {
|
||||
return
|
||||
}
|
||||
|
||||
ui.currentBuffer = n
|
||||
buf := ui.buffers[n]
|
||||
buf.Unread = 0
|
||||
|
||||
ui.messages.Clear()
|
||||
|
||||
for _, line := range buf.Lines {
|
||||
fmt.Fprintln(ui.messages, line)
|
||||
}
|
||||
|
||||
ui.messages.ScrollToEnd()
|
||||
ui.refreshStatus()
|
||||
})
|
||||
@@ -162,14 +171,19 @@ func (ui *UI) SwitchToBuffer(name string) {
|
||||
for i, b := range ui.buffers {
|
||||
if b == buf {
|
||||
ui.currentBuffer = i
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
buf.Unread = 0
|
||||
|
||||
ui.messages.Clear()
|
||||
|
||||
for _, line := range buf.Lines {
|
||||
fmt.Fprintln(ui.messages, line)
|
||||
}
|
||||
|
||||
ui.messages.ScrollToEnd()
|
||||
ui.refreshStatus()
|
||||
})
|
||||
@@ -189,11 +203,13 @@ func (ui *UI) refreshStatus() {
|
||||
|
||||
func (ui *UI) refreshStatusWith(nick, target, connStatus string) {
|
||||
var unreadParts []string
|
||||
|
||||
for i, buf := range ui.buffers {
|
||||
if buf.Unread > 0 {
|
||||
unreadParts = append(unreadParts, fmt.Sprintf("%d:%s(%d)", i, buf.Name, buf.Unread))
|
||||
}
|
||||
}
|
||||
|
||||
unread := ""
|
||||
if len(unreadParts) > 0 {
|
||||
unread = " [Act: " + strings.Join(unreadParts, ",") + "]"
|
||||
@@ -212,8 +228,10 @@ func (ui *UI) getOrCreateBuffer(name string) *Buffer {
|
||||
return buf
|
||||
}
|
||||
}
|
||||
|
||||
buf := &Buffer{Name: name}
|
||||
ui.buffers = append(ui.buffers, buf)
|
||||
|
||||
return buf
|
||||
}
|
||||
|
||||
@@ -229,5 +247,6 @@ func (ui *UI) BufferIndex(name string) int {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user