mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 10:58:02 +00:00
bahaghari/lib: init generateGlyphSet
This commit is contained in:
parent
8f7e13734a
commit
e8bdb850bc
@ -20,6 +20,6 @@ pkgs.lib.makeExtensible
|
|||||||
# a top-level attribute.
|
# a top-level attribute.
|
||||||
tinted-theming = callLibs ./tinted-theming.nix;
|
tinted-theming = callLibs ./tinted-theming.nix;
|
||||||
|
|
||||||
inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs;
|
inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs generateGlyphSet;
|
||||||
inherit (self.hex) toHexString;
|
inherit (self.hex) toHexString;
|
||||||
})
|
})
|
||||||
|
@ -46,4 +46,19 @@
|
|||||||
toBaseDigits = d: glyphs.${builtins.toString d};
|
toBaseDigits = d: glyphs.${builtins.toString d};
|
||||||
in
|
in
|
||||||
pkgs.lib.concatMapStrings toBaseDigits baseDigits;
|
pkgs.lib.concatMapStrings toBaseDigits baseDigits;
|
||||||
|
|
||||||
|
/* Generates a glyph set usable for `toBaseDigitsWithGlyphs`. Take note the
|
||||||
|
given list is assumed to be sorted and the generated glyph set starts at
|
||||||
|
`0` up to (`listLength - 1`).
|
||||||
|
|
||||||
|
Type: generateGlyphSet :: [ String ] -> Attrs
|
||||||
|
|
||||||
|
Example:
|
||||||
|
generateGlyphSet [ "0" "1" "2" "3" "4" "5" "6" "7" "8 "9" "A" "B" "C" "D" "E" "F" ]
|
||||||
|
*/
|
||||||
|
generateGlyphSet = glyphsList:
|
||||||
|
let
|
||||||
|
glyphsList' = pkgs.lib.lists.imap0 (i: glyph: { "${builtins.toString i}" = glyph; }) glyphsList;
|
||||||
|
in
|
||||||
|
pkgs.lib.foldl (acc: glyph: acc // glyph) { } glyphsList';
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,20 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
pkgs.lib.runTests {
|
pkgs.lib.runTests {
|
||||||
|
testGenerateCustomGlyphSet = {
|
||||||
|
expr = lib.trivial.generateGlyphSet [ "A" "B" "C" "D" "E" "F" "G" "H" ];
|
||||||
|
expected = customOctalGlyphs;
|
||||||
|
};
|
||||||
|
|
||||||
|
testGenerateBase24GlyphSet = {
|
||||||
|
expr =
|
||||||
|
lib.trivial.generateGlyphSet
|
||||||
|
[ "0" "1" "2" "3" "4" "5" "6" "7"
|
||||||
|
"8" "9" "A" "B" "C" "D" "E" "F"
|
||||||
|
"G" "H" "I" "J" "M" "N" "O" "P" ];
|
||||||
|
expected = customBase24Glyphs;
|
||||||
|
};
|
||||||
|
|
||||||
testBaseDigitWithCustomOctalGlyph = {
|
testBaseDigitWithCustomOctalGlyph = {
|
||||||
expr = lib.trivial.toBaseDigitsWithGlyphs 8 9 customOctalGlyphs;
|
expr = lib.trivial.toBaseDigitsWithGlyphs 8 9 customOctalGlyphs;
|
||||||
expected = "BB";
|
expected = "BB";
|
||||||
|
Loading…
Reference in New Issue
Block a user