From 205138b53b8845e72d5cb62e73173b3f41699e28 Mon Sep 17 00:00:00 2001 From: Matthias Fulz Date: Wed, 22 May 2019 17:13:51 +0200 Subject: [PATCH] Fixed info window Interface update --- fixed_info_window.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fixed_info_window.go b/fixed_info_window.go index a33b47d..4628a7b 100644 --- a/fixed_info_window.go +++ b/fixed_info_window.go @@ -25,19 +25,11 @@ func (l *FixedInfoWindow) GetLines(count int) []string { return ret } -func (l *FixedInfoWindow) AddLine(line *string) error { - if len(l.lines) <= l.maxLines { - l.lines = append(l.lines, line) +func (l *FixedInfoWindow) RequestLine(line int) *string { + if line < 0 || line > l.maxLines-1 { return nil } - - for i, il := range l.lines { - if il != nil { - l.lines[i] = line - return nil - } - } - return fmt.Errorf("No free lines") + return l.lines[line] } func (l *FixedInfoWindow) Clear() { @@ -51,13 +43,16 @@ func (l *FixedInfoWindow) ClearLine(line int) { return } - l.lines[line] = nil + l.lines[line] = new(string) } func NewFixedInfoWindow(lines int) *FixedInfoWindow { ret := new(FixedInfoWindow) ret.lines = []*string{} ret.maxLines = lines + for i := 0; i < ret.maxLines; i++ { + ret.lines = new(string) + } return ret }