
\begin{DoxyItemize}
\item infos = Information about the rgbcolor plugin is in keys below
\item infos/author = Philipp Gackstatter \href{mailto:philipp.gackstatter@student.tuwien.ac.at}{\tt philipp.\+gackstatter@student.\+tuwien.\+ac.\+at}
\item infos/licence = B\+SD
\item infos/needs =
\item infos/provides =
\item infos/recommends =
\item infos/ordering = type
\item infos/placements = postgetstorage presetstorage
\item infos/status = maintained unittest nodep
\item infos/metadata = check/rgbcolor
\item infos/description = Validation and normalization of rgbcolors
\end{DoxyItemize}

This plugin validates hex-\/formatted rgb color strings and normalizes them to decimal rgba format. It also accepts \href{https://www.w3.org/TR/css-color-3/#svg-color}{\tt named colors} and normalizes them.

\subsection*{Usage}

Add the metakey {\ttfamily check/rgbcolor} with an arbitrary value (e.\+g. {\ttfamily \char`\"{}\char`\"{}}) to the key that you want to check and normalize.

\subsection*{Examples}


\begin{DoxyCode}
# Mount a config file with the rgbcolor plugin
sudo kdb mount color.ecf user/tests/color dump rgbcolor

# Suceeds, since the value is a valid rgbcolor. Quotes are important!
kdb set user/tests/color/hex "#a1C2b3"

# Tell the plugin to validate the key and normalize if necessary
kdb setmeta user/tests/color/hex check/rgbcolor ""

# Colors are normalized to 32-bit unsigned integers
# This one is normalized to 0xa1C2b3ff
kdb get user/tests/color/hex
#> 2713891839

# Color names are supported (https://www.w3.org/TR/css-color-3/#svg-color)
kdb set user/tests/color/hex "yellowgreen"

# yellowgreen is 0x9acd32ff
kdb get user/tests/color/hex
#> 2597139199

kdb set user/tests/color/hex/subcolor "#abc"
kdb setmeta user/tests/color/hex/subcolor check/rgbcolor ""

# Expanded to rgba: #aabbccff
kdb get user/tests/color/hex/subcolor
#> 2864434431

kdb set user/tests/color/hex/subcolor "#abcd"

# Expanded to rgba: #aabbccdd
kdb get user/tests/color/hex/subcolor
#> 2864434397

kdb set user/tests/color/hex/subcolor "#aabbcc"

# Expanded to rgba: #aabbccff
kdb get user/tests/color/hex/subcolor
#> 2864434431

# Try to set incorrect value
kdb set user/tests/color/hex fff
# RET: 5

# Try to set incorrect value
kdb set user/tests/color/hex/subcolor "not a named color"
# RET: 5

# Try to set incorrect value
kdb set user/tests/color/hex "fff"
# RET: 5

# Try to set incorrect value
kdb set user/tests/color/hex "#12345"
# RET: 5

# Old values are still there
kdb get user/tests/color/hex
#> 2597139199

# Undo modifications to the key database
kdb rm -r user/tests/color
sudo kdb umount user/tests/color
\end{DoxyCode}
 