diff options
Diffstat (limited to 'lib/Daffm/Configuration.hs')
| -rw-r--r-- | lib/Daffm/Configuration.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Daffm/Configuration.hs b/lib/Daffm/Configuration.hs index 3b61d6e..ee8f88e 100644 --- a/lib/Daffm/Configuration.hs +++ b/lib/Daffm/Configuration.hs @@ -26,7 +26,7 @@ defaultConfiguration = Configuration { configKeymap = defaultKeymaps, configOpener = Nothing, - configTheme = Map.empty, + configCommands = Map.empty, configExtend = Nothing } @@ -102,7 +102,7 @@ configurationCodec = <$> (keymapCodec "keymap" .= configKeymap) <*> (openerCodec "opener" .= configOpener) <*> (extendCodec "extend" .= configExtend) - <*> pure Map.empty .= configTheme + <*> (commandsCodec "commands" .= configCommands) where openerCodec = Toml.dioptional . Toml.text extendCodec = Toml.dioptional . Toml.text @@ -118,3 +118,11 @@ keymapCodec = Toml.dimap (const Map.empty) toKeymap . keymapRawCodec commandCodec k = cmdCodec k <|> cmdChainCodec k cmdCodec = Toml.dimap (const "") toCmd . Toml.text cmdChainCodec = Toml.dimap (const []) (CmdChain . map toCmd) . Toml.arrayOf Toml._Text + +commandsCodec :: Toml.Key -> Toml.TomlCodec (Map.Map Text.Text Command) +commandsCodec = Toml.tableMap Toml._KeyText commandCodec + where + toCmd = fromMaybe CmdNoop . parseCommand + commandCodec k = cmdCodec k <|> cmdChainCodec k + cmdCodec = Toml.dimap (const "") toCmd . Toml.text + cmdChainCodec = Toml.dimap (const []) (CmdChain . map toCmd) . Toml.arrayOf Toml._Text |
