2023-09-15 17:12:35 +10:00
|
|
|
package application
|
|
|
|
|
|
|
|
|
|
var blankApplicationEventContext = &ApplicationEventContext{}
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
openedFiles = "openedFiles"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ApplicationEventContext struct {
|
|
|
|
|
// contains filtered or unexported fields
|
|
|
|
|
data map[string]any
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c ApplicationEventContext) OpenedFiles() []string {
|
|
|
|
|
files, ok := c.data[openedFiles]
|
|
|
|
|
if !ok {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
result, ok := files.([]string)
|
|
|
|
|
if !ok {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c ApplicationEventContext) setOpenedFiles(files []string) {
|
|
|
|
|
c.data[openedFiles] = files
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c ApplicationEventContext) setIsDarkMode(mode bool) {
|
|
|
|
|
c.data["isDarkMode"] = mode
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 18:12:12 +08:00
|
|
|
func (c ApplicationEventContext) getBool(key string) bool {
|
|
|
|
|
mode, ok := c.data[key]
|
2023-09-15 17:12:35 +10:00
|
|
|
if !ok {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
result, ok := mode.(bool)
|
|
|
|
|
if !ok {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 18:12:12 +08:00
|
|
|
func (c ApplicationEventContext) IsDarkMode() bool {
|
|
|
|
|
return c.getBool("isDarkMode")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c ApplicationEventContext) HasVisibleWindows() bool {
|
|
|
|
|
return c.getBool("hasVisibleWindows")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c ApplicationEventContext) setData(data map[string]any) {
|
|
|
|
|
c.data = data
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-15 17:12:35 +10:00
|
|
|
func newApplicationEventContext() *ApplicationEventContext {
|
|
|
|
|
return &ApplicationEventContext{
|
|
|
|
|
data: make(map[string]any),
|
|
|
|
|
}
|
|
|
|
|
}
|