summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-03 14:54:55 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commit4912205adb5e8e245b33b8e0d5581bcf0ec37e8a (patch)
tree90e28657c0af72cd0a880842f88750c01a32834d /pkg/gui/gui.go
parent9440dcf9de3214927125693e512cdc941ca4e123 (diff)
remove viper
WIP
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 06d79e12d..46861e72f 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -433,13 +433,14 @@ func (gui *Gui) Run() error {
}
g.OnSearchEscape = gui.onSearchEscape
- g.SearchEscapeKey = gui.getKey("universal.return")
- g.NextSearchMatchKey = gui.getKey("universal.nextMatch")
- g.PrevSearchMatchKey = gui.getKey("universal.prevMatch")
+ userConfig := gui.Config.GetUserConfig()
+ g.SearchEscapeKey = gui.getKey(userConfig.Keybinding.Universal.Return)
+ g.NextSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.NextMatch)
+ g.PrevSearchMatchKey = gui.getKey(userConfig.Keybinding.Universal.PrevMatch)
g.ASCII = runtime.GOOS == "windows" && runewidth.IsEastAsian()
- if gui.Config.GetUserConfig().GetBool("gui.mouseEvents") {
+ if userConfig.Gui.MouseEvents {
g.Mouse = true
}
@@ -450,7 +451,7 @@ func (gui *Gui) Run() error {
}
popupTasks := []func(chan struct{}) error{}
- configPopupVersion := gui.Config.GetUserConfig().GetInt("StartupPopupVersion")
+ configPopupVersion := gui.Config.GetUserConfig().StartupPopupVersion
// -1 means we've disabled these popups
if configPopupVersion != -1 && configPopupVersion < StartupPopupVersion {
popupTasks = append(popupTasks, gui.showIntroPopupMessage)
@@ -458,7 +459,7 @@ func (gui *Gui) Run() error {
gui.showInitialPopups(popupTasks)
gui.waitForIntro.Add(1)
- if gui.Config.GetUserConfig().GetBool("git.autoFetch") {
+ if gui.Config.GetUserConfig().Git.AutoFetch {
go gui.startBackgroundFetch()
}
@@ -572,7 +573,10 @@ func (gui *Gui) showInitialPopups(tasks []func(chan struct{}) error) {
func (gui *Gui) showIntroPopupMessage(done chan struct{}) error {
onConfirm := func() error {
done <- struct{}{}
- return gui.Config.WriteToUserConfig("startupPopupVersion", StartupPopupVersion)
+ return gui.Config.WriteToUserConfig(func(userConfig *config.UserConfig) error {
+ userConfig.StartupPopupVersion = StartupPopupVersion
+ return nil
+ })
}
return gui.ask(askOpts{
@@ -621,7 +625,7 @@ func (gui *Gui) startBackgroundFetch() {
// setColorScheme sets the color scheme for the app based on the user config
func (gui *Gui) setColorScheme() error {
userConfig := gui.Config.GetUserConfig()
- theme.UpdateTheme(userConfig)
+ theme.UpdateTheme(userConfig.Gui.Theme)
gui.g.FgColor = theme.InactiveBorderColor
gui.g.SelFgColor = theme.ActiveBorderColor