コード例 #1
0
ファイル: textbox.c プロジェクト: guyhughes/rofi
static void textbox_parse_string (  Display *display, const char *str, RowColor *color )
{
    if ( str == NULL ) {
        return;
    }
    char *cstr = g_strdup ( str );
    char *endp = NULL;
    char *token;
    int  index = 0;
    for ( token = strtok_r ( cstr, ",", &endp ); token != NULL; token = strtok_r ( NULL, ",", &endp ) ) {
        switch ( index )
        {
        case 0:
            parse_color ( display, g_strstrip ( token ), &( color->bg ) );
            break;
        case 1:
            parse_color ( display, g_strstrip ( token ), &( color->fg ) );
            break;
        case 2:
            parse_color ( display, g_strstrip ( token ), &( color->bgalt ) );
            break;
        case 3:
            parse_color ( display, g_strstrip ( token ), &( color->hlbg ) );
            break;
        case 4:
            parse_color ( display, g_strstrip ( token ), &( color->hlfg ) );
            break;
        }
        index++;
    }
    g_free ( cstr );
}
コード例 #2
0
ファイル: highlighting.c プロジェクト: M1tt/geany
static void parse_keyfile_style(GKeyFile *kf, gchar **list,
		const GeanyLexerStyle *default_style, GeanyLexerStyle *style)
{
	gsize len;

	g_return_if_fail(default_style);
	g_return_if_fail(style);

	*style = *default_style;

	if (!list)
		return;

	len = g_strv_length(list);
	if (len == 0)
		return;
	else if (len == 1)
	{
		gchar **items = g_strsplit(list[0], ",", 0);
		if (items != NULL)
		{
			if (g_strv_length(items) > 0)
			{
				if (g_hash_table_lookup(named_style_hash, items[0]) != NULL)
				{
					if (!read_named_style(list[0], style))
						geany_debug("Unable to read named style '%s'", items[0]);
					g_strfreev(items);
					return;
				}
				else if (strchr(list[0], ',') != NULL)
				{
					geany_debug("Unknown named style '%s'", items[0]);
					g_strfreev(items);
					return;
				}
			}
			g_strfreev(items);
		}
	}

	switch (len)
	{
		case 4:
			style->italic = utils_atob(list[3]);
		case 3:
			style->bold = utils_atob(list[2]);
		case 2:
			parse_color(kf, list[1], &style->background);
		case 1:
			parse_color(kf, list[0], &style->foreground);
	}
}
コード例 #3
0
ファイル: tray.cpp プロジェクト: tmud/tortilla
int init(lua_State *L)
{
    if (!g_tray.create())
    {
        base::log(L, L"Критическая ошибка.");
        base::terminate(L);
        return 0;
    }

    base::addCommand(L, L"tray");
    base::addMenu(L, L"Плагины/Оповещения (tray)...", 1);

    luaT_Props p(L);
    g_tray.setFont(p.currentFont());
    g_tray.setAlarmWnd(base::getParent(L));
    g_tray.setActivated(p.activated());

    std::wstring path;
    base::getPath(L, L"config.xml", &path);

    TraySettings &s = g_tray.traySettings();
    s.timeout = 5;
    s.interval = 15;
    s.showactive = 1;
    s.text = GetSysColor(COLOR_INFOTEXT);
    s.background = GetSysColor(COLOR_INFOBK);

    std::wstring error;
    xml::node ld;
    if (ld.load(path.c_str(), &error) && ld.move(L"params"))
    {
        if (ld.get(L"timeout", &s.timeout))
            check_minmax(&s.timeout, 1, 5, MAX_TIMEOUT, MAX_TIMEOUT);
        if (ld.get(L"interval", &s.interval))
            check_minmax(&s.interval, 5, 5, MAX_INTERVAL, MAX_INTERVAL);
        int showactive = 1;
        if (ld.get(L"showactive", &showactive))
            check_minmax(&showactive, 0, 0, 1, 0);
        s.showactive = showactive ? true : false;
        std::wstring text, bkgnd;
        if (ld.get(L"textcolor", &text))
            parse_color(text, &s.text);
        if (ld.get(L"bkgndcolor", &bkgnd))
            parse_color(bkgnd, &s.background);
        ld.move(L"/");
    } else {
      if (!error.empty())
        base::log(L, error.c_str());
    }
    ld.deletenode();
    return 0;
}
コード例 #4
0
ファイル: command.c プロジェクト: matthiasbeyer/tasknc
void run_command_color(char *args) /* {{{ */
{
	/**
	 * create/modify a color rule
	 * syntax: object foreground background [rule]
	 */
	char *object = NULL, *fg = NULL, *bg = NULL, *rule = NULL;
	color_object obj;
	int ret = 0, fgc, bgc;

	if (args != NULL)
		ret = sscanf(args, "%ms %m[a-z0-9-] %m[a-z0-9-] %m[^\n]", &object, &fg, &bg, &rule);
	if (ret < 3)
	{
		statusbar_message(cfg.statusbar_timeout, "syntax: color <object> <foreground> <background> <rule>");
		tnc_fprintf(logfp, LOG_ERROR, "syntax: color <object> <foreground> <background> <rule>  [%d](%s)", ret, args);
		goto cleanup;
	}

	/* parse object */
	obj = parse_object(object);
	if (obj == OBJECT_NONE)
	{
		statusbar_message(cfg.statusbar_timeout, "color: invalid object \"%s\"", object);
		tnc_fprintf(logfp, LOG_ERROR, "color: invalid object \"%s\"", object);
		goto cleanup;
	}

	/* parse colors */
	fgc = parse_color(fg);
	bgc = parse_color(bg);
	if (bgc < -2 || fgc < -2)
	{
		statusbar_message(cfg.statusbar_timeout, "color: invalid colors \"%s\" \"%s\"", fg, bg);
		tnc_fprintf(logfp, LOG_ERROR, "color: invalid colors %d:\"%s\" %d:\"%s\"", fgc, fg, bgc, bg);
		goto cleanup;
	}

	/* create color rule */
	if (add_color_rule(obj, rule, fgc, bgc)>=0)
		statusbar_message(cfg.statusbar_timeout, "applied color rule");
	else
		statusbar_message(cfg.statusbar_timeout, "applying color rule failed");
	goto cleanup;

cleanup:
	check_free(object);
	check_free(fg);
	check_free(bg);
	check_free(rule);
} /* }}} */
コード例 #5
0
int init_terminal_ncurses(char *color, char *bcolor, int predefcol, int predefbgcol) {
	struct cols col, bgcol;
	initscr();
	curs_set(0);
	timeout(0);
	noecho();
	start_color();
	use_default_colors();

	double magic = 1000 / 255.0;
	int colp = 0, bgcolp = 0;

	col = parse_color(color);
	bgcol = parse_color(bcolor);
	if (col.col == -2) {
		init_color(1, (int)(col.R * magic), (int)(col.G * magic), (int)(col.B * magic));
	}
	if (bgcol.col == -2) {
		init_color(2, (int)(bgcol.R * magic), (int)(bgcol.G * magic), (int)(bgcol.B * magic));
	}

	switch (col.col) {
		case -2:
			colp = 1;
			break;
		case -1:
			colp = DEFAULTCOL;
			break;
		default:
			colp = predefcol;
	}

	switch (bgcol.col) {
		case -2:
			bgcolp = 2;
			break;
		case -1:
			bgcolp = DEFAULTBGCOL;
			break;
		default:
			bgcolp = predefbgcol;
	}

	init_pair(1, colp, bgcolp);
	if (bgcolp != -1)
		bkgd(COLOR_PAIR(1));
	attron(COLOR_PAIR(1));
//	attron(A_BOLD);
	return 0;
}
コード例 #6
0
ファイル: combostatus.c プロジェクト: Kotty666/xymon
int main(int argc, char *argv[])
{
	int argi; 
	int showeval = 1;
	int cleanexpr = 0;

	setup_signalhandler(argv[0]);

	for (argi = 1; (argi < argc); argi++) {
		if ((strcmp(argv[argi], "--help") == 0)) {
			printf("%s version %s\n\n", argv[0], VERSION);
			printf("Usage:\n%s [--quiet] [--clean] [--debug] [--no-update]\n", argv[0]);
			exit(0);
		}
		else if ((strcmp(argv[argi], "--version") == 0)) {
			printf("%s version %s\n", argv[0], VERSION);
			exit(0);
		}
		else if ((strcmp(argv[argi], "--debug") == 0)) {
			debug = 1;
		}
		else if ((strcmp(argv[argi], "--no-update") == 0)) {
			dontsendmessages = 1;
		}
		else if ((strcmp(argv[argi], "--quiet") == 0)) {
			showeval = 0;
		}
		else if ((strcmp(argv[argi], "--clean") == 0)) {
			cleanexpr = 1;
		}
		else if ((strncmp(argv[argi], "--error-colors=", 15) == 0)) {
			char *tok;
			int newerrorcolors = 0;

			tok = strtok(strchr(argv[argi], '=')+1, ",");
			while (tok) {
				int col = parse_color(tok);

				if ((col >= 0) && (col <= COL_RED)) newerrorcolors |= (1 << parse_color(tok));
				tok = strtok(NULL, ",");
			}

			if (newerrorcolors) errorcolors = newerrorcolors;
		}
	}

	return update_combotests(showeval, cleanexpr);
}
コード例 #7
0
void CL_CSSParserOutlineColor::parse(CL_CSSBoxProperties &properties, const CL_String &name, const std::vector<CL_CSSToken> &tokens, std::map<CL_String, CL_CSSBoxProperty *> *out_change_set)
{
	size_t pos = 0;
	CL_Colorf color;
	if (parse_color(tokens, pos, color) && pos == tokens.size())
	{
		properties.outline_color.type = CL_CSSBoxOutlineColor::type_color;
		properties.outline_color.color = color;
	}
	else
	{
		CL_CSSToken token = next_token(pos, tokens);
		if (token.type == CL_CSSToken::type_ident && pos == tokens.size())
		{
			if (equals(token.value, "invert"))
			{
				properties.outline_color.type = CL_CSSBoxOutlineColor::type_invert;
			}
			else if (equals(token.value, "inherit"))
			{
				properties.outline_color.type = CL_CSSBoxOutlineColor::type_inherit;
			}
		}
	}
	if (out_change_set)
	{
		(*out_change_set)["outline-color"] = &properties.outline_color;
	}
}
コード例 #8
0
ファイル: css_parser_color.cpp プロジェクト: Cassie90/ClanLib
void CSSParserColor::parse(const std::string &name, const std::vector<CSSToken> &tokens, std::vector<std::unique_ptr<CSSPropertyValue> > &inout_values)
{
	std::unique_ptr<CSSValueColor> color(new CSSValueColor());

	size_t pos = 0;
	Colorf colorf;
	if (parse_color(tokens, pos, colorf) && pos == tokens.size())
	{
		color->type = CSSValueColor::type_color;
		color->color = colorf;
	}
	else
	{
		CSSToken token = next_token(pos, tokens);
		if (token.type == CSSToken::type_ident && pos == tokens.size())
		{
			if (equals(token.value, "inherit"))
			{
				color->type = CSSValueColor::type_inherit;
			}
			else
			{
				return;
			}
		}
		else
		{
			return;
		}
	}

	inout_values.push_back(std::move(color));
}
コード例 #9
0
ファイル: style.c プロジェクト: Guff/lualock
int lualock_lua_style_set(lua_State *L) {
    gdouble r, g, b, a;
    lua_getfield(L, 1, "color");
    parse_color(luaL_optstring(L, 2, "#000000"), &r, &g, &b, &a);
    lua_pop(L, 1);
    lua_getfield(L, 1, "font");
    lua_getfield(L, 1, "x");
    lua_getfield(L, 1, "y");
    lua_getfield(L, 1, "off_x");
    lua_getfield(L, 1, "off_y");
    lua_getfield(L, 1, "width");
    lua_getfield(L, 1, "height");
    lua_getfield(L, 1, "bg_color");
    lua_getfield(L, 1, "border_color");
    lua_getfield(L, 1, "border_width");
    
    style_set(luaL_optstring(L, 2, DEFAULT_FONT),
              luaL_optnumber(L, 3, lualock.style.x),
              luaL_optnumber(L, 4, lualock.style.y),
              luaL_optnumber(L, 5, lualock.style.off_x),
              luaL_optnumber(L, 6, lualock.style.off_y),
              luaL_optnumber(L, 7, lualock.style.width),
              luaL_optnumber(L, 8, lualock.style.height),
              r, g, b, a,
              lua_tostring(L, 9),
              lua_tostring(L, 10),
              luaL_optnumber(L, 11, lualock.style.border_width));
    return 0;
}
コード例 #10
0
ファイル: config.cpp プロジェクト: k-stachowiak/kulki
dick::Color KulkiConfig::m_load_color(const std::string& symbol) const
{
    MoonValue *value = m_load_value(symbol.c_str());
    dick::Color result = parse_color(value, symbol);
    mn_dispose(value);
    return result;
}
コード例 #11
0
ファイル: usystem.c プロジェクト: MaddTheSane/MacBoard
static int
parse_cpair (ColorClass cc, char *str)
{
    if ((textColors[(int)cc].fg=parse_color(str, 0)) == -2) {
	fprintf(stderr, _("%s: can't parse foreground color in `%s'\n"),
		programName, str);
	return -1;
    }

    /* bg and attr are optional */
    textColors[(int)cc].bg = parse_color(str, 1);
    if ((textColors[(int)cc].attr = parse_color(str, 2)) < 0) {
	textColors[(int)cc].attr = 0;
    }
    return 0;
}
コード例 #12
0
static elemstyle_area_t *parse_area(xmlNode *a_node) {
  elemstyle_area_t *area = g_new0(elemstyle_area_t, 1);

  /* these have to be present */
  g_assert(parse_color(a_node, "colour", &area->color));
  return area;
}
コード例 #13
0
ファイル: parse_object.c プロジェクト: vbargues/RayTracer
t_obj				*parse_object(int fd, int id)
{
	char			**line;
	int				i;
	t_obj			*object;

	object = (t_obj *)malloc(sizeof(t_obj));
	init(object);
	line = malloc_line();
	while (get_next_line(fd, line) > 0 && (*line)[0] != '}' && !(i = 0))
	{
		while ((*line)[i] && ((*line)[i] < 'a' || (*line)[i] > 'z'))
			i++;
		if ((*line)[i] && strncmp(*line + i, "color", 5) == 0)
			object->color = parse_color(fd);
		else if ((*line)[i] && strncmp(*line + i, "text_x", 6) == 0)
			object->text_x = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "text_y", 6) == 0)
			object->text_y = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "offset_x", 8) == 0)
			object->offset_x = parse_radius(fd);
		else if ((*line)[i] && strncmp(*line + i, "offset_y", 8) == 0)
			object->offset_y = parse_radius(fd);
		la_norme_a_pas_dit_bonjour(line, object, i, fd);
	}
	object->id = id;
	return (object);
}
コード例 #14
0
ファイル: highlight.cpp プロジェクト: fimmtiu/fish-shell
rgb_color_t highlight_get_color( int highlight, bool is_background )
{
	size_t i;
	int idx=0;
	rgb_color_t result;

	if( highlight < 0 )
		return rgb_color_t::normal();
	if( highlight > (1<<VAR_COUNT) )
		return rgb_color_t::normal();
	for( i=0; i<VAR_COUNT; i++ )
	{
		if( highlight & (1<<i ))
		{
			idx = i;
			break;
		}
	}
    
	env_var_t val_wstr = env_get_string( highlight_var[idx]); 

//	debug( 1, L"%d -> %d -> %ls", highlight, idx, val );	
	
	if (val_wstr.missing())
		val_wstr = env_get_string( highlight_var[0]);
	
	if( ! val_wstr.missing() )
		result = parse_color( val_wstr, is_background );
	
	if( highlight & HIGHLIGHT_VALID_PATH )
	{
		env_var_t val2_wstr =  env_get_string( L"fish_color_valid_path" );
		const wcstring val2 = val2_wstr.missing() ? L"" : val2_wstr.c_str(); 

		rgb_color_t result2 = parse_color( val2, is_background );
		if( result.is_normal() )
			result = result2;
		else 
		{
			if( result2.is_bold() )
				result.set_bold(true);
			if( result2.is_underline() )
				result.set_underline(true);
		}
	}
	return result;
}
コード例 #15
0
ファイル: life.cpp プロジェクト: TkkrLab/ledart
Life::Life(rect_t rect, YAML::Node args):
Graphics(rect, args)
{
    this->field.resize(rect.width);
    this->buffer.resize(rect.width);
    for(fieldcol_t &row: this->field)
    {
        row.resize(rect.height);
    }
    for(fieldcol_t &row: this->buffer)
    {
        row.resize(rect.height);
    }

    // int x = 0;
    // int y = 0;
    // this->draw_pixel(x + 1, y + 0, this->color_alive);
    // this->draw_pixel(x + 2, y + 1, this->color_alive);
    // this->draw_pixel(x + 0, y + 2, this->color_alive);
    // this->draw_pixel(x + 1, y + 2, this->color_alive);
    // this->draw_pixel(x + 2, y + 2, this->color_alive);

    RGBColor_t color = BLACK;
    parse_color(get_arg<std::string>(args["acolor"], "BLUE"), color);
    this->color_alive = color;

    parse_color(get_arg<std::string>(args["dcolor"], "BLACK"), color);
    this->color_dead = color;

    this->color_step = get_arg<int>(args["cstep"], 1);

    this->mode = get_arg<int>(args["mode"], 0);

    for(int x = 0; x < rect.width; x++)
    {
        for(int y = 0; y < rect.height; y++)
        {
            bool state = (rand() % 2) ? ALIVE : DEAD;
            this->field[x][y] = state;
            if(state)
                this->draw_pixel(x, y, this->color_alive);
            else
                this->draw_pixel(x, y, this->color_dead);
        }
    }
}
コード例 #16
0
static void parse_query(void)
{
	cgidata_t *cwalk;

	cwalk = cgidata;
	while (cwalk) {
		/*
		 * cwalk->name points to the name of the setting.
		 * cwalk->value points to the value (may be an empty string).
		 */

		if (strcasecmp(cwalk->name, "HOSTSVC") == 0) {
			char *p = strrchr(cwalk->value, '.');

			if (p) { *p = '\0'; service = strdup(p+1); }
			hostname = strdup(cwalk->value);
			while ((p = strchr(hostname, ','))) *p = '.';
		}
		else if (strcasecmp(cwalk->name, "HOST") == 0) {
			hostname = strdup(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "SERVICE") == 0) {
			service = strdup(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "REPORTTIME") == 0) {
			reporttime = (char *) malloc(strlen(cwalk->value)+strlen("REPORTTIME=")+1);
			sprintf(reporttime, "REPORTTIME=%s", cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "WARNPCT") == 0) {
			reportwarnlevel = atof(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "STYLE") == 0) {
			if (strcmp(cwalk->value, "crit") == 0) style = STYLE_CRIT;
			else if (strcmp(cwalk->value, "nongr") == 0) style = STYLE_NONGR;
			else style = STYLE_OTHER;
		}
		else if (strcasecmp(cwalk->name, "ST") == 0) {
			/* Must be after "STYLE" */
			st = atol(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "END") == 0) {
			end = atol(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "COLOR") == 0) {
			char *colstr = (char *) malloc(strlen(cwalk->value)+2);
			sprintf(colstr, "%s ", cwalk->value);
			color = parse_color(colstr);
			xfree(colstr);
		}
		else if (strcasecmp(cwalk->name, "RECENTGIFS") == 0) {
			use_recentgifs = atoi(cwalk->value);
		}

		cwalk = cwalk->next;
	}
}
コード例 #17
0
ファイル: background.c プロジェクト: Guff/lualock
void background_set_color(const gchar *hex) {
    cairo_t *cr = cairo_create(lualock.bg_surface);
    
    gdouble r, g, b, a;
    parse_color(hex, &r, &g, &b, &a);
    cairo_set_source_rgba(cr, r, g, b, a);
    cairo_paint(cr);
    cairo_destroy(cr);
    
    update_screen();
}
コード例 #18
0
ファイル: setterm.c プロジェクト: Webster-WXH/util-linux
static int parse_febg_color(const char *arg)
{
	int color = parse_color(arg);

	if (color < 0)
		color = strtos32_or_err(arg, _("argument error"));

	if (!is_valid_color(color) || color == GREY)
		errx(EXIT_FAILURE, "%s: %s", _("argument error"), arg);
	return color;
}
コード例 #19
0
ファイル: terminal_ncurses.c プロジェクト: karlstav/cava
static NCURSES_COLOR_T change_color_definition(NCURSES_COLOR_T color_number,
char* const color_string, NCURSES_COLOR_T predef_color) {
	struct colors color = { 0 };
	parse_color(color_string, &color);
	NCURSES_COLOR_T return_color_number = predef_color;
	if (color.color == COLOR_REDEFINITION) {
		//remember_color_definition(color_number);
		init_color(color_number, COLORS_STRUCT_NORMALIZE(color));
		return_color_number = color_number;
	}
	return return_color_number;
}
コード例 #20
0
static elemstyle_line_t *parse_line(xmlNode *a_node) {
  elemstyle_line_t *line = g_new0(elemstyle_line_t, 1);

  /* these have to be present */
  g_assert(parse_color(a_node, "colour", &line->color));
  g_assert(parse_gint(a_node, "width", &line->width));

  line->real.valid =
    parse_gint(a_node, "realwidth", &line->real.width);

  line->bg.valid =
    parse_gint(a_node, "width_bg", &line->bg.width) &&
    parse_color(a_node, "colour_bg", &line->bg.color);

  line->dashed = parse_gboolean(a_node, "dashed");
  if (!parse_gint(a_node, "dash_length", &line->dash_length)) {
    line->dash_length = DEFAULT_DASH_LENGTH;
  }

  return line;
}
コード例 #21
0
ファイル: xymongrep.c プロジェクト: osvaldsson/xymon
static int downok(char *hostname, int nodownhosts)
{
	char *mark, *colorstr;
	int color;

	if (!nodownhosts) return 1;

	/* Check if the host is down (i.e. "conn" test is non-green) */
	if (!connstatus) return 1;
	mark = (char *)malloc(strlen(hostname) + strlen(conncolumn) + 4);
	sprintf(mark, "\n%s|%s|", hostname, conncolumn);
	colorstr = strstr(connstatus, mark);
	if (colorstr) {
		colorstr += strlen(mark);	/* Skip to the color data */
	}
	else if (strncmp(connstatus, mark+1, strlen(mark+1)) == 0) {
		colorstr = connstatus + strlen(mark+1);	/* First entry we get */
	}
	xfree(mark);
	color = (colorstr ? parse_color(colorstr) : COL_GREEN);
	if ((color == COL_RED) || (color == COL_BLUE)) return 0;

	/* Check if the test is currently disabled */
	if (!teststatus) return 1;
	mark = (char *)malloc(strlen(hostname) + strlen(testcolumn) + 4);
	sprintf(mark, "\n%s|%s|", hostname, testcolumn);
	colorstr = strstr(teststatus, mark);
	if (colorstr) {
		colorstr += strlen(mark);	/* Skip to the color data */
	}
	else if (strncmp(teststatus, mark+1, strlen(mark+1)) == 0) {
		colorstr = teststatus + strlen(mark+1);	/* First entry we get */
	}
	xfree(mark);
	color = (colorstr ? parse_color(colorstr) : COL_GREEN);
	if ((color == COL_RED) || (color == COL_BLUE)) return 0;

	return 1;
}
コード例 #22
0
RImage *bilinear (int argc, char **argv, int width, int height,
                  int relief) {

    int color[4][3];
    RImage *image;
    unsigned char *cptr;
    int i, j, k;

    argc--;
    argv++;

    if (!start_image ("bilinear", argc, 4, 5, width, height, &image)) {
        return (RImage *)0;
    }

    for (i=0; i<4; i++) {
        if (!parse_color (argv[i], color[i])) {
            error ("can't parse color: \"%s\"\n", argv[i]);
            return 0;
        }
    }

    cptr = image->data;
    for (i=0; i<height; i++) {
        int b = 0xff * i / height;
        int t = 0xff - b;

        for (j=0; j<width; j++) {
            int r = 0xff * j / width;
            int l = 0xff - r;
            int f[4];

            f[0] = (l*t) >> 8;
            f[1] = (r*t) >> 8;
            f[2] = (l*b) >> 8;
            f[3] = (r*b) >> 8;

            for (k=0; k<3; k++) {
                *cptr++ =
                    ( f[0] * color[0][k] +
                      f[1] * color[1][k] +
                      f[2] * color[2][k] +
                      f[3] * color[3][k] ) >> 8;
            }

            if (RRGBAFormat==image->format)
                cptr++;
        }
    }
    return image;
}
コード例 #23
0
ファイル: b_lockglue.c プロジェクト: BuBuaBu/bang-screensaver
static void
init_colors(ModeInfo *mi)
{
	if (strncasecmp(bubble_color_str, "auto", strlen("auto")) == 0) {
		glb_config.bubble_colour[0] = ((float) (NRAND(100)) / 100.0);
		glb_config.bubble_colour[1] = ((float) (NRAND(100)) / 100.0);
		/* I keep more blue */
		glb_config.bubble_colour[2] = ((float) (NRAND(50)) / 100.0) + 0.50;
	} else if (strncasecmp(bubble_color_str, "random", strlen("random")) == 0) {
	    glb_config.bubble_colour[0] = -1.0;
	} else {
		parse_color(mi, "bubble", bubble_color_str, glb_config.bubble_colour);
	}
}
コード例 #24
0
ファイル: color.c プロジェクト: KingaChou/goaccess
/* Iterate over all color definitions in the config file.
 *
 * On error, it aborts.
 * On success, the color properties are parsed and stored */
