degesch: add a way to output mIRC formatting
This commit is contained in:
parent
00b91976b0
commit
0a990ad6f7
39
degesch.c
39
degesch.c
|
@ -3967,6 +3967,39 @@ irc_process_message (const struct irc_message *msg,
|
||||||
irc_process_numeric (s, msg, numeric);
|
irc_process_numeric (s, msg, numeric);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- mIRC formatting ---------------------------------------------------------
|
||||||
|
|
||||||
|
// Out user interface doesn't give us much of a choice with entering it.
|
||||||
|
|
||||||
|
static char *
|
||||||
|
add_mirc_formatting (const char *text)
|
||||||
|
{
|
||||||
|
struct str output;
|
||||||
|
str_init (&output);
|
||||||
|
|
||||||
|
for (; *text; text++)
|
||||||
|
{
|
||||||
|
char c = *text;
|
||||||
|
if (c != '\\')
|
||||||
|
{
|
||||||
|
str_append_c (&output, c);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (text[1])
|
||||||
|
{
|
||||||
|
case 'b': c = '\x02'; text++; break;
|
||||||
|
case 'c': c = '\x03'; text++; break;
|
||||||
|
case 'i': c = '\x1d'; text++; break;
|
||||||
|
case '_': c = '\x1f'; text++; break;
|
||||||
|
case 'v': c = '\x16'; text++; break;
|
||||||
|
case 'o': c = '\x0f'; text++; break;
|
||||||
|
}
|
||||||
|
str_append_c (&output, c);
|
||||||
|
}
|
||||||
|
return str_steal (&output);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Message autosplitting magic ---------------------------------------------
|
// --- Message autosplitting magic ---------------------------------------------
|
||||||
|
|
||||||
// This is the most basic acceptable algorithm; something like ICU with proper
|
// This is the most basic acceptable algorithm; something like ICU with proper
|
||||||
|
@ -4102,10 +4135,13 @@ send_autosplit_message (struct server *s, struct send_autosplit_args a)
|
||||||
int fixed_part = strlen (a.command) + 1 + strlen (a.target) + 1 + 1
|
int fixed_part = strlen (a.command) + 1 + strlen (a.target) + 1 + 1
|
||||||
+ strlen (a.prefix) + strlen (a.suffix);
|
+ strlen (a.prefix) + strlen (a.suffix);
|
||||||
|
|
||||||
|
// XXX: this may screw up the formatting if we do split the message
|
||||||
|
char *formatted = add_mirc_formatting (a.message);
|
||||||
|
|
||||||
struct str_vector lines;
|
struct str_vector lines;
|
||||||
str_vector_init (&lines);
|
str_vector_init (&lines);
|
||||||
struct error *e = NULL;
|
struct error *e = NULL;
|
||||||
if (!irc_autosplit_message (s, a.message, fixed_part, &lines, &e))
|
if (!irc_autosplit_message (s, formatted, fixed_part, &lines, &e))
|
||||||
{
|
{
|
||||||
buffer_send_error (s->ctx,
|
buffer_send_error (s->ctx,
|
||||||
buffer ? buffer : s->buffer, "%s", e->message);
|
buffer ? buffer : s->buffer, "%s", e->message);
|
||||||
|
@ -4120,6 +4156,7 @@ send_autosplit_message (struct server *s, struct send_autosplit_args a)
|
||||||
a.logger (s, &a, buffer, lines.vector[i]);
|
a.logger (s, &a, buffer, lines.vector[i]);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
free (formatted);
|
||||||
str_vector_free (&lines);
|
str_vector_free (&lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue