summaryrefslogtreecommitdiff
path: root/src/remote.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-05-07 18:52:23 +0200
committerMaxime Coste <frrrwww@gmail.com>2013-05-13 14:25:05 +0200
commit56ab33c9d6dc0255bf15ebd1fbc216766ffb247c (patch)
tree40f3cff1b16397f1ea4ab4c7bff7c69b3cd8a606 /src/remote.cc
parentd80815b927b54be6fb51d244b567f52185ee6cea (diff)
support specifying colors with RGB components
Diffstat (limited to 'src/remote.cc')
-rw-r--r--src/remote.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/remote.cc b/src/remote.cc
index 7b68f6f8..94128871 100644
--- a/src/remote.cc
+++ b/src/remote.cc
@@ -75,6 +75,17 @@ public:
write(memoryview<T>(vec));
}
+ void write(const Color& color)
+ {
+ write(color.color);
+ if (color.color == Colors::RGB)
+ {
+ write(color.r);
+ write(color.g);
+ write(color.b);
+ }
+ }
+
void write(const ColorPair& colors)
{
write(colors.first);
@@ -150,6 +161,20 @@ std::vector<T> read_vector(int socket)
}
template<>
+Color read<Color>(int socket)
+{
+ Color res;
+ res.color = read<Colors>(socket);
+ if (res.color == Colors::RGB)
+ {
+ res.r = read<unsigned char>(socket);
+ res.g = read<unsigned char>(socket);
+ res.b = read<unsigned char>(socket);
+ }
+ return res;
+}
+
+template<>
ColorPair read<ColorPair>(int socket)
{
ColorPair res;