0a809b950acc3c27bfa07c9865b00ad7d48c3690
[silc.git] / apps / irssi / src / fe-common / core / themes.h
1 #ifndef __THEMES_H
2 #define __THEMES_H
3
4 typedef struct {
5         char *name;
6
7         int count;
8         char **formats; /* in same order as in module's default formats */
9         char **expanded_formats; /* this contains the formats after
10                                     expanding {templates} */
11 } MODULE_THEME_REC;
12
13 typedef struct {
14         int refcount;
15
16         char *path;
17         char *name;
18         time_t last_modify;
19
20         int default_color; /* default color to use with text with default
21                               background. default is -1 which means the
22                               default color set by terminal */
23         unsigned int info_eol:1; /* show the timestamp/servertag at the
24                                     end of the line, not at beginning */
25
26         GHashTable *modules;
27
28         int replace_keys[256]; /* index to replace_values for each char */
29         GSList *replace_values;
30         GHashTable *abstracts;
31
32         void *gui_data;
33 } THEME_REC;
34
35 typedef struct _FORMAT_REC FORMAT_REC;
36
37 extern GSList *themes;
38 extern THEME_REC *current_theme;
39 extern GHashTable *default_formats;
40
41 THEME_REC *theme_create(const char *path, const char *name);
42 void theme_destroy(THEME_REC *rec);
43
44 THEME_REC *theme_load(const char *name);
45
46 #define theme_register(formats) theme_register_module(MODULE_NAME, formats)
47 #define theme_unregister() theme_unregister_module(MODULE_NAME)
48 void theme_register_module(const char *module, FORMAT_REC *formats);
49 void theme_unregister_module(const char *module);
50
51 #define EXPAND_FLAG_IGNORE_REPLACES     0x01 /* don't use the character replaces when expanding */
52 #define EXPAND_FLAG_IGNORE_EMPTY        0x02 /* if abstract's argument is empty, or the argument is a $variable that is empty, don't try to expand it (ie. {xx }, but not {xx}) */
53 #define EXPAND_FLAG_RECURSIVE_MASK      0x0f
54 /* private */
55 #define EXPAND_FLAG_ROOT                0x10
56 #define EXPAND_FLAG_LASTCOLOR_ARG       0x20
57
58 char *theme_format_expand(THEME_REC *theme, const char *format);
59 char *theme_format_expand_data(THEME_REC *theme, const char **format,
60                                char default_fg, char default_bg,
61                                char *save_last_fg, char *save_last_bg,
62                                int flags);
63
64 void themes_init(void);
65 void themes_deinit(void);
66
67 #endif