一个很有名的浏览器

源代码在线查看: style.c

软件大小: 3632 K
上传用户: zp380747972
关键词: 浏览器
下载地址: 免注册下载 普通下载 VIP

相关代码

				/* BFU display helpers. */				/* $Id: style.c,v 1.13.4.1 2005/04/05 21:08:40 jonas Exp $ */								#ifdef HAVE_CONFIG_H				#include "config.h"				#endif								#include "elinks.h"								#include "bfu/style.h"				#include "config/options.h"				#include "terminal/color.h"				#include "terminal/draw.h"				#include "terminal/terminal.h"				#include "util/color.h"				#include "util/hash.h"												struct bfu_color_entry {					/* Pointers to the options tree values. */					color_t *background;					color_t *foreground;									/* The copy of "text" and "background" colors. */					struct color_pair colors;				};								static struct hash *bfu_colors = NULL;								struct color_pair *				get_bfu_color(struct terminal *term, unsigned char *stylename)				{					static enum color_mode last_color_mode;					struct bfu_color_entry *entry;					int stylenamelen;					struct hash_item *item;					enum color_mode color_mode;									if (!term) return NULL;									color_mode = get_opt_int_tree(term->spec, "colors");									if (!bfu_colors) {						/* Initialize the style hash. */						bfu_colors = init_hash(8, &strhash);						if (!bfu_colors) return NULL;										last_color_mode = color_mode;									} else if (color_mode != last_color_mode) {						int i;										/* Change mode by emptying the cache so mono/color colors						 * aren't mixed. */						foreach_hash_item (item, *bfu_colors, i) {							mem_free_if(item->value);							item = item->prev;							del_hash_item(bfu_colors, item->next);						}										last_color_mode = color_mode;					}									stylenamelen = strlen(stylename);					item = get_hash_item(bfu_colors, stylename, stylenamelen);					entry = item ? item->value : NULL;									if (!entry) {						struct option *opt;										/* Construct the color entry. */						opt = get_opt_rec_real(config_options, color_mode								       ? "ui.colors.color" : "ui.colors.mono");						if (!opt) return NULL;										opt = get_opt_rec_real(opt, stylename);						if (!opt) return NULL;										entry = mem_calloc(1, sizeof(*entry));						if (!entry) return NULL;										item = add_hash_item(bfu_colors, stylename, stylenamelen, entry);						if (!item) {							mem_free(entry);							return NULL;						}										entry->foreground = &get_opt_color_tree(opt, "text");						entry->background = &get_opt_color_tree(opt, "background");					}									/* Always update the color pair. */					entry->colors.background = *entry->background;					entry->colors.foreground = *entry->foreground;									return &entry->colors;				}								void				done_bfu_colors(void)				{					struct hash_item *item;					int i;									if (!bfu_colors)						return;									foreach_hash_item (item, *bfu_colors, i) {						mem_free_if(item->value);					}									free_hash(bfu_colors);					bfu_colors = NULL;				};							

相关资源