mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
add a meta table to all lines
This commit is contained in:
parent
554a8556d2
commit
7d13cfba07
@ -34,6 +34,7 @@
|
|||||||
#include <irssi/src/core/recode.h>
|
#include <irssi/src/core/recode.h>
|
||||||
#include <irssi/src/core/utf8.h>
|
#include <irssi/src/core/utf8.h>
|
||||||
#include <irssi/src/core/misc.h>
|
#include <irssi/src/core/misc.h>
|
||||||
|
#include <irssi/src/core/refstrings.h>
|
||||||
|
|
||||||
static const char *format_backs = "04261537";
|
static const char *format_backs = "04261537";
|
||||||
static const char *format_fores = "kbgcrmyw";
|
static const char *format_fores = "kbgcrmyw";
|
||||||
@ -46,6 +47,8 @@ static int hide_text_style, hide_server_tags, hide_colors;
|
|||||||
static int timestamp_level;
|
static int timestamp_level;
|
||||||
static int timestamp_timeout;
|
static int timestamp_timeout;
|
||||||
|
|
||||||
|
static GHashTable *global_meta;
|
||||||
|
|
||||||
int format_find_tag(const char *module, const char *tag)
|
int format_find_tag(const char *module, const char *tag)
|
||||||
{
|
{
|
||||||
FORMAT_REC *formats;
|
FORMAT_REC *formats;
|
||||||
@ -453,6 +456,27 @@ void format_read_arglist(va_list va, FORMAT_REC *format,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void format_dest_meta_stash(TEXT_DEST_REC *dest, const char *meta_key, const char *meta_value)
|
||||||
|
{
|
||||||
|
g_hash_table_replace(dest->meta, i_refstr_intern(meta_key), g_strdup(meta_value));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *format_dest_meta_stash_find(TEXT_DEST_REC *dest, const char *meta_key)
|
||||||
|
{
|
||||||
|
return g_hash_table_lookup(dest->meta, meta_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void format_dest_meta_clear_all(TEXT_DEST_REC *dest)
|
||||||
|
{
|
||||||
|
g_hash_table_remove_all(dest->meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clear_global_meta(WINDOW_REC *window, TEXT_DEST_REC *dest)
|
||||||
|
{
|
||||||
|
if (dest != NULL && dest->meta == global_meta)
|
||||||
|
g_hash_table_remove_all(global_meta);
|
||||||
|
}
|
||||||
|
|
||||||
void format_create_dest_tag_meta(TEXT_DEST_REC *dest, void *server, const char *server_tag,
|
void format_create_dest_tag_meta(TEXT_DEST_REC *dest, void *server, const char *server_tag,
|
||||||
const char *target, int level, WINDOW_REC *window,
|
const char *target, int level, WINDOW_REC *window,
|
||||||
GHashTable *meta)
|
GHashTable *meta)
|
||||||
@ -465,7 +489,7 @@ void format_create_dest_tag_meta(TEXT_DEST_REC *dest, void *server, const char *
|
|||||||
dest->level = level;
|
dest->level = level;
|
||||||
dest->window = window != NULL ? window :
|
dest->window = window != NULL ? window :
|
||||||
window_find_closest(server, target, level);
|
window_find_closest(server, target, level);
|
||||||
dest->meta = meta;
|
dest->meta = meta != NULL ? meta : global_meta;
|
||||||
}
|
}
|
||||||
|
|
||||||
void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, const char *server_tag,
|
void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, const char *server_tag,
|
||||||
@ -1705,12 +1729,18 @@ static void read_settings(void)
|
|||||||
void formats_init(void)
|
void formats_init(void)
|
||||||
{
|
{
|
||||||
signal_gui_print_text = signal_get_uniq_id("gui print text");
|
signal_gui_print_text = signal_get_uniq_id("gui print text");
|
||||||
|
global_meta =
|
||||||
|
g_hash_table_new_full(g_str_hash, (GEqualFunc) g_str_equal,
|
||||||
|
(GDestroyNotify) i_refstr_release, (GDestroyNotify) g_free);
|
||||||
|
|
||||||
read_settings();
|
read_settings();
|
||||||
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
signal_add_last("gui print text finished", (SIGNAL_FUNC) clear_global_meta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void formats_deinit(void)
|
void formats_deinit(void)
|
||||||
{
|
{
|
||||||
|
g_hash_table_destroy(global_meta);
|
||||||
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
||||||
|
signal_remove("gui print text finished", (SIGNAL_FUNC) clear_global_meta);
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ typedef struct _TEXT_DEST_REC {
|
|||||||
|
|
||||||
int hilight_priority;
|
int hilight_priority;
|
||||||
char *hilight_color;
|
char *hilight_color;
|
||||||
int flags;
|
int flags; /* PRINT_FLAG */
|
||||||
GHashTable *meta;
|
GHashTable *meta;
|
||||||
} TEXT_DEST_REC;
|
} TEXT_DEST_REC;
|
||||||
|
|
||||||
@ -116,12 +116,16 @@ char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest, time_t t);
|
|||||||
void format_create_dest(TEXT_DEST_REC *dest,
|
void format_create_dest(TEXT_DEST_REC *dest,
|
||||||
void *server, const char *target,
|
void *server, const char *target,
|
||||||
int level, WINDOW_REC *window);
|
int level, WINDOW_REC *window);
|
||||||
void format_create_dest_tag(TEXT_DEST_REC *dest, void *server,
|
void format_create_dest_tag(TEXT_DEST_REC *dest, void *server, const char *server_tag,
|
||||||
const char *server_tag, const char *target,
|
const char *target, int level, WINDOW_REC *window);
|
||||||
int level, WINDOW_REC *window);
|
|
||||||
|
|
||||||
void format_newline(TEXT_DEST_REC *dest);
|
void format_newline(TEXT_DEST_REC *dest);
|
||||||
|
|
||||||
|
/* manipulate the meta table of a dest */
|
||||||
|
void format_dest_meta_stash(TEXT_DEST_REC *dest, const char *meta_key, const char *meta_value);
|
||||||
|
const char *format_dest_meta_stash_find(TEXT_DEST_REC *dest, const char *meta_key);
|
||||||
|
void format_dest_meta_clear_all(TEXT_DEST_REC *dest);
|
||||||
|
|
||||||
/* Return how many characters in `str' must be skipped before `len'
|
/* Return how many characters in `str' must be skipped before `len'
|
||||||
characters of text is skipped. */
|
characters of text is skipped. */
|
||||||
int strip_real_length(const char *str, int len,
|
int strip_real_length(const char *str, int len,
|
||||||
|
@ -156,3 +156,22 @@ print(dest, str)
|
|||||||
char *str
|
char *str
|
||||||
CODE:
|
CODE:
|
||||||
printtext_dest(dest, "%s", str);
|
printtext_dest(dest, "%s", str);
|
||||||
|
|
||||||
|
#*******************************
|
||||||
|
MODULE = Irssi::UI::Formats PACKAGE = Irssi::UI::TextDest PREFIX = format_dest_
|
||||||
|
#*******************************
|
||||||
|
|
||||||
|
void
|
||||||
|
format_dest_meta_stash(dest, meta_key, meta_value)
|
||||||
|
Irssi::UI::TextDest dest
|
||||||
|
char *meta_key
|
||||||
|
char *meta_value
|
||||||
|
|
||||||
|
char *
|
||||||
|
format_dest_meta_stash_find(dest, meta_key)
|
||||||
|
Irssi::UI::TextDest dest
|
||||||
|
char *meta_key
|
||||||
|
CODE:
|
||||||
|
RETVAL = (char *) format_dest_meta_stash_find(dest, meta_key);
|
||||||
|
OUTPUT:
|
||||||
|
RETVAL
|
||||||
|
Loading…
Reference in New Issue
Block a user