From fe33ae88d3610eceeb79d5ecb2729aa1a6e81828 Mon Sep 17 00:00:00 2001 From: citrons Date: Mon, 2 Jun 2025 14:03:36 -0500 Subject: put default window functionality in concrete type --- client/channel_window.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'client/channel_window.go') diff --git a/client/channel_window.go b/client/channel_window.go index e5b50c3..b516775 100644 --- a/client/channel_window.go +++ b/client/channel_window.go @@ -14,9 +14,8 @@ type channelLocation struct { } type channelWindow struct { + window.DefaultWindow location channelLocation - buf buffer.Buffer - input tui.TextInput watchedUsers map[string]bool loadingHistory bool endOfHistory bool @@ -66,7 +65,7 @@ func (cw *channelWindow) isGone(uid string) bool { } func (cw *channelWindow) put(msg proto.Object) { - cw.buf.Add(channelMsg {msg, cw}) + cw.Buf.Add(channelMsg {msg, cw}) } func (cw *channelWindow) Location() window.Location { @@ -81,14 +80,10 @@ func (cw *channelWindow) Kill() { } func (cw *channelWindow) Buffer() *buffer.Buffer { - if cw.buf.AtTop() { + if cw.Buf.AtTop() { cw.loadMoreHistory() } - return &cw.buf -} - -func (cw *channelWindow) Input() *tui.TextInput { - return &cw.input + return &cw.Buf } func (cw *channelWindow) Send(text string) { @@ -110,7 +105,7 @@ func (cw *channelWindow) Send(text string) { } msg := proto.Object {"m", "", map[string]string {"": text}} globalApp.Request(proto.NewCmd("p", cw.location.id, msg), cb) - cw.input.SetText("") + cw.In.SetText("") } func (cw *channelWindow) leaveChannel() { @@ -139,7 +134,7 @@ func (cw *channelWindow) loadMoreHistory() { cw.loadingHistory = true rq := proto.Object {Fields: make(map[string]string)} - top := cw.buf.Top() + top := cw.Buf.Top() if top != nil { rq.Kind = "before" rq.Fields[""] = top.Msg().(channelMsg).Object.Id @@ -154,7 +149,7 @@ func (cw *channelWindow) loadMoreHistory() { cw.endOfHistory = true } for i := len(response.Args) - 1; i >= 0; i-- { - cw.buf.AddTop(channelMsg {response.Args[i], cw}) + cw.Buf.AddTop(channelMsg {response.Args[i], cw}) } case "fail": cw.endOfHistory = true -- cgit v1.2.3