⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 style.c

📁 一个很有名的浏览器
💻 C
字号:
/* 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;}voiddone_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;};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -