Modules/Color: Prepare applyColors helper script
This commit is contained in:
16
home/modules/color/applyColors.py
Normal file
16
home/modules/color/applyColors.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import fileinput
|
||||||
|
|
||||||
|
colors: dict[str, str]
|
||||||
|
# colors: dict[str, str] = {
|
||||||
|
# "rosewater": "f5e0dc",
|
||||||
|
# "flamingo": "f2cdcd",
|
||||||
|
# }
|
||||||
|
|
||||||
|
|
||||||
|
def applyColorToLine(line: str) -> None:
|
||||||
|
print(f"{line} # piped")
|
||||||
|
|
||||||
|
|
||||||
|
# Apply transformation to every line from stdin
|
||||||
|
for line in fileinput.input():
|
||||||
|
applyColorToLine(line)
|
@ -2,6 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
mylib,
|
mylib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (config.modules) color;
|
inherit (config.modules) color;
|
||||||
@ -20,8 +21,29 @@ in {
|
|||||||
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
|
mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};};
|
||||||
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
|
mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};};
|
||||||
in {
|
in {
|
||||||
# This module sets its own options
|
# Helper script that processes a visual mode selection and replaces
|
||||||
# to the values specified in a colorscheme file.
|
# referenced colors in-place with their counterparts in this module.
|
||||||
|
# Usage: '<,'>!applyColors<cr>
|
||||||
|
home.packages = let
|
||||||
|
applyColors = let
|
||||||
|
mkPythonColorDef = name: value: " '${name}': '${value}',";
|
||||||
|
in
|
||||||
|
pkgs.writers.writePython3Bin
|
||||||
|
"applyColors"
|
||||||
|
(
|
||||||
|
builtins.concatStringsSep "\n" [
|
||||||
|
"colors: dict[str, str] = {"
|
||||||
|
(config.modules.color.hex.dark
|
||||||
|
|> builtins.mapAttrs mkPythonColorDef
|
||||||
|
|> builtins.attrValues
|
||||||
|
|> builtins.concatStringsSep "\n")
|
||||||
|
"}"
|
||||||
|
(builtins.readFile ./applyColors.py)
|
||||||
|
]
|
||||||
|
);
|
||||||
|
in [applyColors];
|
||||||
|
|
||||||
|
# This module sets its own options to the values specified in a colorscheme file.
|
||||||
# TODO: This is fucking stupid. Add an option to set a colorscheme,
|
# TODO: This is fucking stupid. Add an option to set a colorscheme,
|
||||||
# then provide a single hex/rgb/rgbString set, not this light/dark shit.
|
# then provide a single hex/rgb/rgbString set, not this light/dark shit.
|
||||||
modules.color = {
|
modules.color = {
|
||||||
|
Reference in New Issue
Block a user