diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-11-07 11:49:27 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-11-07 11:49:27 +0530 |
| commit | 6c3f7442b92f2fbf2308d93ece448cf3dd759a58 (patch) | |
| tree | f05287259e7da168355fa3798e80079f6dda1087 /lib/Daffm/Configuration.hs | |
| parent | 0e4a7e45357e6024586b6042c1f4c173926a2ace (diff) | |
| download | daffm-6c3f7442b92f2fbf2308d93ece448cf3dd759a58.tar.gz daffm-6c3f7442b92f2fbf2308d93ece448cf3dd759a58.zip | |
Add custom commands
Diffstat (limited to '')
| -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 |
