addition of silc.css
[silc.git] / apps / irssi / src / fe-common / core / formats.h
1 #ifndef __FORMATS_H
2 #define __FORMATS_H
3
4 #include "themes.h"
5 #include "fe-windows.h"
6
7 #define PRINTFLAG_BOLD          0x01
8 #define PRINTFLAG_REVERSE       0x02
9 #define PRINTFLAG_UNDERLINE     0x04
10 #define PRINTFLAG_BLINK         0x08
11 #define PRINTFLAG_MIRC_COLOR    0x10
12 #define PRINTFLAG_INDENT        0x20
13 #define PRINTFLAG_NEWLINE       0x40
14
15 #define MAX_FORMAT_PARAMS 10
16 #define DEFAULT_FORMAT_ARGLIST_SIZE 200
17
18 enum {
19         FORMAT_STRING,
20         FORMAT_INT,
21         FORMAT_LONG,
22         FORMAT_FLOAT
23 };
24
25 struct _FORMAT_REC {
26         char *tag;
27         char *def;
28
29         int params;
30         int paramtypes[MAX_FORMAT_PARAMS];
31 };
32
33 typedef struct {
34         WINDOW_REC *window;
35         SERVER_REC *server;
36         const char *target;
37         int level;
38
39         int hilight_priority;
40         char *hilight_color;
41 } TEXT_DEST_REC;
42
43 int format_find_tag(const char *module, const char *tag);
44
45 /* Return length of text part in string (ie. without % codes) */
46 int format_get_length(const char *str);
47 /* Return how many characters in `str' must be skipped before `len'
48    characters of text is skipped. Like strip_real_length(), except this
49    handles %codes. */
50 int format_real_length(const char *str, int len);
51
52 char *format_string_expand(const char *text);
53
54 char *format_get_text(const char *module, WINDOW_REC *window,
55                       void *server, const char *target,
56                       int formatnum, ...);
57
58 /* good size for buffer is DEFAULT_FORMAT_ARGLIST_SIZE */
59 void format_read_arglist(va_list va, FORMAT_REC *format,
60                          char **arglist, int arglist_size,
61                          char *buffer, int buffer_size);
62 char *format_get_text_theme(THEME_REC *theme, const char *module,
63                             TEXT_DEST_REC *dest, int formatnum, ...);
64 char *format_get_text_theme_args(THEME_REC *theme, const char *module,
65                                  TEXT_DEST_REC *dest, int formatnum,
66                                  va_list va);
67 char *format_get_text_theme_charargs(THEME_REC *theme, const char *module,
68                                      TEXT_DEST_REC *dest, int formatnum,
69                                      char **args);
70
71 /* add `linestart' to start of each line in `text'. `text' may contain
72    multiple lines separated with \n. */
73 char *format_add_linestart(const char *text, const char *linestart);
74
75 /* return the "-!- " text at the start of the line */
76 char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest);
77
78 /* return timestamp + server tag */
79 char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t);
80
81
82 /* "private" functions for printtext */
83 void format_create_dest(TEXT_DEST_REC *dest,
84                         void *server, const char *target,
85                         int level, WINDOW_REC *window);
86
87 void format_newline(WINDOW_REC *window);
88
89 /* Return how many characters in `str' must be skipped before `len'
90    characters of text is skipped. */
91 int strip_real_length(const char *str, int len,
92                       int *last_color_pos, int *last_color_len);
93
94 /* strip all color (etc.) codes from `input'.
95    Returns newly allocated string. */
96 char *strip_codes(const char *input);
97
98 /* send a fully parsed text string for GUI to print */
99 void format_send_to_gui(TEXT_DEST_REC *dest, const char *text);
100
101 #define FORMAT_COLOR_NOCHANGE   ('0'-1) /* don't change this, at least hilighting depends this value */
102
103 #define FORMAT_STYLE_SPECIAL    0x60
104 #define FORMAT_STYLE_BLINK      (0x01 + FORMAT_STYLE_SPECIAL)
105 #define FORMAT_STYLE_UNDERLINE  (0x02 + FORMAT_STYLE_SPECIAL)
106 #define FORMAT_STYLE_BOLD       (0x03 + FORMAT_STYLE_SPECIAL)
107 #define FORMAT_STYLE_REVERSE    (0x04 + FORMAT_STYLE_SPECIAL)
108 #define FORMAT_STYLE_INDENT     (0x05 + FORMAT_STYLE_SPECIAL)
109 #define FORMAT_STYLE_DEFAULTS   (0x06 + FORMAT_STYLE_SPECIAL)
110 int format_expand_styles(GString *out, char format);
111
112 void formats_init(void);
113 void formats_deinit(void);
114
115 #endif