blob: a877f7b236e86d37c36df439a46bb77c902abaf9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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]
}
|