summaryrefslogtreecommitdiff
path: root/client/window
diff options
context:
space:
mode:
Diffstat (limited to 'client/window')
-rw-r--r--client/window/window.go38
1 files changed, 38 insertions, 0 deletions
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]
+}