static void
parse_colors (const char *colors[], size_t n)
{
  char *line;
  size_t i;

  for (i = 0; i < n; ++i) {
    line = strdup (colors[i]);
    /* did not find a valid format */
    if (strchr (line, ':') == NULL) {
      free (line);
      continue;
    }
    parse_color (line);
  }
}
コード例 #25
0
ファイル: config.cpp プロジェクト: k-stachowiak/kulki
std::vector<dick::Color> KulkiConfig::m_load_color_range(const std::string& symbol) const
{
    MoonValue *value = m_load_value(symbol.c_str());
    if (value->type != MN_ARRAY) {
        std::cerr << "Type error while reading config value " << symbol << std::endl;
        exit(1);
    }
    MoonValue *item = value->data.compound;
    std::vector<dick::Color> result;
    while (item) {
        result.push_back(parse_color(item, symbol));
        item = item->next;
    }
    mn_dispose(value);
    return result;
}
コード例 #26
0
void ColorArray::readXml(const ci::XmlTree& xml)
{
	mColor.clear();

	for (auto it=xml.begin(), end=xml.end(); it != end; ++it) {
		if (it->getTag() == "color") {
			ci::ColorA				clr;
			const std::string		rgb = it->getAttributeValue<std::string>("rgb", "");
			if (parse_color(rgb, clr)) {
				ColorParam			cp(clr);
				cp.readXml(*it);
				mColor.push_back(cp);
			}
		}
	}
}
コード例 #27
0
ファイル: criticalview.c プロジェクト: Kotty666/xymon
static void parse_query(void)
{
	cgidata_t *cgidata = cgi_request();
	cgidata_t *cwalk;
	int havemaxprio=0, havemaxage=0, havemincolor=0, havewantacked=0, haveevcount=0;

	cwalk = cgidata;
	while (cwalk) {
		if (strcasecmp(cwalk->name, "MAXPRIO") == 0) {
			selectenv(cwalk->name, cwalk->value);
			maxprio = atoi(cwalk->value);
			havemaxprio = 1;
		}
		else if (strcasecmp(cwalk->name, "MAXAGE") == 0) {
			selectenv(cwalk->name, cwalk->value);
			maxage = 60*atoi(cwalk->value);
			havemaxage = 1;
		}
		else if (strcasecmp(cwalk->name, "MINCOLOR") == 0) {
			selectenv(cwalk->name, cwalk->value);
			mincolor = parse_color(cwalk->value);
			havemincolor = 1;
		}
		else if (strcasecmp(cwalk->name, "OLDLIMIT") == 0) {
			selectenv(cwalk->name, cwalk->value);
			oldlimit = 60*atoi(cwalk->value);
		}
		else if (strcasecmp(cwalk->name, "WANTACKED") == 0) {
			selectenv(cwalk->name, cwalk->value);
			wantacked = (strcasecmp(cwalk->value, "yes") == 0);
			havewantacked = 1;
		}
		else if (strcasecmp(cwalk->name, "EVCOUNT") == 0) {
			selectenv(cwalk->name, cwalk->value);
			evcount = atoi(cwalk->value);
			haveevcount = 1;
		}

		cwalk = cwalk->next;
	}

	if (!havemaxprio)   selectenv("MAXPRIO", "3");
	if (!havemaxage)    selectenv("MAXAGE", "525600");
	if (!havemincolor)  selectenv("MINCOLOR", "yellow");
	if (!havewantacked) selectenv("WANTACKED", "no");
	if (!haveevcount)   selectenv("EVCOUNT", "0");
}
コード例 #28
0
ファイル: loaddata.c プロジェクト: tjyang/abmon
dispsummary_t *init_displaysummary(char *fn, logdata_t *log)
{
	char l[MAX_LINE_LEN];
	dispsummary_t *newsum = NULL;
	time_t now = getcurrenttime(NULL);

	dbgprintf("init_displaysummary(%s)\n", textornull(fn));

	if (log->validtime < now) return NULL;
	strcpy(l, log->msg);

	if (strlen(l)) {
		char *p;
		char *color = (char *) malloc(strlen(l));

		newsum = (dispsummary_t *) calloc(1, sizeof(dispsummary_t));
		newsum->url = (char *) malloc(strlen(l));

		if (sscanf(l, "%s %s", color, newsum->url) == 2) {
			char *rowcol;
			newsum->color = parse_color(color);

			rowcol = (char *) malloc(strlen(fn) + 1);
			strcpy(rowcol, fn+8);
			p = strrchr(rowcol, '.');
			if (p) *p = ' ';

			newsum->column = (char *) malloc(strlen(rowcol)+1);
			newsum->row = (char *) malloc(strlen(rowcol)+1);
			sscanf(rowcol, "%s %s", newsum->row, newsum->column);
			newsum->next = NULL;

			xfree(rowcol);
		}
		else {
			xfree(newsum->url);
			xfree(newsum);
			newsum = NULL;
		}

		xfree(color);
	}

	return newsum;
}
コード例 #29
0
ファイル: combostatus.c プロジェクト: Kotty666/xymon
static int getxymondvalue(char *hostname, char *testname, char **errptr)
{
	static char *board = NULL;
	int xymondresult;
	int result = COL_CLEAR;
	char *pattern, *found, *colstr;

	if (board == NULL) {
		sendreturn_t *sres = newsendreturnbuf(1, NULL);

		xymondresult = sendmessage("xymondboard fields=hostname,testname,color", NULL, XYMON_TIMEOUT, sres);
		board = getsendreturnstr(sres, 1);

		if ((xymondresult != XYMONSEND_OK) || (board == NULL)) {
			board = "";
			*errptr += sprintf(*errptr, "Could not access xymond board, error %d\n", xymondresult);
			return COL_CLEAR;
		}

		freesendreturnbuf(sres);
	}

	pattern = (char *)malloc(1 + strlen(hostname) + 1 + strlen(testname) + 1 + 1);
	sprintf(pattern, "\n%s|%s|", hostname, testname);

	if (strncmp(board, pattern+1, strlen(pattern+1)) == 0) {
		/* The first entry in the board doesn't have the "\n" */
		found = board;
	}
	else {
		found = strstr(board, pattern);
	}

	if (found) {
		/* hostname|testname|color */
		colstr = found + strlen(pattern);
		result = parse_color(colstr);
	}

	xfree(pattern);
	return result;
}
コード例 #30
0
void CL_CSSParserBorderLTRBColor::parse(CL_CSSBoxProperties &properties, const CL_String &name, const std::vector<CL_CSSToken> &tokens, std::map<CL_String, CL_CSSBoxProperty *> *out_change_set)
{
	CL_CSSBoxBorderColor *border_color = 0;
	if (equals(name, "border-top-color"))
		border_color = &properties.border_color_top;
	else if (equals(name, "border-right-color"))
		border_color = &properties.border_color_right;
	else if (equals(name, "border-bottom-color"))
		border_color = &properties.border_color_bottom;
	else if (equals(name, "border-left-color"))
		border_color = &properties.border_color_left;

	if (border_color)
	{
		size_t pos = 0;
		CL_Colorf color;
		if (parse_color(tokens, pos, color) && pos == tokens.size())
		{
			border_color->type = CL_CSSBoxBorderColor::type_color;
			border_color->color = color;
		}
		else
		{
			CL_CSSToken token = next_token(pos, tokens);
			if (token.type == CL_CSSToken::type_ident && pos == tokens.size())
			{
				if (equals(token.value, "inherit"))
				{
					border_color->type = CL_CSSBoxBorderColor::type_inherit;
				}
			}
		}
	}

	if (out_change_set)
	{
		(*out_change_set)[name] = border_color;
	}
}