mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Some fixes for handling %n
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@792 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
000ba23aa7
commit
1541257ac7
120
default.theme
120
default.theme
@ -1,5 +1,7 @@
|
||||
# these characters are automatically replaced with specified color
|
||||
replaces = { "[]<>=" = "%K$0-%n"; };
|
||||
replaces = {
|
||||
"[]<>=" = "%K$0-%n";
|
||||
};
|
||||
|
||||
# %n specifies the color set in higher level, like in
|
||||
# {ctcp {nick $0-} requested ... }
|
||||
@ -7,7 +9,7 @@ replaces = { "[]<>=" = "%K$0-%n"; };
|
||||
# "requested" text would be green
|
||||
|
||||
abstracts = {
|
||||
# generic
|
||||
# generic
|
||||
line_start = "%B-%W!%B-%n";
|
||||
hilight = "%_$0-%_";
|
||||
|
||||
@ -16,7 +18,7 @@ abstracts = {
|
||||
server = "%_$0-%_";
|
||||
reason = "[$0-]";
|
||||
|
||||
# channel specific messages
|
||||
# channel specific messages
|
||||
channick_hilight = "%C$0-%n";
|
||||
chanhost_hilight = "[%c$0-%n]";
|
||||
channick = "%c$0-%n";
|
||||
@ -24,24 +26,24 @@ abstracts = {
|
||||
channelhilight = "%c$0-%n";
|
||||
ban = "%c$0-%n";
|
||||
|
||||
# messages
|
||||
# messages
|
||||
msgnick = "<$0-> %|";
|
||||
msgownnick = "%W$0-%n";
|
||||
msgchannel = "%K:%c$0-%n";
|
||||
msgme = "%Y$0-%n";
|
||||
privmsgnick = "[%R$0-%n] ";
|
||||
privmsgnick = "[%R$0-%n] "
|
||||
privmsghost = "%K(%r$0-%K)%n";
|
||||
ownprivmsg = "[%r$0-%n] ";
|
||||
ownprivmsgdest = "%K(%R$0-%K)";
|
||||
|
||||
# actions
|
||||
# actions
|
||||
action = "%W * $0-%n ";
|
||||
ownaction = "{action $0-}";
|
||||
pvtaction = "%W (*) $0-%n ";
|
||||
pvtaction_query = "{action $0-}";
|
||||
pubaction = "{action $0-}";
|
||||
|
||||
# notices
|
||||
# notices
|
||||
ownnotice = "[%r$0-]%n ";
|
||||
ownnotice_target = "%K(%R$0-%K)";
|
||||
notice = "%K-%M$0-%K-%n ";
|
||||
@ -49,37 +51,37 @@ abstracts = {
|
||||
pvtnotice_nick = "%K(%m$0-%K)";
|
||||
servernotice = "%g!$0-%n ";
|
||||
|
||||
# ctcp
|
||||
# ctcp
|
||||
ownctcp = "[%r$0-] ";
|
||||
ownctcp_target = "K(%R$0-%K)";
|
||||
ownctcp_target = "%K(%R$0-%K)";
|
||||
ctcp = "%g$0-%n";
|
||||
|
||||
# wall
|
||||
# wall
|
||||
ownwall = "[%W$0-] ";
|
||||
ownwall_channel = "%K/%c$0-";
|
||||
|
||||
# wallops
|
||||
# wallops
|
||||
wallop = "%W$0-%n: ";
|
||||
wallop_nick = "%n$0-";
|
||||
wallop_action = "%W * $0-%n ";
|
||||
|
||||
# netsplits
|
||||
# netsplits
|
||||
netsplit = "%G$0-%n";
|
||||
netjoin = "%C$0-%n";
|
||||
|
||||
# /names list
|
||||
# /names list
|
||||
names_nickstat = "%_$0-%_";
|
||||
names_users = "[%g$0-%n]";
|
||||
names_channel = "%G$0-%n";
|
||||
|
||||
# dcc
|
||||
# dcc
|
||||
dcc = "%g$0-%n";
|
||||
dccfile = "%_$0-%_";
|
||||
|
||||
dccownmsg = "[%r$0-%n] ";
|
||||
dccownnick = "%K(%R$1%K)%n";
|
||||
dccownaction = "{action $0-}";
|
||||
dccmsg = "[%G$0-%n] ";
|
||||
dccmsg = "[%G$0-%n] "
|
||||
dccmsghost = "%K(%g$0-%K)%n";
|
||||
dccquerynick = "%G$0-%n";
|
||||
dccaction = "%W (*dcc*) $0-%n %|";
|
||||
@ -336,56 +338,56 @@ formats = {
|
||||
};
|
||||
|
||||
"fe-common/irc/dcc" = {
|
||||
own_dcc = "{dccownmsg dcc{dccownnick $1}}$2";
|
||||
own_dcc_action = "{dccownaction $0}$1";
|
||||
own_dcc_ctcp = "{ownctcp ctcp{ownctcp_target $0}}$1 $2";
|
||||
dcc_msg = "{dccmsg $0{dccmsghost dcc}}$1";
|
||||
action_dcc = "{dccaction $0}$1";
|
||||
own_dcc_query = "{msgnick {msgownnick $0}}$2";
|
||||
dcc_msg_query = "{msgnick {dccquerynick $0}}$1";
|
||||
dcc_ctcp = "{dcc >>> DCC CTCP received from {hilight $0}: $1}";
|
||||
dcc_chat = "{dcc DCC CHAT from {nick $0} [$1 port $2]}";
|
||||
dcc_chat_not_found = "{dcc No DCC CHAT connection open to {nick $0}}";
|
||||
dcc_chat_connected = "{dcc DCC CHAT connection with {nick $0} [$1 port $2] established}";
|
||||
dcc_chat_disconnected = "{dcc DCC lost chat to {nick $0}}";
|
||||
dcc_send = "{dcc DCC SEND from {nick $0} [$1 port $2]: $3 [$4 bytes]}";
|
||||
dcc_send_exists = "{dcc DCC already sending file {dccfile $0} for {nick $1}}";
|
||||
dcc_send_not_found = "{dcc DCC not sending file {dccfile $1} to {nick $0}}";
|
||||
dcc_send_file_not_found = "{dcc DCC file not found: {dccfile $0}}";
|
||||
dcc_send_connected = "{dcc DCC sending file {dccfile $0} for {nick $1} [$2 port $3]}";
|
||||
dcc_send_complete = "{dcc DCC sent file {dccfile $0} [{hilight $1}kb] for {nick $2} in {hilight $3} secs [{hilight $4kb/s}]}";
|
||||
dcc_send_aborted = "{dcc DCC aborted sending file {dccfile $0} for {nick $1}}";
|
||||
dcc_get_not_found = "{dcc DCC no file offered by {nick $0}}";
|
||||
dcc_get_connected = "{dcc DCC receiving file {dccfile $0} from {nick $1} [$2 port $3]}";
|
||||
dcc_get_complete = "{dcc DCC received file {dccfile $0} [$1kb] from {nick $2} in {hilight $3} secs [$4kb/s]}";
|
||||
dcc_get_aborted = "{dcc DCC aborted receiving file {dccfile $0} from {nick $1}}";
|
||||
dcc_unknown_ctcp = "{dcc DCC unknown ctcp {hilight $0} from {nick $1} [$2]}";
|
||||
dcc_unknown_reply = "{dcc DCC unknown reply {hilight $0} from {nick $1} [$2]}";
|
||||
dcc_unknown_type = "{dcc DCC unknown type {hilight $0}}";
|
||||
dcc_connect_error = "{dcc DCC can't connect to {hilight $0} port {hilight $1}}";
|
||||
dcc_cant_create = "{dcc DCC can't create file {dccfile $0}}";
|
||||
dcc_rejected = "{dcc DCC $0 was rejected by {nick $1} [{hilight $2}]}";
|
||||
dcc_close = "{dcc DCC $0 close for {nick $1} [{hilight $2}]}";
|
||||
dcc_list_header = "{dcc DCC connections}";
|
||||
dcc_list_line_chat = "{dcc $0 $1}";
|
||||
dcc_list_line_file = "{dcc $0 $1: $2k of $3k ($4%%) - $5kB/s - $6}";
|
||||
dcc_list_footer = "";
|
||||
own_dcc = "{dccownmsg dcc{dccownnick $1}}$2";
|
||||
own_dcc_action = "{dccownaction $0}$1";
|
||||
own_dcc_ctcp = "{ownctcp ctcp{ownctcp_target $0}}$1 $2";
|
||||
dcc_msg = "{dccmsg $0{dccmsghost dcc}}$1";
|
||||
action_dcc = "{dccaction $0}$1";
|
||||
own_dcc_query = "{msgnick {msgownnick $0}}$2";
|
||||
dcc_msg_query = "{msgnick {dccquerynick $0}}$1";
|
||||
dcc_ctcp = "{dcc >>> DCC CTCP received from {hilight $0}: $1}";
|
||||
dcc_chat = "{dcc DCC CHAT from {nick $0} [$1 port $2]}";
|
||||
dcc_chat_not_found = "{dcc No DCC CHAT connection open to {nick $0}}";
|
||||
dcc_chat_connected = "{dcc DCC CHAT connection with {nick $0} [$1 port $2] established}";
|
||||
dcc_chat_disconnected = "{dcc DCC lost chat to {nick $0}}";
|
||||
dcc_send = "{dcc DCC SEND from {nick $0} [$1 port $2]: $3 [$4 bytes]}";
|
||||
dcc_send_exists = "{dcc DCC already sending file {dccfile $0} for {nick $1}}";
|
||||
dcc_send_not_found = "{dcc DCC not sending file {dccfile $1} to {nick $0}}";
|
||||
dcc_send_file_not_found = "{dcc DCC file not found: {dccfile $0}}";
|
||||
dcc_send_connected = "{dcc DCC sending file {dccfile $0} for {nick $1} [$2 port $3]}";
|
||||
dcc_send_complete = "{dcc DCC sent file {dccfile $0} [{hilight $1}kb] for {nick $2} in {hilight $3} secs [{hilight $4kb/s}]}";
|
||||
dcc_send_aborted = "{dcc DCC aborted sending file {dccfile $0} for {nick $1}}";
|
||||
dcc_get_not_found = "{dcc DCC no file offered by {nick $0}}";
|
||||
dcc_get_connected = "{dcc DCC receiving file {dccfile $0} from {nick $1} [$2 port $3]}";
|
||||
dcc_get_complete = "{dcc DCC received file {dccfile $0} [$1kb] from {nick $2} in {hilight $3} secs [$4kb/s]}";
|
||||
dcc_get_aborted = "{dcc DCC aborted receiving file {dccfile $0} from {nick $1}}";
|
||||
dcc_unknown_ctcp = "{dcc DCC unknown ctcp {hilight $0} from {nick $1} [$2]}";
|
||||
dcc_unknown_reply = "{dcc DCC unknown reply {hilight $0} from {nick $1} [$2]}";
|
||||
dcc_unknown_type = "{dcc DCC unknown type {hilight $0}}";
|
||||
dcc_connect_error = "{dcc DCC can't connect to {hilight $0} port {hilight $1}}";
|
||||
dcc_cant_create = "{dcc DCC can't create file {dccfile $0}}";
|
||||
dcc_rejected = "{dcc DCC $0 was rejected by {nick $1} [{hilight $2}]}";
|
||||
dcc_close = "{dcc DCC $0 close for {nick $1} [{hilight $2}]}";
|
||||
dcc_list_header = "{dcc DCC connections}";
|
||||
dcc_list_line_chat = "{dcc $0 $1}";
|
||||
dcc_list_line_file = "{dcc $0 $1: $2k of $3k ($4%%) - $5kB/s - $6}";
|
||||
dcc_list_footer = "";
|
||||
};
|
||||
|
||||
"fe-common/irc/flood" = {
|
||||
autoignore = "Flood detected from {nick $0}, autoignoring for {hilight $1} minutes";
|
||||
autounignore = "Removed autoignore from {nick $0}";
|
||||
autoignore = "Flood detected from {nick $0}, autoignoring for {hilight $1} minutes";
|
||||
autounignore = "Removed autoignore from {nick $0}";
|
||||
};
|
||||
|
||||
"fe-common/irc/notifylist" = {
|
||||
notify_join = "{nick $0} [$1@$2] [{hilight $3}] has joined to $4";
|
||||
notify_part = "{nick $0} has left $4";
|
||||
notify_away = "{nick $0} [$5] [$1@$2] [{hilight $3}] is now away: $4";
|
||||
notify_unaway = "{nick $0} [$4] [$1@$2] [{hilight $3}] is now unaway";
|
||||
notify_unidle = "{nick $0} [$5] [$1@$2] [{hilight $3}] just stopped idling";
|
||||
notify_online = "On $0: {hilight $1}";
|
||||
notify_offline = "Offline: $0";
|
||||
notify_list = "$0: $1 $2 $3";
|
||||
notify_join = "{nick $0} [$1@$2] [{hilight $3}] has joined to $4";
|
||||
notify_part = "{nick $0} has left $4";
|
||||
notify_away = "{nick $0} [$5] [$1@$2] [{hilight $3}] is now away: $4";
|
||||
notify_unaway = "{nick $0} [$4] [$1@$2] [{hilight $3}] is now unaway"
|
||||
notify_unidle = "{nick $0} [$5] [$1@$2] [{hilight $3}] just stopped idling";
|
||||
notify_online = "On $0: {hilight $1}";
|
||||
notify_offline = "Offline: $0";
|
||||
notify_list = "$0: $1 $2 $3";
|
||||
};
|
||||
|
||||
"fe-text" = {
|
||||
|
@ -99,7 +99,9 @@ void theme_destroy(THEME_REC *rec)
|
||||
}
|
||||
|
||||
static char *theme_format_expand_data(THEME_REC *theme,
|
||||
const char **format, int root);
|
||||
const char **format,
|
||||
char default_color,
|
||||
char *before_arg_color, int root);
|
||||
|
||||
static int theme_replace_find(THEME_REC *theme, char chr)
|
||||
{
|
||||
@ -115,26 +117,48 @@ static int theme_replace_find(THEME_REC *theme, char chr)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char *theme_replace_expand(THEME_REC *theme, int index, char chr)
|
||||
static char *theme_replace_expand(THEME_REC *theme, int index,
|
||||
char default_color, char chr)
|
||||
{
|
||||
GSList *rec;
|
||||
char data[2];
|
||||
char *ret, *abstract, data[2];
|
||||
|
||||
rec = g_slist_nth(theme->replace_values, index);
|
||||
g_return_val_if_fail(rec != NULL, NULL);
|
||||
|
||||
data[0] = chr; data[1] = '\0';
|
||||
return parse_special_string(rec->data, NULL, NULL, data, NULL);
|
||||
|
||||
abstract = rec->data;
|
||||
abstract = theme_format_expand_data(theme, (const char **) &abstract,
|
||||
default_color, NULL, FALSE);
|
||||
ret = parse_special_string(abstract, NULL, NULL, data, NULL);
|
||||
g_free(abstract);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* append next "item", either a character or $variable */
|
||||
static const char *colorformats = "n01234567krgybmpcwKRGYBMPCW";
|
||||
|
||||
#define IS_COLOR_FORMAT(c) \
|
||||
(strchr(colorformats, c) != NULL)
|
||||
|
||||
/* append next "item", either a character, $variable or %format */
|
||||
static void theme_format_append_next(THEME_REC *theme, GString *str,
|
||||
const char **format)
|
||||
const char **format,
|
||||
char default_color, char *last_color)
|
||||
{
|
||||
int index;
|
||||
char *value;
|
||||
char *value, chr;
|
||||
|
||||
if (**format == '$') {
|
||||
chr = **format;
|
||||
if ((chr == '$' || chr == '%') &&
|
||||
(*format)[1] == '\0') {
|
||||
/* last char, always append */
|
||||
g_string_append_c(str, chr);
|
||||
(*format)++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (chr == '$') {
|
||||
/* $variable .. we'll always need to skip this, since it
|
||||
may contain characters that are in replace chars. */
|
||||
const char *orig;
|
||||
@ -143,6 +167,7 @@ static void theme_format_append_next(THEME_REC *theme, GString *str,
|
||||
|
||||
orig = *format;
|
||||
(*format)++;
|
||||
|
||||
value = parse_special((char **) format, NULL, NULL,
|
||||
args, &free_ret, NULL );
|
||||
if (free_ret) g_free(value);
|
||||
@ -155,11 +180,31 @@ static void theme_format_append_next(THEME_REC *theme, GString *str,
|
||||
return;
|
||||
}
|
||||
|
||||
index = theme_replace_find(theme, **format);
|
||||
if (**format == '%') {
|
||||
/* format */
|
||||
(*format)++;
|
||||
if (**format != '{' && **format != '}') {
|
||||
chr = **format;
|
||||
if (**format == 'n')
|
||||
chr = default_color;
|
||||
|
||||
if (IS_COLOR_FORMAT(chr))
|
||||
*last_color = chr;
|
||||
g_string_append_c(str, '%');
|
||||
g_string_append_c(str, chr);
|
||||
(*format)++;
|
||||
return;
|
||||
}
|
||||
|
||||
/* %{ or %} gives us { or } char */
|
||||
chr = **format;
|
||||
}
|
||||
|
||||
index = theme_replace_find(theme, chr);
|
||||
if (index == -1)
|
||||
g_string_append_c(str, **format);
|
||||
g_string_append_c(str, chr);
|
||||
else {
|
||||
value = theme_replace_expand(theme, index, **format);
|
||||
value = theme_replace_expand(theme, index, default_color, chr);
|
||||
g_string_append(str, value);
|
||||
g_free(value);
|
||||
}
|
||||
@ -169,7 +214,8 @@ static void theme_format_append_next(THEME_REC *theme, GString *str,
|
||||
|
||||
/* expand a single {abstract ...data... } */
|
||||
static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||
const char **formatp)
|
||||
const char **formatp,
|
||||
char default_color)
|
||||
{
|
||||
const char *p, *format;
|
||||
char *abstract, *data, *ret;
|
||||
@ -202,12 +248,14 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||
|
||||
/* abstract may itself contain abstracts or replaces :) */
|
||||
p = data = abstract;
|
||||
abstract = theme_format_expand_data(theme, &p, FALSE);
|
||||
abstract = theme_format_expand_data(theme, &p, default_color,
|
||||
&default_color, FALSE);
|
||||
g_free(data);
|
||||
|
||||
/* now we'll need to get the data part. it may contain
|
||||
more abstracts, they are automatically expanded. */
|
||||
data = theme_format_expand_data(theme, formatp, FALSE);
|
||||
data = theme_format_expand_data(theme, formatp, default_color,
|
||||
NULL, FALSE);
|
||||
|
||||
ret = parse_special_string(abstract, NULL, NULL, data, NULL);
|
||||
g_free(abstract);
|
||||
@ -218,10 +266,13 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||
/* expand the data part in {abstract data}. If root is TRUE, we're actually
|
||||
expanding the original format string so we ignore all extra } chars. */
|
||||
static char *theme_format_expand_data(THEME_REC *theme,
|
||||
const char **format, int root)
|
||||
const char **format,
|
||||
char default_color,
|
||||
char *before_arg_color, int root)
|
||||
{
|
||||
GString *str;
|
||||
char *ret, *abstract;
|
||||
char last_color = default_color;
|
||||
|
||||
str = g_string_new(NULL);
|
||||
|
||||
@ -232,7 +283,16 @@ static char *theme_format_expand_data(THEME_REC *theme,
|
||||
}
|
||||
|
||||
if (**format != '{') {
|
||||
theme_format_append_next(theme, str, format);
|
||||
if (before_arg_color != NULL &&
|
||||
**format == '$' && (*format)[1] == '0') {
|
||||
/* save the color before $0 ..
|
||||
this is for the %n replacing */
|
||||
*before_arg_color = last_color;
|
||||
before_arg_color = NULL;
|
||||
}
|
||||
|
||||
theme_format_append_next(theme, str, format,
|
||||
default_color, &last_color);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -241,7 +301,8 @@ static char *theme_format_expand_data(THEME_REC *theme,
|
||||
break; /* error */
|
||||
|
||||
/* get a single {...} */
|
||||
abstract = theme_format_expand_abstract(theme, format);
|
||||
abstract = theme_format_expand_abstract(theme, format,
|
||||
last_color);
|
||||
if (abstract != NULL) {
|
||||
g_string_append(str, abstract);
|
||||
g_free(abstract);
|
||||
@ -258,7 +319,7 @@ static char *theme_format_expand(THEME_REC *theme, const char *format)
|
||||
g_return_val_if_fail(theme != NULL, NULL);
|
||||
g_return_val_if_fail(format != NULL, NULL);
|
||||
|
||||
return theme_format_expand_data(theme, &format, TRUE);
|
||||
return theme_format_expand_data(theme, &format, 'n', NULL, TRUE);
|
||||
}
|
||||
|
||||
static MODULE_THEME_REC *theme_module_create(THEME_REC *theme, const char *module)
|
||||
|
Loading…
Reference in New Issue
Block a user