mirror of
https://github.com/irssi/irssi.git
synced 2026-08-10 20:33:46 +02:00
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:
parent
f7683c0423
commit
2a75c88f99
12 changed files with 368 additions and 92 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue