From 9b44d674a8c91d1aa48a935b97c1d989aa01ca1d Mon Sep 17 00:00:00 2001 From: Gabriel Volpe Date: Mon, 17 Oct 2022 12:48:04 +0200 Subject: [PATCH] polishing emoji work before cutting release --- data/emoji.settings | 1 + output/emoji.nix | 1 + src/DConf.hs | 12 ++++++++---- test/DConf2NixTest.hs | 23 +++++++++++++---------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/data/emoji.settings b/data/emoji.settings index cd791e1..09680be 100644 --- a/data/emoji.settings +++ b/data/emoji.settings @@ -1,3 +1,4 @@ [ org/gnome/Characters ] recent-characters=['💡'] some-other-character=['🤓'] +emoji-in-double-quotes=["🔥"] diff --git a/output/emoji.nix b/output/emoji.nix index 3f141a4..52831bc 100644 --- a/output/emoji.nix +++ b/output/emoji.nix @@ -6,6 +6,7 @@ with lib.hm.gvariant; { dconf.settings = { "org/gnome/Characters" = { + emoji-in-double-quotes = [ "🔥" ]; recent-characters = [ "💡" ]; some-other-character = [ "🤓" ]; }; diff --git a/src/DConf.hs b/src/DConf.hs index 24f7621..83e5f1b 100644 --- a/src/DConf.hs +++ b/src/DConf.hs @@ -87,11 +87,15 @@ vString parser = try $ do vAny :: Parsec Text () Value vAny = S . T.pack <$> manyTill anyChar (try $ lookAhead endOfLine) +emojiParser :: EmojiSupport -> [Parsec Text () Value] +emojiParser Enabled = [vEmoji] +emojiParser Disabled = [] + dconf :: EmojiSupport -> Parser -> Parsec Text () Value -dconf Enabled p = choice - [vBool, vInt, vDouble, vUint32, vInt64, vEmptyString, vEmoji, vString p, vTuple Enabled, vAny] -dconf Disabled p = choice - [vBool, vInt, vDouble, vUint32, vInt64, vEmptyString, vString p, vTuple Disabled, vAny] +dconf es p = + let xs = [vBool, vInt, vDouble, vUint32, vInt64, vEmptyString] + ys = [vString p, vTuple es, vAny] + in choice (xs ++ emojiParser es ++ ys) -- There is no support for variants in HM yet so we parse them as a string vListOfVariant :: Parsec Text () Value diff --git a/test/DConf2NixTest.hs b/test/DConf2NixTest.hs index 4b8ec89..df302aa 100644 --- a/test/DConf2NixTest.hs +++ b/test/DConf2NixTest.hs @@ -17,6 +17,9 @@ import Text.Parsec ( runParser ) prop_dconf2nix :: Property prop_dconf2nix = withTests (10 :: TestLimit) dconf2nix +baseProperty' :: FilePath -> FilePath -> Root -> Property +baseProperty' i o root = baseProperty i o root Disabled + baseProperty :: FilePath -> FilePath -> Root -> EmojiSupport -> Property baseProperty i o root es = property $ do input <- evalIO $ T.readFile i @@ -34,7 +37,7 @@ dconf2nix = let input = "data/dconf.settings" output = "output/dconf.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_custom_root :: Property prop_dconf2nix_custom_root = withTests (10 :: TestLimit) dconf2nixCustomRoot @@ -44,7 +47,7 @@ dconf2nixCustomRoot = let input = "data/custom.settings" output = "output/custom.nix" root = Root "ca/desrt/dconf-editor" - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_custom_nested_root :: Property prop_dconf2nix_custom_nested_root = @@ -55,14 +58,14 @@ dconf2nixCustomNestedRoot = let input = "data/nested.settings" output = "output/nested.nix" root = Root "org/gnome/desktop/peripherals" - in baseProperty input output root Disabled + in baseProperty' input output root dconf2nixIndexer :: Property dconf2nixIndexer = let input = "data/indexer.settings" output = "output/indexer.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_indexer :: Property prop_dconf2nix_indexer = withTests (10 :: TestLimit) dconf2nixIndexer @@ -72,7 +75,7 @@ dconf2nixNegative = let input = "data/negative.settings" output = "output/negative.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_negative :: Property prop_dconf2nix_negative = withTests (10 :: TestLimit) dconf2nixNegative @@ -82,7 +85,7 @@ dconf2nixJson = let input = "data/json.settings" output = "output/json.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_json :: Property prop_dconf2nix_json = withTests (10 :: TestLimit) dconf2nixJson @@ -92,7 +95,7 @@ dconf2nixClocks = let input = "data/clocks.settings" output = "output/clocks.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_clocks :: Property prop_dconf2nix_clocks = withTests (10 :: TestLimit) dconf2nixClocks @@ -102,7 +105,7 @@ dconf2nixKeybindings = let input = "data/keybindings.settings" output = "output/keybindings.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_keybindings :: Property prop_dconf2nix_keybindings = withTests (10 :: TestLimit) dconf2nixKeybindings @@ -112,7 +115,7 @@ dconf2nixScientificNotation = let input = "data/scientific-notation.settings" output = "output/scientific-notation.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_scientific_notation :: Property prop_dconf2nix_scientific_notation = @@ -123,7 +126,7 @@ dconf2nixHeaders = let input = "data/headers.settings" output = "output/headers.nix" root = Root T.empty - in baseProperty input output root Disabled + in baseProperty' input output root prop_dconf2nix_headers :: Property prop_dconf2nix_headers =