aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/col.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-16 23:51:35 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-12-16 23:53:01 +0900
commitf40eab09f26f4ee2c6008dbd0f6ca1a2da8516b1 (patch)
treed33ff9f196eec085da8ec907ffaad7a5b8b0f497 /src/bin/col.c
parentfix mouse scroll on mode SGR/NONE. Closes T661 (diff)
downloadterminology-f40eab09f26f4ee2c6008dbd0f6ca1a2da8516b1.tar.gz
color options - fill in colors options panel.
this makes the colors config work and able to save/load a custom color palette. when enabled it overrides the theme provided palette for the "base" 48 colors (normal + bright with intense modes of each).
Diffstat (limited to 'src/bin/col.c')
-rw-r--r--src/bin/col.c94
1 files changed, 68 insertions, 26 deletions
diff --git a/src/bin/col.c b/src/bin/col.c
index 2a5da82..7203ea3 100644
--- a/src/bin/col.c
+++ b/src/bin/col.c
@@ -1,6 +1,7 @@
#include "private.h"
+#include <Elementary.h>
+#include "config.h"
#include "col.h"
-#include <Edje.h>
typedef struct _Color Color;
@@ -377,7 +378,7 @@ static const Color colors256[256] =
};
void
-colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
+colors_term_init(Evas_Object *textgrid, Evas_Object *bg, Config *config)
{
int c, n;
int r, g, b, a;
@@ -385,36 +386,56 @@ colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
for (c = 0; c < 4 * 12; c++)
{
- snprintf(buf, sizeof(buf) - 1, "c%i", 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))
+ if (config->colors_use)
{
+ n = c + (24 * (c / 24));
+
+ r = config->colors[c].r;
+ g = config->colors[c].g;
+ b = config->colors[c].b;
+ a = config->colors[c].a;
/* normal */
- evas_object_textgrid_palette_set(
- textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n,
- r, g, b, a);
+ evas_object_textgrid_palette_set
+ (textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n,
+ r, g, b, a);
/* faint */
- evas_object_textgrid_palette_set(
- textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n + 24,
- r/2, g/2, b/2, a/2);
+ evas_object_textgrid_palette_set
+ (textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n + 24,
+ r / 2, g / 2, b / 2, a / 2);
}
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,
- color.r/2, color.g/2, color.b/2, color.a/2);
+ snprintf(buf, sizeof(buf) - 1, "c%i", 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))
+ {
+ /* normal */
+ evas_object_textgrid_palette_set
+ (textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n,
+ r, g, b, a);
+ /* faint */
+ evas_object_textgrid_palette_set
+ (textgrid, EVAS_TEXTGRID_PALETTE_STANDARD, n + 24,
+ r / 2, g / 2, b / 2, a / 2);
+ }
+ 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,
+ color.r / 2, color.g / 2, color.b / 2, color.a / 2);
+ }
}
}
for (c = 0; c < 256; c++)
@@ -440,3 +461,24 @@ colors_term_init(Evas_Object *textgrid, Evas_Object *bg)
}
}
}
+
+void
+colors_standard_get(int set, int col, unsigned char *r, unsigned char *g, unsigned char *b, unsigned char *a)
+{
+ if ((set >= 0) && (set < 4))
+ {
+ int s1, s2;
+
+ s1 = set / 2;
+ s2 = set % 2;
+ *r = colors[s1][s2][col].r;
+ *g = colors[s1][s2][col].g;
+ *b = colors[s1][s2][col].b;
+ *a = colors[s1][s2][col].a;
+ return;
+ }
+ *r = 0;
+ *g = 0;
+ *b = 0;
+ *a = 0;
+}