summaryrefslogtreecommitdiff
path: root/src/fe-common/core/formats.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fe-common/core/formats.c')
-rw-r--r--src/fe-common/core/formats.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 515a48a3..dbdd51f2 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -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;