mirror of
https://github.com/irssi/irssi.git
synced 2024-11-03 04:27:19 -05:00
Cleaned up printtext.c, split part of it to formats.c
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@796 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
8653c6ea36
commit
4dcbe05c0f
@ -22,6 +22,7 @@ libfe_common_core_a_SOURCES = \
|
||||
fe-queries.c \
|
||||
fe-server.c \
|
||||
fe-settings.c \
|
||||
formats.c \
|
||||
hilight-text.c \
|
||||
keyboard.c \
|
||||
module-formats.c \
|
||||
@ -39,6 +40,7 @@ noinst_HEADERS = \
|
||||
completion.h \
|
||||
fe-common-core.h \
|
||||
fe-queries.h \
|
||||
formats.h \
|
||||
hilight-text.h \
|
||||
keyboard.h \
|
||||
module-formats.h \
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void signal_channel_created(CHANNEL_REC *channel, gpointer automatic)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "irssi-version.h"
|
||||
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#define PASTE_CHECK_SPEED 200 /* 0.2 sec */
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "servers.h"
|
||||
#include "ignore.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void fe_unignore(IGNORE_REC *rec);
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "formats.h"
|
||||
#include "themes.h"
|
||||
#include "printtext.h"
|
||||
|
||||
/* close autologs after 5 minutes of inactivity */
|
||||
#define AUTOLOG_INACTIVITY_CLOSE (60*5)
|
||||
@ -419,13 +421,10 @@ static void sig_printtext_stripped(WINDOW_REC *window, void *server,
|
||||
}
|
||||
|
||||
static void sig_print_format(THEME_REC *theme, const char *module,
|
||||
TEXT_DEST_REC *dest, gpointer formatnump,
|
||||
TEXT_DEST_REC *dest, void *formatnum,
|
||||
va_list va)
|
||||
{
|
||||
MODULE_THEME_REC *module_theme;
|
||||
FORMAT_REC *formats;
|
||||
int formatnum;
|
||||
char *str, *str2, *stripped, *tmp;
|
||||
char *str, *stripped, *linestart, *tmp;
|
||||
|
||||
if (log_theme == NULL) {
|
||||
/* theme isn't loaded for some reason (/reload destroys it),
|
||||
@ -437,31 +436,20 @@ static void sig_print_format(THEME_REC *theme, const char *module,
|
||||
if (theme == log_theme)
|
||||
return;
|
||||
|
||||
/* log uses a different theme .. very ugly kludge follows.. : */
|
||||
formatnum = GPOINTER_TO_INT(formatnump);
|
||||
module_theme = g_hash_table_lookup(log_theme->modules, module);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
str = format_get_text_theme_args(log_theme, module, dest,
|
||||
GPOINTER_TO_INT(formatnum), va);
|
||||
skip_next_printtext = TRUE;
|
||||
|
||||
str = output_format_text_args(dest, &formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
if (*str != '\0') {
|
||||
/* get_line_start_text() gets the line start with
|
||||
current theme. */
|
||||
THEME_REC *old_theme = current_theme;
|
||||
current_theme = log_theme;
|
||||
tmp = get_line_start_text(dest);
|
||||
current_theme = old_theme;
|
||||
|
||||
/* line start + text */
|
||||
str2 = tmp == NULL ? str :
|
||||
g_strconcat(tmp, str, NULL);
|
||||
if (str2 != str) g_free(str);
|
||||
str = str2;
|
||||
g_free_not_null(tmp);
|
||||
/* add the line start format */
|
||||
linestart = format_get_line_start(log_theme, dest);
|
||||
tmp = str;
|
||||
str = format_add_linestart(tmp, linestart);
|
||||
g_free_not_null(linestart);
|
||||
g_free(tmp);
|
||||
|
||||
/* strip colors from text, log it. */
|
||||
stripped = strip_codes(str);
|
||||
skip_next_printtext = TRUE;
|
||||
log_line(dest->window, dest->server, dest->target,
|
||||
dest->level, stripped);
|
||||
g_free(stripped);
|
||||
@ -558,10 +546,10 @@ static void read_settings(void)
|
||||
|
||||
/* write to log files with different theme? */
|
||||
log_theme_name = settings_get_str("log_theme");
|
||||
if (old_log_theme == NULL && *log_theme_name != '\0') {
|
||||
if (*old_log_theme == '\0' && *log_theme_name != '\0') {
|
||||
/* theme set */
|
||||
signal_add("print format", (SIGNAL_FUNC) sig_print_format);
|
||||
} else if (old_log_theme != NULL && *log_theme_name == '\0') {
|
||||
} else if (*old_log_theme != '\0' && *log_theme_name == '\0') {
|
||||
/* theme unset */
|
||||
signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
|
||||
}
|
||||
@ -581,6 +569,7 @@ void fe_log_init(void)
|
||||
settings_add_str("log", "log_theme", "");
|
||||
|
||||
autolog_level = 0;
|
||||
log_theme_name = "";
|
||||
read_settings();
|
||||
|
||||
command_bind("log", NULL, (SIGNAL_FUNC) cmd_log);
|
||||
@ -605,7 +594,7 @@ void fe_log_init(void)
|
||||
void fe_log_deinit(void)
|
||||
{
|
||||
g_source_remove(autoremove_tag);
|
||||
if (log_theme_name != NULL && *log_theme_name != '\0')
|
||||
if (*log_theme_name != '\0')
|
||||
signal_remove("print format", (SIGNAL_FUNC) sig_print_format);
|
||||
|
||||
command_unbind("log", (SIGNAL_FUNC) cmd_log);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "nicklist.h"
|
||||
#include "hilight-text.h"
|
||||
#include "ignore.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static char *get_nickmode(CHANNEL_REC *channel, const char *nick)
|
||||
{
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "commands.h"
|
||||
#include "levels.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
static void sig_module_error(void *number, const char *module, const char *data)
|
||||
{
|
||||
switch (GPOINTER_TO_INT(number)) {
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static int queryclose_tag, query_auto_close, querycreate_level;
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "servers-reconnect.h"
|
||||
|
||||
#include "module-formats.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void print_servers(void)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "levels.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void set_print(SETTINGS_REC *rec)
|
||||
{
|
||||
|
354
src/fe-common/core/formats.c
Normal file
354
src/fe-common/core/formats.c
Normal file
@ -0,0 +1,354 @@
|
||||
/*
|
||||
formats.c : irssi
|
||||
|
||||
Copyright (C) 1999-2000 Timo Sirainen
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "module-formats.h"
|
||||
#include "signals.h"
|
||||
#include "special-vars.h"
|
||||
|
||||
#include "levels.h"
|
||||
|
||||
#include "windows.h"
|
||||
#include "formats.h"
|
||||
#include "themes.h"
|
||||
|
||||
int format_expand_styles(GString *out, char format, TEXT_DEST_REC *dest)
|
||||
{
|
||||
static const char *backs = "04261537";
|
||||
static const char *fores = "kbgcrmyw";
|
||||
static const char *boldfores = "KBGCRMYW";
|
||||
char *p;
|
||||
|
||||
switch (format) {
|
||||
case 'U':
|
||||
/* Underline on/off */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_STYLE_UNDERLINE);
|
||||
break;
|
||||
case '9':
|
||||
case '_':
|
||||
/* bold on/off */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_STYLE_BOLD);
|
||||
break;
|
||||
case '8':
|
||||
/* reverse */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_STYLE_REVERSE);
|
||||
break;
|
||||
case '%':
|
||||
g_string_append_c(out, '%');
|
||||
break;
|
||||
case ':':
|
||||
/* Newline */
|
||||
g_string_append_c(out, '\n');
|
||||
break;
|
||||
case '|':
|
||||
/* Indent here */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_STYLE_INDENT);
|
||||
break;
|
||||
case 'F':
|
||||
/* flashing - ignore */
|
||||
break;
|
||||
case 'N':
|
||||
/* don't put clear-color tag at the end of the output - ignore */
|
||||
break;
|
||||
case 'n':
|
||||
/* default color */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_STYLE_DEFAULTS);
|
||||
break;
|
||||
default:
|
||||
/* check if it's a background color */
|
||||
p = strchr(backs, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, FORMAT_COLOR_NOCHANGE);
|
||||
g_string_append_c(out, (int) (p-backs)+'0');
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if it's a foreground color */
|
||||
if (format == 'p') format = 'm';
|
||||
p = strchr(fores, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, (int) (p-fores)+'0');
|
||||
g_string_append_c(out, FORMAT_COLOR_NOCHANGE);
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if it's a bold foreground color */
|
||||
if (format == 'P') format = 'M';
|
||||
p = strchr(boldfores, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, 8+(int) (p-boldfores)+'0');
|
||||
g_string_append_c(out, FORMAT_COLOR_NOCHANGE);
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void read_arglist(va_list va, FORMAT_REC *format,
|
||||
char **arglist, int arglist_size,
|
||||
char *buffer, int buffer_size)
|
||||
{
|
||||
int num, len, bufpos;
|
||||
|
||||
bufpos = 0;
|
||||
arglist[format->params] = NULL;
|
||||
for (num = 0; num < format->params && num < arglist_size; num++) {
|
||||
switch (format->paramtypes[num]) {
|
||||
case FORMAT_STRING:
|
||||
arglist[num] = (char *) va_arg(va, char *);
|
||||
if (arglist[num] == NULL) {
|
||||
g_warning("read_arglist() : parameter %d is NULL", num);
|
||||
arglist[num] = "";
|
||||
}
|
||||
break;
|
||||
case FORMAT_INT: {
|
||||
int d = (int) va_arg(va, int);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%d", d);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
case FORMAT_LONG: {
|
||||
long l = (long) va_arg(va, long);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%ld", l);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
case FORMAT_FLOAT: {
|
||||
double f = (double) va_arg(va, double);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%0.2f", f);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void format_create_dest(TEXT_DEST_REC *dest,
|
||||
void *server, const char *target,
|
||||
int level, WINDOW_REC *window)
|
||||
{
|
||||
dest->server = server;
|
||||
dest->target = target;
|
||||
dest->level = level;
|
||||
dest->window = window != NULL ? window :
|
||||
window_find_closest(server, target, level);
|
||||
}
|
||||
|
||||
static char *format_get_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format,
|
||||
const char *text, va_list va)
|
||||
{
|
||||
GString *out;
|
||||
char *arglist[10];
|
||||
char buffer[200]; /* should be enough? (won't overflow even if it isn't) */
|
||||
|
||||
char code, *ret;
|
||||
int need_free;
|
||||
|
||||
/* read all optional arguments to arglist[] list
|
||||
so they can be used in any order.. */
|
||||
read_arglist(va, format,
|
||||
arglist, sizeof(arglist)/sizeof(void*),
|
||||
buffer, sizeof(buffer));
|
||||
|
||||
out = g_string_new(NULL);
|
||||
|
||||
code = 0;
|
||||
while (*text != '\0') {
|
||||
if (code == '%') {
|
||||
/* color code */
|
||||
if (!format_expand_styles(out, *text, dest)) {
|
||||
g_string_append_c(out, '%');
|
||||
g_string_append_c(out, '%');
|
||||
g_string_append_c(out, *text);
|
||||
}
|
||||
code = 0;
|
||||
} else if (code == '$') {
|
||||
/* argument */
|
||||
char *ret;
|
||||
|
||||
ret = parse_special((char **) &text, active_win->active_server,
|
||||
active_win->active, arglist, &need_free, NULL);
|
||||
|
||||
if (ret != NULL) {
|
||||
/* string shouldn't end with \003 or it could
|
||||
mess up the next one or two characters */
|
||||
int diff;
|
||||
int len = strlen(ret);
|
||||
while (len > 0 && ret[len-1] == 3) len--;
|
||||
diff = strlen(ret)-len;
|
||||
|
||||
g_string_append(out, ret);
|
||||
if (diff > 0)
|
||||
g_string_truncate(out, out->len-diff);
|
||||
if (need_free) g_free(ret);
|
||||
}
|
||||
code = 0;
|
||||
} else {
|
||||
if (*text == '%' || *text == '$')
|
||||
code = *text;
|
||||
else
|
||||
g_string_append_c(out, *text);
|
||||
}
|
||||
|
||||
text++;
|
||||
}
|
||||
|
||||
ret = out->str;
|
||||
g_string_free(out, FALSE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *format_get_text_theme(THEME_REC *theme, const char *module,
|
||||
TEXT_DEST_REC *dest, int formatnum, ...)
|
||||
{
|
||||
va_list va;
|
||||
char *str;
|
||||
|
||||
if (theme == NULL) {
|
||||
theme = dest->window->theme == NULL ? current_theme :
|
||||
dest->window->theme;
|
||||
}
|
||||
|
||||
va_start(va, formatnum);
|
||||
str = format_get_text_theme_args(theme, module, dest, formatnum, va);
|
||||
va_end(va);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *format_get_text_theme_args(THEME_REC *theme, const char *module,
|
||||
TEXT_DEST_REC *dest, int formatnum,
|
||||
va_list va)
|
||||
{
|
||||
MODULE_THEME_REC *module_theme;
|
||||
FORMAT_REC *formats;
|
||||
char *str;
|
||||
|
||||
module_theme = g_hash_table_lookup(theme->modules, module);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
|
||||
str = format_get_text_args(dest, &formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
return str;
|
||||
}
|
||||
|
||||
char *format_get_text(const char *module, WINDOW_REC *window,
|
||||
void *server, const char *target,
|
||||
int formatnum, ...)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
THEME_REC *theme;
|
||||
va_list va;
|
||||
char *str;
|
||||
|
||||
format_create_dest(&dest, server, target, 0, window);
|
||||
theme = dest.window->theme == NULL ? current_theme :
|
||||
dest.window->theme;
|
||||
|
||||
va_start(va, formatnum);
|
||||
str = format_get_text_theme_args(theme, module, &dest, formatnum, va);
|
||||
va_end(va);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* 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)
|
||||
{
|
||||
GString *str;
|
||||
char *ret;
|
||||
|
||||
if (linestart == NULL)
|
||||
return g_strdup(text);
|
||||
|
||||
if (strchr(text, '\n') == NULL)
|
||||
return g_strconcat(linestart, text, NULL);
|
||||
|
||||
str = g_string_new(linestart);
|
||||
while (*text != '\0') {
|
||||
g_string_append_c(str, *text);
|
||||
if (*text == '\n')
|
||||
g_string_append(str, linestart);
|
||||
text++;
|
||||
}
|
||||
|
||||
ret = str->str;
|
||||
g_string_free(str, FALSE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define LINE_START_IRSSI_LEVEL \
|
||||
(MSGLEVEL_CLIENTERROR | MSGLEVEL_CLIENTNOTICE)
|
||||
|
||||
#define NOT_LINE_START_LEVEL \
|
||||
(MSGLEVEL_NEVER | MSGLEVEL_LASTLOG | MSGLEVEL_CLIENTCRAP | \
|
||||
MSGLEVEL_MSGS | MSGLEVEL_PUBLIC | MSGLEVEL_DCC | MSGLEVEL_DCCMSGS | \
|
||||
MSGLEVEL_ACTIONS | MSGLEVEL_NOTICES | MSGLEVEL_SNOTES | MSGLEVEL_CTCPS)
|
||||
|
||||
/* return the "-!- " text at the start of the line */
|
||||
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest)
|
||||
{
|
||||
int format;
|
||||
|
||||
if (dest->level & LINE_START_IRSSI_LEVEL)
|
||||
format = IRCTXT_LINE_START_IRSSI;
|
||||
else if ((dest->level & NOT_LINE_START_LEVEL) == 0)
|
||||
format = IRCTXT_LINE_START;
|
||||
else
|
||||
return NULL;
|
||||
|
||||
return format_get_text_theme(theme, MODULE_NAME, dest, format);
|
||||
}
|
62
src/fe-common/core/formats.h
Normal file
62
src/fe-common/core/formats.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef __FORMATS_H
|
||||
#define __FORMATS_H
|
||||
|
||||
#include "themes.h"
|
||||
#include "windows.h"
|
||||
|
||||
enum {
|
||||
FORMAT_STRING,
|
||||
FORMAT_INT,
|
||||
FORMAT_LONG,
|
||||
FORMAT_FLOAT
|
||||
};
|
||||
|
||||
struct _FORMAT_REC {
|
||||
char *tag;
|
||||
char *def;
|
||||
|
||||
int params;
|
||||
int paramtypes[10];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
WINDOW_REC *window;
|
||||
void *server;
|
||||
const char *target;
|
||||
int level;
|
||||
} TEXT_DEST_REC;
|
||||
|
||||
char *format_get_text(const char *module, WINDOW_REC *window,
|
||||
void *server, const char *target,
|
||||
int formatnum, ...);
|
||||
|
||||
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);
|
||||
|
||||
/* 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 */
|
||||
char *format_get_line_start(THEME_REC *theme, TEXT_DEST_REC *dest);
|
||||
|
||||
|
||||
/* "private" functions for printtext */
|
||||
void format_create_dest(TEXT_DEST_REC *dest,
|
||||
void *server, const char *target,
|
||||
int level, WINDOW_REC *window);
|
||||
|
||||
#define FORMAT_COLOR_NOCHANGE ('0'-1)
|
||||
|
||||
#define FORMAT_STYLE_SPECIAL 0x60
|
||||
#define FORMAT_STYLE_UNDERLINE (0x01 + FORMAT_STYLE_SPECIAL)
|
||||
#define FORMAT_STYLE_BOLD (0x02 + FORMAT_STYLE_SPECIAL)
|
||||
#define FORMAT_STYLE_REVERSE (0x03 + FORMAT_STYLE_SPECIAL)
|
||||
#define FORMAT_STYLE_INDENT (0x04 + FORMAT_STYLE_SPECIAL)
|
||||
#define FORMAT_STYLE_DEFAULTS (0x05 + FORMAT_STYLE_SPECIAL)
|
||||
int format_expand_styles(GString *out, char format, TEXT_DEST_REC *dest);
|
||||
|
||||
#endif
|
@ -30,6 +30,7 @@
|
||||
#include "servers.h"
|
||||
|
||||
#include "hilight-text.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#define DEFAULT_HILIGHT_LEVEL \
|
||||
(MSGLEVEL_PUBLIC | MSGLEVEL_MSGS | \
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "keyboard.h"
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
GSList *keyinfos;
|
||||
static GHashTable *keys;
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC fecommon_core_formats[] = {
|
||||
{ MODULE_NAME, "Core", 0 },
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "modules.h"
|
||||
#include "signals.h"
|
||||
#include "commands.h"
|
||||
#include "special-vars.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include "levels.h"
|
||||
@ -32,6 +31,7 @@
|
||||
#include "translation.h"
|
||||
#include "themes.h"
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static int beep_msg_level, beep_when_away;
|
||||
static int timestamps, msgs_timestamps, hide_text_style;
|
||||
@ -43,7 +43,7 @@ static int signal_print_text;
|
||||
static int signal_print_text_finished;
|
||||
static int signal_print_format;
|
||||
|
||||
static void print_string(TEXT_DEST_REC *dest, const char *text);
|
||||
static void print_line(TEXT_DEST_REC *dest, const char *text);
|
||||
|
||||
void printbeep(void)
|
||||
{
|
||||
@ -51,23 +51,47 @@ void printbeep(void)
|
||||
GINT_TO_POINTER(PRINTFLAG_BEEP), "", MSGLEVEL_NEVER);
|
||||
}
|
||||
|
||||
static void skip_mirc_color(char **str)
|
||||
static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
|
||||
{
|
||||
if (!isdigit((int) **str))
|
||||
return;
|
||||
int fg, bg;
|
||||
|
||||
/* foreground */
|
||||
(*str)++;
|
||||
if (isdigit((int) **str)) (*str)++;
|
||||
fg = fg_ret == NULL ? -1 : *fg_ret;
|
||||
bg = bg_ret == NULL ? -1 : *bg_ret;
|
||||
|
||||
if (**str != ',' || !isdigit((int) (*str)[1])) return;
|
||||
if (!isdigit((int) **str) && **str != ',') {
|
||||
fg = -1;
|
||||
bg = -1;
|
||||
} else {
|
||||
/* foreground color */
|
||||
if (**str != ',') {
|
||||
fg = **str-'0';
|
||||
(*str)++;
|
||||
if (isdigit((int) **str)) {
|
||||
fg = fg*10 + (**str-'0');
|
||||
(*str)++;
|
||||
}
|
||||
}
|
||||
if (**str == ',') {
|
||||
/* background color */
|
||||
(*str)++;
|
||||
if (!isdigit((int) **str))
|
||||
bg = -1;
|
||||
else {
|
||||
bg = **str-'0';
|
||||
(*str)++;
|
||||
if (isdigit((int) **str)) {
|
||||
bg = bg*10 + (**str-'0');
|
||||
(*str)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* background */
|
||||
(*str) += 2;
|
||||
if (isdigit((int) **str)) (*str)++;
|
||||
if (fg_ret) *fg_ret = fg;
|
||||
if (bg_ret) *bg_ret = bg;
|
||||
}
|
||||
|
||||
#define is_color_code(c) \
|
||||
#define IS_COLOR_CODE(c) \
|
||||
((c) == 2 || (c) == 3 || (c) == 4 || (c) == 6 || (c) == 7 || \
|
||||
(c) == 15 || (c) == 22 || (c) == 27 || (c) == 31)
|
||||
|
||||
@ -81,25 +105,26 @@ char *strip_codes(const char *input)
|
||||
if (*p == 3) {
|
||||
p++;
|
||||
|
||||
if (*p < 17 && *p > 0) {
|
||||
/* irssi color */
|
||||
if (p[1] < 17 && p[1] > 0) p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* mirc color */
|
||||
skip_mirc_color((char **) &p);
|
||||
get_mirc_color(&p, NULL, NULL);
|
||||
p--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (*p == 4 && p[1] != '\0' && p[2] != '\0') {
|
||||
if (*p == 4 && p[1] != '\0') {
|
||||
if (p[1] >= FORMAT_STYLE_SPECIAL) {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* irssi color */
|
||||
p += 2;
|
||||
continue;
|
||||
if (p[2] != '\0') {
|
||||
p += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_color_code(*p))
|
||||
if (!IS_COLOR_CODE(*p))
|
||||
*out++ = *p;
|
||||
}
|
||||
|
||||
@ -108,20 +133,20 @@ char *strip_codes(const char *input)
|
||||
}
|
||||
|
||||
/* parse ANSI color string */
|
||||
static char *convert_ansi(THEME_REC *theme, char *str,
|
||||
int *fgcolor, int *bgcolor, int *flags)
|
||||
static char *get_ansi_color(THEME_REC *theme, char *str,
|
||||
int *fg_ret, int *bg_ret, int *flags_ret)
|
||||
{
|
||||
static char ansitab[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
char *start;
|
||||
int fg, bg, fl, num;
|
||||
int fg, bg, flags, num;
|
||||
|
||||
if (*str != '[')
|
||||
return str;
|
||||
start = str++;
|
||||
|
||||
fg = *fgcolor < 0 ? theme->default_color : *fgcolor;
|
||||
bg = *bgcolor < 0 ? -1 : *bgcolor;
|
||||
fl = *flags;
|
||||
fg = fg_ret == NULL || *fg_ret < 0 ? theme->default_color : *fg_ret;
|
||||
bg = bg_ret == NULL || *bg_ret < 0 ? -1 : *bg_ret;
|
||||
flags = flags_ret == NULL ? 0 : *flags_ret;
|
||||
|
||||
num = 0;
|
||||
for (;; str++) {
|
||||
@ -140,19 +165,19 @@ static char *convert_ansi(THEME_REC *theme, char *str,
|
||||
/* reset colors back to default */
|
||||
fg = theme->default_color;
|
||||
bg = -1;
|
||||
fl &= ~(PRINTFLAG_BEEP|PRINTFLAG_INDENT);
|
||||
flags &= ~(PRINTFLAG_BEEP|PRINTFLAG_INDENT);
|
||||
break;
|
||||
case 1:
|
||||
/* hilight */
|
||||
fl |= PRINTFLAG_BOLD;
|
||||
flags |= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case 5:
|
||||
/* blink */
|
||||
fl |= PRINTFLAG_BLINK;
|
||||
flags |= PRINTFLAG_BLINK;
|
||||
break;
|
||||
case 7:
|
||||
/* reverse */
|
||||
fl |= PRINTFLAG_REVERSE;
|
||||
flags |= PRINTFLAG_REVERSE;
|
||||
break;
|
||||
default:
|
||||
if (num >= 30 && num <= 37)
|
||||
@ -166,11 +191,10 @@ static char *convert_ansi(THEME_REC *theme, char *str,
|
||||
num = 0;
|
||||
|
||||
if (*str == 'm') {
|
||||
if (!hide_text_style) {
|
||||
*fgcolor = fg;
|
||||
*bgcolor = bg;
|
||||
*flags = fl;
|
||||
}
|
||||
if (fg_ret != NULL) *fg_ret = fg;
|
||||
if (bg_ret != NULL) *bg_ret = bg;
|
||||
if (flags_ret != NULL) *flags_ret = flags;
|
||||
|
||||
str++;
|
||||
break;
|
||||
}
|
||||
@ -179,301 +203,23 @@ static char *convert_ansi(THEME_REC *theme, char *str,
|
||||
return str;
|
||||
}
|
||||
|
||||
static int expand_styles(GString *out, char format, TEXT_DEST_REC *dest)
|
||||
{
|
||||
static const char *backs = "04261537";
|
||||
static const char *fores = "kbgcrmyw";
|
||||
static const char *boldfores = "KBGCRMYW";
|
||||
char *p;
|
||||
|
||||
switch (format) {
|
||||
case 'U':
|
||||
/* Underline on/off */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -1);
|
||||
g_string_append_c(out, 2);
|
||||
break;
|
||||
case '9':
|
||||
case '_':
|
||||
/* bold on/off */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -1);
|
||||
g_string_append_c(out, 1);
|
||||
break;
|
||||
case '8':
|
||||
/* reverse */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -1);
|
||||
g_string_append_c(out, 3);
|
||||
break;
|
||||
case '%':
|
||||
g_string_append_c(out, '%');
|
||||
break;
|
||||
case ':':
|
||||
/* Newline */
|
||||
print_string(dest, out->str);
|
||||
g_string_truncate(out, 0);
|
||||
break;
|
||||
case '|':
|
||||
/* Indent here */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -1);
|
||||
g_string_append_c(out, 4);
|
||||
break;
|
||||
case 'F':
|
||||
/* flashing - ignore */
|
||||
break;
|
||||
case 'N':
|
||||
/* don't put clear-color tag at the end of the output - ignore */
|
||||
break;
|
||||
case 'n':
|
||||
/* default color */
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -1);
|
||||
g_string_append_c(out, -1);
|
||||
break;
|
||||
default:
|
||||
/* check if it's a background color */
|
||||
p = strchr(backs, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, -2);
|
||||
g_string_append_c(out, (int) (p-backs)+1);
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if it's a foreground color */
|
||||
if (format == 'p') format = 'm';
|
||||
p = strchr(fores, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, (int) (p-fores)+1);
|
||||
g_string_append_c(out, -2);
|
||||
break;
|
||||
}
|
||||
|
||||
/* check if it's a bold foreground color */
|
||||
if (format == 'P') format = 'M';
|
||||
p = strchr(boldfores, format);
|
||||
if (p != NULL) {
|
||||
g_string_append_c(out, 4);
|
||||
g_string_append_c(out, 8+(int) (p-boldfores)+1);
|
||||
g_string_append_c(out, -2);
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void read_arglist(va_list va, FORMAT_REC *format,
|
||||
char **arglist, int arglist_size,
|
||||
char *buffer, int buffer_size)
|
||||
{
|
||||
int num, len, bufpos;
|
||||
|
||||
bufpos = 0;
|
||||
arglist[format->params] = NULL;
|
||||
for (num = 0; num < format->params && num < arglist_size; num++) {
|
||||
switch (format->paramtypes[num]) {
|
||||
case FORMAT_STRING:
|
||||
arglist[num] = (char *) va_arg(va, char *);
|
||||
if (arglist[num] == NULL) {
|
||||
g_warning("read_arglist() : parameter %d is NULL", num);
|
||||
arglist[num] = "";
|
||||
}
|
||||
break;
|
||||
case FORMAT_INT: {
|
||||
int d = (int) va_arg(va, int);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%d", d);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
case FORMAT_LONG: {
|
||||
long l = (long) va_arg(va, long);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%ld", l);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
case FORMAT_FLOAT: {
|
||||
double f = (double) va_arg(va, double);
|
||||
|
||||
if (bufpos >= buffer_size) {
|
||||
arglist[num] = "";
|
||||
break;
|
||||
}
|
||||
|
||||
arglist[num] = buffer+bufpos;
|
||||
len = g_snprintf(buffer+bufpos, buffer_size-bufpos,
|
||||
"%0.2f", f);
|
||||
bufpos += len+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void create_dest_rec(TEXT_DEST_REC *dest,
|
||||
void *server, const char *target,
|
||||
int level, WINDOW_REC *window)
|
||||
{
|
||||
dest->server = server;
|
||||
dest->target = target;
|
||||
dest->level = level;
|
||||
dest->window = window != NULL ? window :
|
||||
window_find_closest(server, target, level);
|
||||
}
|
||||
|
||||
char *output_format_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format,
|
||||
const char *text, va_list va)
|
||||
{
|
||||
GString *out;
|
||||
char *arglist[10];
|
||||
char buffer[200]; /* should be enough? (won't overflow even if it isn't) */
|
||||
|
||||
char code, *ret;
|
||||
int need_free;
|
||||
|
||||
/* read all optional arguments to arglist[] list
|
||||
so they can be used in any order.. */
|
||||
read_arglist(va, format,
|
||||
arglist, sizeof(arglist)/sizeof(void*),
|
||||
buffer, sizeof(buffer));
|
||||
|
||||
out = g_string_new(NULL);
|
||||
|
||||
code = 0;
|
||||
while (*text != '\0') {
|
||||
if (code == '%') {
|
||||
/* color code */
|
||||
if (!expand_styles(out, *text, dest)) {
|
||||
g_string_append_c(out, '%');
|
||||
g_string_append_c(out, '%');
|
||||
g_string_append_c(out, *text);
|
||||
}
|
||||
code = 0;
|
||||
} else if (code == '$') {
|
||||
/* argument */
|
||||
char *ret;
|
||||
|
||||
ret = parse_special((char **) &text, active_win->active_server,
|
||||
active_win->active, arglist, &need_free, NULL);
|
||||
|
||||
if (ret != NULL) {
|
||||
/* string shouldn't end with \003 or it could
|
||||
mess up the next one or two characters */
|
||||
int diff;
|
||||
int len = strlen(ret);
|
||||
while (len > 0 && ret[len-1] == 3) len--;
|
||||
diff = strlen(ret)-len;
|
||||
|
||||
g_string_append(out, ret);
|
||||
if (diff > 0)
|
||||
g_string_truncate(out, out->len-diff);
|
||||
if (need_free) g_free(ret);
|
||||
}
|
||||
code = 0;
|
||||
} else {
|
||||
if (*text == '%' || *text == '$')
|
||||
code = *text;
|
||||
else
|
||||
g_string_append_c(out, *text);
|
||||
}
|
||||
|
||||
text++;
|
||||
}
|
||||
|
||||
ret = out->str;
|
||||
g_string_free(out, FALSE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *output_format_get_text(const char *module, WINDOW_REC *window,
|
||||
void *server, const char *target,
|
||||
int formatnum, ...)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
THEME_REC *theme;
|
||||
MODULE_THEME_REC *module_theme;
|
||||
FORMAT_REC *formats;
|
||||
va_list va;
|
||||
char *ret;
|
||||
|
||||
create_dest_rec(&dest, server, target, 0, window);
|
||||
theme = dest.window->theme == NULL ? current_theme :
|
||||
dest.window->theme;
|
||||
|
||||
module_theme = g_hash_table_lookup(theme->modules, module);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
|
||||
va_start(va, formatnum);
|
||||
ret = output_format_text_args(&dest, &formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
va_end(va);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *output_format_text(TEXT_DEST_REC *dest, int formatnum, ...)
|
||||
{
|
||||
THEME_REC *theme;
|
||||
MODULE_THEME_REC *module_theme;
|
||||
va_list va;
|
||||
char *ret;
|
||||
|
||||
theme = dest->window->theme == NULL ? current_theme :
|
||||
dest->window->theme;
|
||||
module_theme = g_hash_table_lookup(theme->modules, MODULE_NAME);
|
||||
|
||||
va_start(va, formatnum);
|
||||
ret = output_format_text_args(dest, &fecommon_core_formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
va_end(va);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void printformat_module_args(const char *module, void *server,
|
||||
const char *target, int level,
|
||||
int formatnum, va_list va)
|
||||
{
|
||||
THEME_REC *theme;
|
||||
MODULE_THEME_REC *module_theme;
|
||||
TEXT_DEST_REC dest;
|
||||
FORMAT_REC *formats;
|
||||
char *str;
|
||||
|
||||
create_dest_rec(&dest, server, target, level, NULL);
|
||||
format_create_dest(&dest, server, target, level, NULL);
|
||||
theme = dest.window->theme == NULL ? current_theme :
|
||||
dest.window->theme;
|
||||
|
||||
signal_emit_id(signal_print_format, 5, theme, module,
|
||||
&dest, GINT_TO_POINTER(formatnum), va);
|
||||
|
||||
module_theme = g_hash_table_lookup(theme->modules, module);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
|
||||
str = output_format_text_args(&dest, &formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
if (*str != '\0') print_string(&dest, str);
|
||||
str = format_get_text_theme_args(theme, module, &dest, formatnum, va);
|
||||
if (*str != '\0') print_line(&dest, str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
@ -490,24 +236,18 @@ void printformat_module_window_args(const char *module, WINDOW_REC *window,
|
||||
int level, int formatnum, va_list va)
|
||||
{
|
||||
THEME_REC *theme;
|
||||
MODULE_THEME_REC *module_theme;
|
||||
TEXT_DEST_REC dest;
|
||||
FORMAT_REC *formats;
|
||||
char *str;
|
||||
|
||||
create_dest_rec(&dest, NULL, NULL, level, window);
|
||||
format_create_dest(&dest, NULL, NULL, level, window);
|
||||
theme = window->theme == NULL ? current_theme :
|
||||
window->theme;
|
||||
|
||||
signal_emit_id(signal_print_format, 5, theme, module,
|
||||
&dest, GINT_TO_POINTER(formatnum), va);
|
||||
|
||||
module_theme = g_hash_table_lookup(theme->modules, module);
|
||||
formats = g_hash_table_lookup(default_formats, module);
|
||||
|
||||
str = output_format_text_args(&dest, &formats[formatnum],
|
||||
module_theme->expanded_formats[formatnum], va);
|
||||
if (*str != '\0') print_string(&dest, str);
|
||||
str = format_get_text_theme_args(theme, module, &dest, formatnum, va);
|
||||
if (*str != '\0') print_line(&dest, str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
@ -521,37 +261,16 @@ void printformat_module_window(const char *module, WINDOW_REC *window,
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
#define LINE_START_IRSSI_LEVEL \
|
||||
(MSGLEVEL_CLIENTERROR | MSGLEVEL_CLIENTNOTICE)
|
||||
|
||||
#define NOT_LINE_START_LEVEL \
|
||||
(MSGLEVEL_NEVER | MSGLEVEL_LASTLOG | MSGLEVEL_CLIENTCRAP | \
|
||||
MSGLEVEL_MSGS | MSGLEVEL_PUBLIC | MSGLEVEL_DCC | MSGLEVEL_DCCMSGS | \
|
||||
MSGLEVEL_ACTIONS | MSGLEVEL_NOTICES | MSGLEVEL_SNOTES | MSGLEVEL_CTCPS)
|
||||
|
||||
/* return the "-!- " text at the start of the line */
|
||||
char *get_line_start_text(TEXT_DEST_REC *dest)
|
||||
static void print_line(TEXT_DEST_REC *dest, const char *text)
|
||||
{
|
||||
if (dest->level & LINE_START_IRSSI_LEVEL)
|
||||
return output_format_text(dest, IRCTXT_LINE_START_IRSSI);
|
||||
|
||||
if ((dest->level & NOT_LINE_START_LEVEL) == 0)
|
||||
return output_format_text(dest, IRCTXT_LINE_START);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void print_string(TEXT_DEST_REC *dest, const char *text)
|
||||
{
|
||||
gpointer levelp;
|
||||
void *levelp;
|
||||
char *str, *tmp;
|
||||
|
||||
g_return_if_fail(dest != NULL);
|
||||
g_return_if_fail(text != NULL);
|
||||
|
||||
tmp = get_line_start_text(dest);
|
||||
str = tmp == NULL ? (char *) text :
|
||||
g_strconcat(tmp, text, NULL);
|
||||
tmp = format_get_line_start(current_theme, dest);
|
||||
str = format_add_linestart(text, tmp);
|
||||
g_free_not_null(tmp);
|
||||
|
||||
levelp = GINT_TO_POINTER(dest->level);
|
||||
@ -562,7 +281,7 @@ static void print_string(TEXT_DEST_REC *dest, const char *text)
|
||||
g_free(tmp);
|
||||
|
||||
signal_emit_id(signal_print_text, 5, dest->window, dest->server, dest->target, levelp, str);
|
||||
if (str != text) g_free(str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
/* append string to `out', expand newlines. */
|
||||
@ -572,7 +291,7 @@ static void printtext_append_str(TEXT_DEST_REC *dest, GString *out, const char *
|
||||
if (*str != '\n')
|
||||
g_string_append_c(out, *str);
|
||||
else {
|
||||
print_string(dest, out->str);
|
||||
print_line(dest, out->str);
|
||||
g_string_truncate(out, 0);
|
||||
}
|
||||
str++;
|
||||
@ -631,7 +350,7 @@ static char *printtext_get_args(TEXT_DEST_REC *dest, const char *str, va_list va
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (!expand_styles(out, *str, dest)) {
|
||||
if (!format_expand_styles(out, *str, dest)) {
|
||||
g_string_append_c(out, '%');
|
||||
g_string_append_c(out, *str);
|
||||
}
|
||||
@ -653,13 +372,13 @@ void printtext(void *server, const char *target, int level, const char *text, ..
|
||||
|
||||
g_return_if_fail(text != NULL);
|
||||
|
||||
create_dest_rec(&dest, server, target, level, NULL);
|
||||
format_create_dest(&dest, server, target, level, NULL);
|
||||
|
||||
va_start(va, text);
|
||||
str = printtext_get_args(&dest, text, va);
|
||||
va_end(va);
|
||||
|
||||
print_string(&dest, str);
|
||||
print_line(&dest, str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
@ -671,14 +390,14 @@ void printtext_window(WINDOW_REC *window, int level, const char *text, ...)
|
||||
|
||||
g_return_if_fail(text != NULL);
|
||||
|
||||
create_dest_rec(&dest, NULL, NULL, level,
|
||||
window != NULL ? window : active_win);
|
||||
format_create_dest(&dest, NULL, NULL, level,
|
||||
window != NULL ? window : active_win);
|
||||
|
||||
va_start(va, text);
|
||||
str = printtext_get_args(&dest, text, va);
|
||||
va_end(va);
|
||||
|
||||
print_string(&dest, str);
|
||||
print_line(&dest, str);
|
||||
g_free(str);
|
||||
}
|
||||
|
||||
@ -715,9 +434,10 @@ static char *get_timestamp(TEXT_DEST_REC *dest)
|
||||
}
|
||||
|
||||
tm = localtime(&t);
|
||||
return output_format_text(dest, IRCTXT_TIMESTAMP,
|
||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
return format_get_text_theme(NULL, MODULE_NAME, dest, IRCTXT_TIMESTAMP,
|
||||
tm->tm_year+1900,
|
||||
tm->tm_mon+1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||
}
|
||||
|
||||
static char *get_server_tag(TEXT_DEST_REC *dest)
|
||||
@ -730,7 +450,8 @@ static char *get_server_tag(TEXT_DEST_REC *dest)
|
||||
(dest->window->active != NULL && dest->window->active->server == server))
|
||||
return NULL;
|
||||
|
||||
return output_format_text(dest, IRCTXT_SERVERTAG, server->tag);
|
||||
return format_get_text_theme(NULL, MODULE_NAME, dest,
|
||||
IRCTXT_SERVERTAG, server->tag);
|
||||
}
|
||||
|
||||
static void msg_beep_check(SERVER_REC *server, int level)
|
||||
@ -742,197 +463,166 @@ static void msg_beep_check(SERVER_REC *server, int level)
|
||||
}
|
||||
}
|
||||
|
||||
static char *fix_line_start(TEXT_DEST_REC *dest, const char *text)
|
||||
{
|
||||
char *timestamp, *servertag;
|
||||
char *linestart, *str;
|
||||
|
||||
timestamp = get_timestamp(dest);
|
||||
servertag = get_server_tag(dest);
|
||||
|
||||
if (timestamp == NULL && servertag == NULL)
|
||||
return g_strdup(text);
|
||||
|
||||
linestart = g_strconcat(timestamp != NULL ? timestamp : "",
|
||||
servertag, NULL);
|
||||
str = format_add_linestart(text, linestart);
|
||||
g_free(linestart);
|
||||
|
||||
g_free_not_null(timestamp);
|
||||
g_free_not_null(servertag);
|
||||
return str;
|
||||
}
|
||||
|
||||
static void sig_print_text(WINDOW_REC *window, SERVER_REC *server,
|
||||
const char *target, gpointer level,
|
||||
const char *text)
|
||||
{
|
||||
TEXT_DEST_REC dest;
|
||||
char *dup, *ptr, type, *str, *timestamp, *servertag;
|
||||
int fgcolor, bgcolor;
|
||||
int flags;
|
||||
TEXT_DEST_REC dest;
|
||||
char *dup, *ptr, type, *str;
|
||||
int fgcolor, bgcolor;
|
||||
int flags;
|
||||
|
||||
g_return_if_fail(text != NULL);
|
||||
g_return_if_fail(window != NULL);
|
||||
g_return_if_fail(text != NULL);
|
||||
g_return_if_fail(window != NULL);
|
||||
|
||||
create_dest_rec(&dest, server, target, GPOINTER_TO_INT(level), window);
|
||||
msg_beep_check(server, dest.level);
|
||||
format_create_dest(&dest, server, target,
|
||||
GPOINTER_TO_INT(level), window);
|
||||
msg_beep_check(server, dest.level);
|
||||
|
||||
flags = 0; fgcolor = -1; bgcolor = -1; type = '\0';
|
||||
window->last_line = time(NULL);
|
||||
newline(window);
|
||||
window->last_line = time(NULL);
|
||||
newline(window);
|
||||
|
||||
timestamp = get_timestamp(&dest);
|
||||
servertag = get_server_tag(&dest);
|
||||
str = g_strconcat(timestamp != NULL ? timestamp : "",
|
||||
servertag != NULL ? servertag : "",
|
||||
text, NULL);
|
||||
g_free_not_null(timestamp);
|
||||
g_free_not_null(servertag);
|
||||
dup = str = fix_line_start(&dest, text);
|
||||
flags = 0; fgcolor = -1; bgcolor = -1; type = '\0';
|
||||
while (*str != '\0') {
|
||||
for (ptr = str; *ptr != '\0'; ptr++) {
|
||||
if (IS_COLOR_CODE(*ptr)) {
|
||||
type = *ptr;
|
||||
*ptr++ = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
dup = str;
|
||||
while (*str != '\0')
|
||||
{
|
||||
for (ptr = str; *ptr != '\0'; ptr++)
|
||||
{
|
||||
if (is_color_code(*ptr))
|
||||
{
|
||||
type = *ptr;
|
||||
*ptr++ = '\0';
|
||||
break;
|
||||
}
|
||||
*ptr = (char) translation_in[(int) (unsigned char) *ptr];
|
||||
}
|
||||
|
||||
*ptr = (char) translation_in[(gint) (guchar) *ptr];
|
||||
}
|
||||
if (type == 7) {
|
||||
/* bell */
|
||||
if (settings_get_bool("bell_beeps"))
|
||||
flags |= PRINTFLAG_BEEP;
|
||||
}
|
||||
if (*str != '\0' || flags & PRINTFLAG_BEEP) {
|
||||
/* send the text to gui handler */
|
||||
signal_emit_id(signal_gui_print_text, 6, window,
|
||||
GINT_TO_POINTER(fgcolor),
|
||||
GINT_TO_POINTER(bgcolor),
|
||||
GINT_TO_POINTER(flags), str, level);
|
||||
flags &= ~(PRINTFLAG_BEEP|PRINTFLAG_INDENT);
|
||||
}
|
||||
|
||||
if (type == 7)
|
||||
{
|
||||
/* bell */
|
||||
if (settings_get_bool("bell_beeps"))
|
||||
flags |= PRINTFLAG_BEEP;
|
||||
}
|
||||
if (*str != '\0' || flags & PRINTFLAG_BEEP)
|
||||
{
|
||||
signal_emit_id(signal_gui_print_text, 6, window,
|
||||
GINT_TO_POINTER(fgcolor), GINT_TO_POINTER(bgcolor),
|
||||
GINT_TO_POINTER(flags), str, level);
|
||||
flags &= ~(PRINTFLAG_BEEP|PRINTFLAG_INDENT);
|
||||
}
|
||||
if (*ptr == '\0') break;
|
||||
if (*ptr == '\0')
|
||||
break;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 2:
|
||||
/* bold */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case 6:
|
||||
/* blink */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BLINK;
|
||||
break;
|
||||
case 15:
|
||||
/* remove all styling */
|
||||
flags &= PRINTFLAG_BEEP;
|
||||
fgcolor = bgcolor = -1;
|
||||
break;
|
||||
case 22:
|
||||
/* reverse */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_REVERSE;
|
||||
break;
|
||||
case 31:
|
||||
/* underline */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_UNDERLINE;
|
||||
case 27:
|
||||
/* ansi color code */
|
||||
ptr = convert_ansi(window->theme == NULL ? current_theme :
|
||||
window->theme, ptr, &fgcolor, &bgcolor, &flags);
|
||||
break;
|
||||
case 4:
|
||||
/* user specific colors */
|
||||
flags &= ~PRINTFLAG_MIRC_COLOR;
|
||||
if ((signed char) *ptr == -1)
|
||||
{
|
||||
ptr++;
|
||||
if ((signed char) *ptr == -1)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 2:
|
||||
/* bold */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case 6:
|
||||
/* blink */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_BLINK;
|
||||
break;
|
||||
case 15:
|
||||
/* remove all styling */
|
||||
flags &= PRINTFLAG_BEEP;
|
||||
fgcolor = bgcolor = -1;
|
||||
flags &= PRINTFLAG_INDENT;
|
||||
}
|
||||
else if (*ptr == 1)
|
||||
flags ^= PRINTFLAG_BOLD;
|
||||
else if (*ptr == 2)
|
||||
flags ^= PRINTFLAG_UNDERLINE;
|
||||
else if (*ptr == 3)
|
||||
flags ^= PRINTFLAG_REVERSE;
|
||||
else if (*ptr == 4)
|
||||
flags |= PRINTFLAG_INDENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((signed char) *ptr != -2)
|
||||
{
|
||||
fgcolor = (guchar) *ptr-1;
|
||||
if (fgcolor <= 7)
|
||||
flags &= ~PRINTFLAG_BOLD;
|
||||
else
|
||||
{
|
||||
/* bold */
|
||||
if (fgcolor != 8) fgcolor -= 8;
|
||||
flags |= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case 22:
|
||||
/* reverse */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_REVERSE;
|
||||
break;
|
||||
case 31:
|
||||
/* underline */
|
||||
if (!hide_text_style)
|
||||
flags ^= PRINTFLAG_UNDERLINE;
|
||||
case 27:
|
||||
/* ansi color code */
|
||||
ptr = get_ansi_color(window->theme == NULL ?
|
||||
current_theme : window->theme,
|
||||
ptr,
|
||||
hide_text_style ? NULL : &fgcolor,
|
||||
hide_text_style ? NULL : &bgcolor,
|
||||
hide_text_style ? NULL : &flags);
|
||||
break;
|
||||
case 4:
|
||||
/* user specific colors */
|
||||
flags &= ~PRINTFLAG_MIRC_COLOR;
|
||||
switch (*ptr) {
|
||||
case FORMAT_STYLE_UNDERLINE:
|
||||
flags ^= PRINTFLAG_UNDERLINE;
|
||||
break;
|
||||
case FORMAT_STYLE_BOLD:
|
||||
flags ^= PRINTFLAG_BOLD;
|
||||
break;
|
||||
case FORMAT_STYLE_REVERSE:
|
||||
flags ^= PRINTFLAG_REVERSE;
|
||||
break;
|
||||
case FORMAT_STYLE_INDENT:
|
||||
flags |= PRINTFLAG_INDENT;
|
||||
break;
|
||||
case FORMAT_STYLE_DEFAULTS:
|
||||
fgcolor = bgcolor = -1;
|
||||
flags &= PRINTFLAG_INDENT;
|
||||
break;
|
||||
default:
|
||||
if (*ptr != FORMAT_COLOR_NOCHANGE) {
|
||||
fgcolor = (unsigned char) *ptr-'0';
|
||||
if (fgcolor <= 7)
|
||||
flags &= ~PRINTFLAG_BOLD;
|
||||
else {
|
||||
/* bold */
|
||||
if (fgcolor != 8) fgcolor -= 8;
|
||||
flags |= PRINTFLAG_BOLD;
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
if (*ptr != FORMAT_COLOR_NOCHANGE)
|
||||
bgcolor = *ptr-'0';
|
||||
}
|
||||
}
|
||||
ptr++;
|
||||
if ((signed char) *ptr != -2)
|
||||
bgcolor = (signed char) *ptr == -1 ? -1 : *ptr-1;
|
||||
}
|
||||
ptr++;
|
||||
break;
|
||||
case 3:
|
||||
if (*ptr < 17)
|
||||
{
|
||||
/* mostly just for irssi's internal use.. */
|
||||
fgcolor = (*ptr++)-1;
|
||||
if (*ptr == 0 || *ptr >= 17)
|
||||
bgcolor = -1;
|
||||
else
|
||||
bgcolor = (*ptr++)-1;
|
||||
if (fgcolor & 8)
|
||||
flags |= PRINTFLAG_BOLD;
|
||||
else
|
||||
flags &= ~PRINTFLAG_BOLD;
|
||||
break;
|
||||
ptr++;
|
||||
break;
|
||||
case 3:
|
||||
/* MIRC color */
|
||||
get_mirc_color((const char **) &ptr,
|
||||
hide_text_style ? NULL : &fgcolor,
|
||||
hide_text_style ? NULL : &bgcolor);
|
||||
if (!hide_text_style)
|
||||
flags |= PRINTFLAG_MIRC_COLOR;
|
||||
break;
|
||||
}
|
||||
|
||||
/* MIRC color */
|
||||
if (hide_text_style)
|
||||
{
|
||||
/* don't show them. */
|
||||
skip_mirc_color(&ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
flags |= PRINTFLAG_MIRC_COLOR;
|
||||
if (!isdigit((gint) *ptr) && *ptr != ',')
|
||||
{
|
||||
fgcolor = -1;
|
||||
bgcolor = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* foreground color */
|
||||
if (*ptr != ',')
|
||||
{
|
||||
fgcolor = *ptr++-'0';
|
||||
if (isdigit((gint) *ptr))
|
||||
fgcolor = fgcolor*10 + (*ptr++-'0');
|
||||
}
|
||||
if (*ptr == ',')
|
||||
{
|
||||
/* back color */
|
||||
bgcolor = 0;
|
||||
if (!isdigit((gint) *++ptr))
|
||||
bgcolor = -1;
|
||||
else
|
||||
{
|
||||
bgcolor = *ptr++-'0';
|
||||
if (isdigit((gint) *ptr))
|
||||
bgcolor = bgcolor*10 + (*ptr++-'0');
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
str = ptr;
|
||||
}
|
||||
g_free(dup);
|
||||
signal_emit_id(signal_print_text_finished, 1, window);
|
||||
str = ptr;
|
||||
}
|
||||
g_free(dup);
|
||||
signal_emit_id(signal_print_text_finished, 1, window);
|
||||
}
|
||||
|
||||
void printtext_multiline(void *server, const char *target, int level, const char *format, const char *text)
|
||||
void printtext_multiline(void *server, const char *target, int level,
|
||||
const char *format, const char *text)
|
||||
{
|
||||
char **lines, **tmp;
|
||||
|
||||
|
@ -3,21 +3,6 @@
|
||||
|
||||
#include "windows.h"
|
||||
|
||||
enum {
|
||||
FORMAT_STRING,
|
||||
FORMAT_INT,
|
||||
FORMAT_LONG,
|
||||
FORMAT_FLOAT
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char *tag;
|
||||
char *def;
|
||||
|
||||
int params;
|
||||
int paramtypes[10];
|
||||
} FORMAT_REC;
|
||||
|
||||
#define PRINTFLAG_BOLD 0x01
|
||||
#define PRINTFLAG_REVERSE 0x02
|
||||
#define PRINTFLAG_UNDERLINE 0x04
|
||||
@ -26,10 +11,6 @@ typedef struct {
|
||||
#define PRINTFLAG_MIRC_COLOR 0x20
|
||||
#define PRINTFLAG_INDENT 0x40
|
||||
|
||||
char *output_format_get_text(const char *module, WINDOW_REC *window,
|
||||
void *server, const char *target,
|
||||
int formatnum, ...);
|
||||
|
||||
void printformat_module(const char *module, void *server, const char *target, int level, int formatnum, ...);
|
||||
void printformat_module_window(const char *module, WINDOW_REC *window, int level, int formatnum, ...);
|
||||
|
||||
@ -67,9 +48,10 @@ void printtext_deinit(void);
|
||||
printformat_module_window(MODULE_NAME, window, level, formatnum, __VA_ARGS__)
|
||||
#else
|
||||
/* inline/static */
|
||||
static
|
||||
#ifdef G_CAN_INLINE
|
||||
inline
|
||||
G_INLINE_FUNC
|
||||
#else
|
||||
static
|
||||
#endif
|
||||
void printformat(void *server, const char *target, int level, int formatnum, ...)
|
||||
{
|
||||
@ -80,9 +62,10 @@ void printformat(void *server, const char *target, int level, int formatnum, ...
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static
|
||||
#ifdef G_CAN_INLINE
|
||||
inline
|
||||
G_INLINE_FUNC
|
||||
#else
|
||||
static
|
||||
#endif
|
||||
void printformat_window(WINDOW_REC *window, int level, int formatnum, ...)
|
||||
{
|
||||
@ -94,18 +77,4 @@ void printformat_window(WINDOW_REC *window, int level, int formatnum, ...)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* semi-private functions.. */
|
||||
typedef struct {
|
||||
WINDOW_REC *window;
|
||||
void *server;
|
||||
const char *target;
|
||||
int level;
|
||||
} TEXT_DEST_REC;
|
||||
|
||||
char *output_format_text_args(TEXT_DEST_REC *dest, FORMAT_REC *format,
|
||||
const char *text, va_list va);
|
||||
|
||||
/* return the "-!- " text at the start of the line */
|
||||
char *get_line_start_text(TEXT_DEST_REC *dest);
|
||||
|
||||
#endif
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "printtext.h"
|
||||
|
||||
GSList *themes;
|
||||
THEME_REC *current_theme;
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef __THEMES_H
|
||||
#define __THEMES_H
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
|
||||
@ -26,6 +24,8 @@ typedef struct {
|
||||
void *gui_data;
|
||||
} THEME_REC;
|
||||
|
||||
typedef struct _FORMAT_REC FORMAT_REC;
|
||||
|
||||
extern GSList *themes;
|
||||
extern THEME_REC *current_theme;
|
||||
extern GHashTable *default_formats;
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "window-save.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void cmd_window(const char *data, void *server, WI_ITEM_REC *item)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
|
||||
void window_add_item(WINDOW_REC *window, WI_ITEM_REC *item, int automatic)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "windows.h"
|
||||
|
||||
#include "module-formats.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void dcc_connected(DCC_REC *dcc)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC fecommon_irc_dcc_formats[] = {
|
||||
{ MODULE_NAME, "IRC", 0 },
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void ctcp_print(const char *pre, const char *data, IRC_SERVER_REC *server, const char *nick, const char *addr, const char *target)
|
||||
{
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "irc-channels.h"
|
||||
#include "nicklist.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
static char *last_away_nick = NULL;
|
||||
static char *last_away_msg = NULL;
|
||||
|
||||
@ -96,10 +98,10 @@ static void display_sorted_nicks(CHANNEL_REC *channel, GSList *nicklist, gint it
|
||||
memset(linebuf, ' ', max);
|
||||
nickmode[0] = rec->op ? '@' : rec->voice ? '+' : ' ';
|
||||
memcpy(linebuf, rec->nick, strlen(rec->nick));
|
||||
ret = output_format_get_text(MODULE_NAME, NULL,
|
||||
channel->server, channel->name,
|
||||
IRCTXT_NAMES_NICK, nickmode, linebuf);
|
||||
g_string_append(str, ret);
|
||||
ret = format_get_text(MODULE_NAME, NULL,
|
||||
channel->server, channel->name,
|
||||
IRCTXT_NAMES_NICK, nickmode, linebuf);
|
||||
g_string_append(str, ret);
|
||||
g_free(ret);
|
||||
cols++;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "irc-channels.h"
|
||||
#include "irc-nicklist.h"
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#include "completion.h"
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include "irc.h"
|
||||
#include "channel-rejoin.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
static void sig_channel_rejoin(IRC_SERVER_REC *server, REJOIN_REC *rec)
|
||||
{
|
||||
g_return_if_fail(rec != NULL);
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include "fe-queries.h"
|
||||
#include "windows.h"
|
||||
#include "window-items.h"
|
||||
#include "printtext.h"
|
||||
|
||||
/* SYNTAX: ME <message> */
|
||||
static void cmd_me(gchar *data, IRC_SERVER_REC *server, WI_ITEM_REC *item)
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "irc-servers-setup.h"
|
||||
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void sig_server_add_create(IRC_SERVER_SETUP_REC **rec,
|
||||
GHashTable *optlist)
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "irc-servers.h"
|
||||
#include "irc-chatnets.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void cmd_ircnet_list(void)
|
||||
{
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "ignore.h"
|
||||
#include "netsplit.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
#define NETJOIN_WAIT_TIME 2 /* how many seconds to wait for the netsplitted JOIN messages to stop */
|
||||
#define NETJOIN_MAX_WAIT 30 /* how many seconds to wait for nick to join to the rest of the channels she was before the netsplit */
|
||||
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "ignore.h"
|
||||
#include "netsplit.h"
|
||||
|
||||
#include "printtext.h"
|
||||
|
||||
#define SPLIT_WAIT_TIME 2 /* how many seconds to wait for the QUIT split messages to stop */
|
||||
|
||||
static int split_tag;
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "irc/flood/autoignore.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "printtext.h"
|
||||
|
||||
static void event_autoignore_new(IRC_SERVER_REC *server, AUTOIGNORE_REC *ignore)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC fecommon_irc_flood_formats[] =
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC fecommon_irc_formats[] = {
|
||||
{ MODULE_NAME, "IRC", 0 },
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "irc/notifylist/notifylist.h"
|
||||
|
||||
#include "themes.h"
|
||||
#include "printtext.h"
|
||||
|
||||
/* add the nick of a hostmask to list if it isn't there already */
|
||||
static GSList *mask_add_once(GSList *list, const char *mask)
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC fecommon_irc_notifylist_formats[] =
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "irc-servers.h"
|
||||
#include "windows.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#include "screen.h"
|
||||
#include "gui-windows.h"
|
||||
@ -56,8 +57,8 @@ static gchar *gui_window_line2text(LINE_REC *line)
|
||||
{
|
||||
/* set color */
|
||||
color = *ptr;
|
||||
g_string_sprintfa(str, "\003%c%c", (color & 0x07)+1, ((color & 0xf0) >> 4)+1);
|
||||
if (color & 0x08) g_string_sprintfa(str, "\002");
|
||||
g_string_sprintfa(str, "\004%c%c", (color & 0x0f)+'0',
|
||||
((color & 0xf0) >> 4)+'0');
|
||||
}
|
||||
else switch ((guchar) *ptr)
|
||||
{
|
||||
@ -73,16 +74,19 @@ static gchar *gui_window_line2text(LINE_REC *line)
|
||||
g_string_append_c(str, 31);
|
||||
break;
|
||||
case LINE_CMD_COLOR0:
|
||||
g_string_sprintfa(str, "\003%c%c", 1, ((color & 0xf0) >> 4)+1);
|
||||
g_string_sprintfa(str, "\004%c%c",
|
||||
'0', ((color & 0xf0) >> 4)+'0');
|
||||
break;
|
||||
case LINE_CMD_COLOR8:
|
||||
g_string_sprintfa(str, "\003%c%c", 9, ((color & 0xf0) >> 4)+1);
|
||||
g_string_sprintfa(str, "\004%c%c",
|
||||
'8', ((color & 0xf0) >> 4)+'0');
|
||||
color &= 0xfff0;
|
||||
color |= 8|ATTR_COLOR8;
|
||||
break;
|
||||
case LINE_CMD_BLINK:
|
||||
color |= 0x80;
|
||||
g_string_sprintfa(str, "\003%c%c", (color & 0x0f)+1, ((color & 0xf0) >> 4)+1);
|
||||
g_string_sprintfa(str, "\004%c%c", (color & 0x0f)+'0',
|
||||
((color & 0xf0) >> 4)+'0');
|
||||
break;
|
||||
case LINE_CMD_INDENT:
|
||||
break;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "commands.h"
|
||||
#include "levels.h"
|
||||
#include "misc.h"
|
||||
#include "printtext.h"
|
||||
|
||||
#include "screen.h"
|
||||
#include "statusbar.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include "module.h"
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
FORMAT_REC gui_text_formats[] =
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "printtext.h"
|
||||
#include "formats.h"
|
||||
|
||||
enum {
|
||||
IRCTXT_MODULE_NAME,
|
||||
|
Loading…
Reference in New Issue
Block a user