1
0
mirror of https://github.com/mrusme/neonmodem.git synced 2024-12-04 14:46:37 -05:00
neonmodem/ui/views/posts/wm.go
2023-01-01 22:01:05 -05:00

48 lines
740 B
Go

package posts
var WM_ROOT_ID = "list"
func (m *Model) WMOpen(id string) bool {
if m.WMisOpen(id) {
if m.WMisFocused(id) {
return true
}
return false
}
m.wm = append(m.wm, id)
return true
}
func (m *Model) WMCloseFocused() bool {
return m.WMClose(m.WMFocused())
}
func (m *Model) WMClose(id string) bool {
for i := len(m.wm) - 1; i > 0; i-- {
if m.wm[i] == id {
m.wm = append(m.wm[:i], m.wm[i+1:]...)
return true
}
}
return false
}
func (m *Model) WMFocused() string {
return m.wm[len(m.wm)-1]
}
func (m *Model) WMisOpen(id string) bool {
for _, openID := range m.wm {
if openID == id {
return true
}
}
return false
}
func (m *Model) WMisFocused(id string) bool {
return id == m.WMFocused()
}