aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/col.c
diff options
context:
space:
mode:
authorBoris Faure <billiob@gmail.com>2013-01-20 16:48:18 +0000
committerBoris Faure <billiob@gmail.com>2013-01-20 16:48:18 +0000
commita7eb68799c1018e78f549a3f45e736f6effaf8dd (patch)
tree0800bef5a4f57fb3372b10df3299ae8d89221676 /src/bin/col.c
parentterminology: revert previous commit at it is not ready yet for primetime. (diff)
downloadterminology-a7eb68799c1018e78f549a3f45e736f6effaf8dd.tar.gz
terminology: read colors from theme
SVN revision: 83019
Diffstat (limited to 'src/bin/col.c')
-rw-r--r--src/bin/col.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/src/bin/col.c b/src/bin/col.c
index a08e1b9..8c0bb69 100644
--- a/src/bin/col.c
+++ b/src/bin/col.c
@@ -1,6 +1,16 @@
+#include "private.h"
#include "col.h"
+#include <Edje.h>
-const Color colors[2][2][12] =
+typedef struct _Color Color;
+
+struct _Color
+{
+ unsigned char r, g, b, a;
+};
+
+
+static const Color colors[2][2][12] =
{
{ // normal
{ // normal
@@ -64,7 +74,7 @@ const Color colors[2][2][12] =
}
};
-const Color colors256[256] =
+static const Color colors256[256] =
{
// basic 16 repeated
/*
@@ -383,3 +393,62 @@ const Color colors256[256] =
{ 0xe4, 0xe4, 0xe4, 0xff },
{ 0xee, 0xee, 0xee, 0xff },
};
+
+void colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
+{
+ int c, n, l, k, j, i;
+ int r, g, b, a;
+ char buf[32];
+
+ for (c = 0; c < 4 * 12; c++)
+ {
+ snprintf(buf, sizeof(buf) - 1, "color-%d", c);
+
+ n = c + 24 * ( c / 24);
+
+ if (edje_object_color_class_get(bg, buf,
+ &r, &g, &b, &a,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL))
+ {
+ evas_object_textgrid_palette_set(
+ textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, c,
+ r, g, b, a);
+ }
+ else
+ {
+ Color color = colors[c/24][(c%24)/12][c%12];
+
+ /* normal */
+ evas_object_textgrid_palette_set(
+ textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n,
+ color.r, color.g, color.b, color.a);
+ /* faint */
+ evas_object_textgrid_palette_set(
+ textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n + 24,
+ r/2, g/2, b/2, a/2);
+ }
+ }
+ for (c = 0; c < 256; c++)
+ {
+ snprintf(buf, sizeof(buf) - 1, "256color-%d", c);
+
+ if (edje_object_color_class_get(bg, buf,
+ &r, &g, &b, &a,
+ NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL))
+ {
+ evas_object_textgrid_palette_set(
+ textgrid, EVAS_TEXTGRID_PALETTE_EXTENDED, c,
+ r, g, b, a);
+ }
+ else
+ {
+ Color color = colors256[c];
+
+ evas_object_textgrid_palette_set(
+ textgrid, EVAS_TEXTGRID_PALETTE_EXTENDED, c,
+ color.r, color.g, color.b, color.a);
+ }
+ }
+}