summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-24 22:52:15 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-24 22:52:15 +0000
commit2a75c88f99e1aa24fbac81deac007ceca313b993 (patch)
tree5267820ea1eab3c7061056f2e7dbb92f2ace729b /src/fe-common
parentf7683c0423277dec3ec939cf33c3044658ee48a5 (diff)
downloadirssi-2a75c88f99e1aa24fbac81deac007ceca313b993.zip
Added support for changing indentation behaviour with modules.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1912 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/formats.c33
-rw-r--r--src/fe-common/core/formats.h22
2 files changed, 42 insertions, 13 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;
diff --git a/src/fe-common/core/formats.h b/src/fe-common/core/formats.h
index f8b91d1b..27e87715 100644
--- a/src/fe-common/core/formats.h
+++ b/src/fe-common/core/formats.h
@@ -4,14 +4,15 @@
#include "themes.h"
#include "fe-windows.h"
-#define GUI_PRINT_FLAG_BOLD 0x01
-#define GUI_PRINT_FLAG_REVERSE 0x02
-#define GUI_PRINT_FLAG_UNDERLINE 0x04
-#define GUI_PRINT_FLAG_BLINK 0x08
-#define GUI_PRINT_FLAG_MIRC_COLOR 0x10
-#define GUI_PRINT_FLAG_INDENT 0x20
-#define GUI_PRINT_FLAG_NEWLINE 0x40
-#define GUI_PRINT_FLAG_CLRTOEOL 0x80
+#define GUI_PRINT_FLAG_BOLD 0x0001
+#define GUI_PRINT_FLAG_REVERSE 0x0002
+#define GUI_PRINT_FLAG_UNDERLINE 0x0004
+#define GUI_PRINT_FLAG_BLINK 0x0008
+#define GUI_PRINT_FLAG_MIRC_COLOR 0x0010
+#define GUI_PRINT_FLAG_INDENT 0x0020
+#define GUI_PRINT_FLAG_INDENT_FUNC 0x0040
+#define GUI_PRINT_FLAG_NEWLINE 0x0080
+#define GUI_PRINT_FLAG_CLRTOEOL 0x0100
#define MAX_FORMAT_PARAMS 10
#define DEFAULT_FORMAT_ARGLIST_SIZE 200
@@ -121,8 +122,9 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text);
#define FORMAT_STYLE_BOLD (0x03 + FORMAT_STYLE_SPECIAL)
#define FORMAT_STYLE_REVERSE (0x04 + FORMAT_STYLE_SPECIAL)
#define FORMAT_STYLE_INDENT (0x05 + FORMAT_STYLE_SPECIAL)
-#define FORMAT_STYLE_DEFAULTS (0x06 + FORMAT_STYLE_SPECIAL)
-#define FORMAT_STYLE_CLRTOEOL (0x07 + FORMAT_STYLE_SPECIAL)
+#define FORMAT_STYLE_INDENT_FUNC (0x06 + FORMAT_STYLE_SPECIAL)
+#define FORMAT_STYLE_DEFAULTS (0x07 + FORMAT_STYLE_SPECIAL)
+#define FORMAT_STYLE_CLRTOEOL (0x08 + FORMAT_STYLE_SPECIAL)
int format_expand_styles(GString *out, const char **format, int *flags);
void formats_init(void);