2000-10-28 16:14:19 -04:00
|
|
|
#ifndef __FORMATS_H
|
|
|
|
#define __FORMATS_H
|
|
|
|
|
|
|
|
#include "themes.h"
|
2000-11-17 11:27:14 -05:00
|
|
|
#include "fe-windows.h"
|
2000-10-28 16:14:19 -04:00
|
|
|
|
2001-06-26 17:28:00 -04:00
|
|
|
#define GUI_PRINT_FLAG_BOLD 0x01
|
|
|
|
#define GUI_PRINT_FLAG_REVERSE 0x02
|
|
|
|
#define GUI_PRINT_FLAG_UNDERLINE 0x04
|
|
|
|
#define GUI_PRINT_FLAG_BLINK 0x08
|
|
|
|
#define GUI_PRINT_FLAG_MIRC_COLOR 0x10
|
|
|
|
#define GUI_PRINT_FLAG_INDENT 0x20
|
|
|
|
#define GUI_PRINT_FLAG_NEWLINE 0x40
|
2000-11-12 15:20:05 -05:00
|
|
|
|
|
|
|
#define MAX_FORMAT_PARAMS 10
|
|
|
|
#define DEFAULT_FORMAT_ARGLIST_SIZE 200
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
enum {
|
|
|
|
FORMAT_STRING,
|
|
|
|
FORMAT_INT,
|
|
|
|
FORMAT_LONG,
|
|
|
|
FORMAT_FLOAT
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _FORMAT_REC {
|
|
|
|
char *tag;
|
|
|
|
char *def;
|
|
|
|
|
|
|
|
int params;
|
2000-11-12 15:20:05 -05:00
|
|
|
int paramtypes[MAX_FORMAT_PARAMS];
|
2000-10-28 16:14:19 -04:00
|
|
|
};
|
|
|
|
|
2001-06-26 17:28:00 -04:00
|
|
|
#define PRINT_FLAG_SET_LINE_START 0x0001
|
|
|
|
#define PRINT_FLAG_SET_LINE_START_IRSSI 0x0002
|
|
|
|
#define PRINT_FLAG_UNSET_LINE_START 0x0003
|
|
|
|
|
|
|
|
#define PRINT_FLAG_SET_TIMESTAMP 0x0004
|
|
|
|
#define PRINT_FLAG_UNSET_TIMESTAMP 0x0008
|
|
|
|
|
|
|
|
#define PRINT_FLAG_SET_SERVERTAG 0x0010
|
|
|
|
#define PRINT_FLAG_UNSET_SERVERTAG 0x0020
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
typedef struct {
|
|
|
|
WINDOW_REC *window;
|
2001-03-03 13:30:21 -05:00
|
|
|
SERVER_REC *server;
|
2000-10-28 16:14:19 -04:00
|
|
|
const char *target;
|
|
|
|
int level;
|
2001-01-09 16:06:45 -05:00
|
|
|
|
|
|
|
int hilight_priority;
|
2001-03-16 20:52:43 -05:00
|
|
|
char *hilight_color;
|
2001-06-26 17:28:00 -04:00
|
|
|
int flags;
|
2000-10-28 16:14:19 -04:00
|
|
|
} TEXT_DEST_REC;
|
|
|
|
|
2000-11-20 22:00:05 -05:00
|
|
|
int format_find_tag(const char *module, const char *tag);
|
|
|
|
|
2001-02-20 23:21:15 -05:00
|
|
|
/* Return length of text part in string (ie. without % codes) */
|
|
|
|
int format_get_length(const char *str);
|
2001-03-12 05:34:04 -05:00
|
|
|
/* Return how many characters in `str' must be skipped before `len'
|
|
|
|
characters of text is skipped. Like strip_real_length(), except this
|
|
|
|
handles %codes. */
|
|
|
|
int format_real_length(const char *str, int len);
|
2001-02-20 23:21:15 -05:00
|
|
|
|
2001-06-26 17:28:00 -04:00
|
|
|
char *format_string_expand(const char *text, int *flags);
|
2001-03-16 20:52:43 -05:00
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
char *format_get_text(const char *module, WINDOW_REC *window,
|
|
|
|
void *server, const char *target,
|
|
|
|
int formatnum, ...);
|
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
/* good size for buffer is DEFAULT_FORMAT_ARGLIST_SIZE */
|
|
|
|
void format_read_arglist(va_list va, FORMAT_REC *format,
|
|
|
|
char **arglist, int arglist_size,
|
|
|
|
char *buffer, int buffer_size);
|
2000-10-28 16:14:19 -04:00
|
|
|
char *format_get_text_theme(THEME_REC *theme, const char *module,
|
|
|
|
TEXT_DEST_REC *dest, int formatnum, ...);
|
|
|
|
char *format_get_text_theme_args(THEME_REC *theme, const char *module,
|
|
|
|
TEXT_DEST_REC *dest, int formatnum,
|
|
|
|
va_list va);
|
2000-11-12 15:20:05 -05:00
|
|
|
char *format_get_text_theme_charargs(THEME_REC *theme, const char *module,
|
|
|
|
TEXT_DEST_REC *dest, int formatnum,
|
|
|
|
char **args);
|
2000-10-28 16:14:19 -04:00
|
|
|
|
|
|
|
/* add `linestart' to start of each line in `text'. `text' may contain
|
|
|
|
multiple lines separated with \n. */
|
|
|
|
char *format_add_linestart(const char *text, const char *linestart);
|
|
|
|
|
|
|
|
/* return the "-!- " text at the start of the line */
|
2000-11-20 22:00:05 -05:00
|
|
|
char *format_get_level_tag(THEME_REC *theme, TEXT_DEST_REC *dest);
|
|
|
|
|
|
|
|
/* return timestamp + server tag */
|
2000-12-02 17:08:07 -05:00
|
|
|
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t);
|
2000-10-28 16:14:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
/* "private" functions for printtext */
|
|
|
|
void format_create_dest(TEXT_DEST_REC *dest,
|
|
|
|
void *server, const char *target,
|
|
|
|
int level, WINDOW_REC *window);
|
|
|
|
|
2000-11-12 15:20:05 -05:00
|
|
|
void format_newline(WINDOW_REC *window);
|
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
/* Return how many characters in `str' must be skipped before `len'
|
|
|
|
characters of text is skipped. */
|
|
|
|
int strip_real_length(const char *str, int len,
|
|
|
|
int *last_color_pos, int *last_color_len);
|
|
|
|
|
|
|
|
/* strip all color (etc.) codes from `input'.
|
|
|
|
Returns newly allocated string. */
|
2000-11-12 15:20:05 -05:00
|
|
|
char *strip_codes(const char *input);
|
|
|
|
|
|
|
|
/* send a fully parsed text string for GUI to print */
|
|
|
|
void format_send_to_gui(TEXT_DEST_REC *dest, const char *text);
|
|
|
|
|
2001-03-16 20:52:43 -05:00
|
|
|
#define FORMAT_COLOR_NOCHANGE ('0'-1) /* don't change this, at least hilighting depends this value */
|
2000-10-28 16:14:19 -04:00
|
|
|
|
|
|
|
#define FORMAT_STYLE_SPECIAL 0x60
|
2001-03-16 21:32:32 -05:00
|
|
|
#define FORMAT_STYLE_BLINK (0x01 + FORMAT_STYLE_SPECIAL)
|
|
|
|
#define FORMAT_STYLE_UNDERLINE (0x02 + FORMAT_STYLE_SPECIAL)
|
|
|
|
#define FORMAT_STYLE_BOLD (0x03 + FORMAT_STYLE_SPECIAL)
|
|
|
|
#define FORMAT_STYLE_REVERSE (0x04 + FORMAT_STYLE_SPECIAL)
|
|
|
|
#define FORMAT_STYLE_INDENT (0x05 + FORMAT_STYLE_SPECIAL)
|
|
|
|
#define FORMAT_STYLE_DEFAULTS (0x06 + FORMAT_STYLE_SPECIAL)
|
2001-06-26 17:28:00 -04:00
|
|
|
int format_expand_styles(GString *out, const char **format, int *flags);
|
2000-10-28 16:14:19 -04:00
|
|
|
|
2000-11-12 20:52:41 -05:00
|
|
|
void formats_init(void);
|
|
|
|
void formats_deinit(void);
|
|
|
|
|
2000-10-28 16:14:19 -04:00
|
|
|
#endif
|