Added support for changing indentation behaviour with modules.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1912 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-10-24 22:52:15 +00:00 committed by cras
commit 2a75c88f99
12 changed files with 368 additions and 92 deletions

View file

@ -60,7 +60,7 @@ int format_find_tag(const char *module, const char *tag)
return -1;
}
static void format_expand_code(const char **format, int *flags)
static void format_expand_code(const char **format, GString *out, int *flags)
{
int set;
@ -73,12 +73,28 @@ static void format_expand_code(const char **format, int *flags)
set = TRUE;
(*format)++;
while (**format != ']') {
while (**format != ']' && **format != '\0') {
if (**format == '+')
set = TRUE;
else if (**format == '-')
set = FALSE;
else switch (**format) {
case 'i':
/* indent function */
(*format)++;
if (**format == '=')
(*format)++;
g_string_append_c(out, 4);
g_string_append_c(out, FORMAT_STYLE_INDENT_FUNC);
while (**format != ']' && **format != '\0' &&
**format != ',') {
g_string_append_c(out, **format);
(*format)++;
}
g_string_append_c(out, ',');
(*format)--;
break;
case 's':
case 'S':
*flags |= !set ? PRINT_FLAG_UNSET_LINE_START :
@ -154,7 +170,7 @@ int format_expand_styles(GString *out, const char **format, int *flags)
break;
case '[':
/* code */
format_expand_code(format, flags);
format_expand_code(format, out, flags);
break;
default:
/* check if it's a background color */
@ -945,6 +961,17 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
case FORMAT_STYLE_INDENT:
flags |= GUI_PRINT_FLAG_INDENT;
break;
case FORMAT_STYLE_INDENT_FUNC: {
const char *start = ptr;
while (*ptr != ',' && *ptr != '\0')
ptr++;
if (*ptr != '\0') *ptr++ = '\0';
signal_emit_id(signal_gui_print_text, 6,
dest->window, NULL, NULL,
GINT_TO_POINTER(GUI_PRINT_FLAG_INDENT_FUNC),
str, start, dest->level);
break;
}
case FORMAT_STYLE_DEFAULTS:
fgcolor = bgcolor = -1;
flags &= GUI_PRINT_FLAG_INDENT;