From e2dc5b6fbb6adf6f379ef0123c214a196211c305 Mon Sep 17 00:00:00 2001 From: citrons Date: Sun, 1 Jun 2025 15:38:17 -0500 Subject: joining channels --- client/window/window.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 client/window/window.go (limited to 'client/window/window.go') diff --git a/client/window/window.go b/client/window/window.go new file mode 100644 index 0000000..a877f7b --- /dev/null +++ b/client/window/window.go @@ -0,0 +1,38 @@ +package window + +import ( + "citrons.xyz/talk/client/buffer" + "citrons.xyz/talk/tui" +) + +type Location interface { + CreateWindow() Window +} + +type Window interface { + Location() Location + Kill() + Buffer() *buffer.Buffer + Input() *tui.TextInput + Send(text string) + ShowStatusLine() +} + +type WindowCache struct { + windows map[Location]Window +} + +func NewCache() WindowCache { + return WindowCache {make(map[Location]Window)} +} + +func (wc *WindowCache) Open(l Location) Window { + if wc.windows[l] == nil { + wc.windows[l] = l.CreateWindow() + } + return wc.windows[l] +} + +func (wc *WindowCache) Get(l Location) Window { + return wc.windows[l] +} -- cgit v1.2.3