Merged Irssi 0.8.2 from irssi.org cvs.
[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         char *path;
15         char *name;
16         time_t last_modify;
17
18         int default_color; /* default color to use with text with default
19                               background. default is -1 which means the
20                               default color set by terminal */
21         unsigned int info_eol:1; /* show the timestamp/servertag at the
22                                     end of the line, not at beginning */
23
24         GHashTable *modules;
25
26         int replace_keys[256]; /* index to replace_values for each char */
27         GSList *replace_values;
28         GHashTable *abstracts;
29
30         void *gui_data;
31 } THEME_REC;
32
33 typedef struct _FORMAT_REC FORMAT_REC;
34
35 extern GSList *themes;
36 extern THEME_REC *current_theme;
37 extern GHashTable *default_formats;
38
39 THEME_REC *theme_create(const char *path, const char *name);
40 void theme_destroy(THEME_REC *rec);
41
42 THEME_REC *theme_load(const char *name);
43
44 #define theme_register(formats) theme_register_module(MODULE_NAME, formats)
45 #define theme_unregister() theme_unregister_module(MODULE_NAME)
46 void theme_register_module(const char *module, FORMAT_REC *formats);
47 void theme_unregister_module(const char *module);
48
49 #define EXPAND_FLAG_IGNORE_REPLACES     0x01 /* don't use the character replaces when expanding */
50 #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}) */
51 #define EXPAND_FLAG_RECURSIVE_MASK      0x0f
52 /* private */
53 #define EXPAND_FLAG_ROOT                0x10
54 #define EXPAND_FLAG_LASTCOLOR_ARG       0x20
55
56 char *theme_format_expand(THEME_REC *theme, const char *format);
57 char *theme_format_expand_data(THEME_REC *theme, const char **format,
58                                char default_fg, char default_bg,
59                                char *save_last_fg, char *save_last_bg,
60                                int flags);
61
62 void themes_init(void);
63 void themes_deinit(void);
64
65 #endif