• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parse_color函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parse_color函数的典型用法代码示例。如果您正苦于以下问题:C++ parse_color函数的具体用法?C++ parse_color怎么用?C++ parse_color使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse_color函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: textbox_parse_string

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 );
}
开发者ID:guyhughes,项目名称:rofi,代码行数:32,代码来源:textbox.c


示例2: parse_keyfile_style

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);
	}
}
开发者ID:M1tt,项目名称:geany,代码行数:53,代码来源:highlighting.c


示例3: init

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;
}
开发者ID:tmud,项目名称:tortilla,代码行数:52,代码来源:tray.cpp


示例4: run_command_color

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);
} /* }}} */
开发者ID:matthiasbeyer,项目名称:tasknc,代码行数:51,代码来源:command.c


示例5: main

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);
}
开发者ID:Kotty666,项目名称:xymon,代码行数:48,代码来源:combostatus.c


示例6: parse

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;
	}
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:29,代码来源:css_parser_outline_color.cpp


示例7: color

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));
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:33,代码来源:css_parser_color.cpp


示例8: lualock_lua_style_set

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;
}
开发者ID:Guff,项目名称:lualock,代码行数:29,代码来源:style.c


示例9: m_load_value

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;
}
开发者ID:k-stachowiak,项目名称:kulki,代码行数:7,代码来源:config.cpp


示例10: parse_cpair

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;
}
开发者ID:MaddTheSane,项目名称:MacBoard,代码行数:16,代码来源:usystem.c


示例11: init

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);
}
开发者ID:vbargues,项目名称:RayTracer,代码行数:28,代码来源:parse_object.c


示例12: highlight_get_color

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;
}
开发者ID:fimmtiu,项目名称:fish-shell,代码行数:47,代码来源:highlight.cpp


示例13: Graphics

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);
        }
    }
}
开发者ID:TkkrLab,项目名称:ledart,代码行数:46,代码来源:life.cpp


示例14: background_set_color

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();
}
开发者ID:Guff,项目名称:lualock,代码行数:11,代码来源:background.c


示例15: parse_febg_color

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;
}
开发者ID:Webster-WXH,项目名称:util-linux,代码行数:11,代码来源:setterm.c


示例16: change_color_definition

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;
}
开发者ID:karlstav,项目名称:cava,代码行数:12,代码来源:terminal_ncurses.c


示例17: downok

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;
}
开发者ID:osvaldsson,项目名称:xymon,代码行数:39,代码来源:xymongrep.c


示例18: init_colors

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);
	}
}
开发者ID:BuBuaBu,项目名称:bang-screensaver,代码行数:14,代码来源:b_lockglue.c


示例19: parse_colors

/* 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);
  }
}
开发者ID:KingaChou,项目名称:goaccess,代码行数:20,代码来源:color.c


示例20: readXml

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);
			}
		}
	}
}
开发者ID:hksonngan,项目名称:ds_cinder,代码行数:16,代码来源:arc_color_array.cpp



注:本文中的parse_color函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parse_command函数代码示例发布时间:2022-05-30
下一篇:
C++ parse_cmd函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap