summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@0x90.dk>2014-07-07 22:16:23 +0200
committerAlexander Færøy <ahf@0x90.dk>2014-07-07 22:16:23 +0200
commit09a1801186bdc682f8d0e7ad8c049e7f93172665 (patch)
treefa522c7fa78723c5ac703bafafc17f34314f1404 /src/fe-common
parent5e8947a8b0943ae569876af105c4702ab2d95742 (diff)
parent225d149968f72137d19002344d414637774f4377 (diff)
downloadirssi-09a1801186bdc682f8d0e7ad8c049e7f93172665.zip
Merge pull request #58 from ailin-nemui/italics
Implement italics support for Irssi
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/fe-messages.c14
-rw-r--r--src/fe-common/core/formats.c23
-rw-r--r--src/fe-common/core/formats.h2
3 files changed, 34 insertions, 5 deletions
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index 67c95745..25c20109 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -45,16 +45,19 @@
GHashTable *printnicks;
-/* convert _underlined_ and *bold* words (and phrases) to use real
+/* convert _underlined_, /italics/, and *bold* words (and phrases) to use real
underlining or bolding */
char *expand_emphasis(WI_ITEM_REC *item, const char *text)
{
GString *str;
char *ret;
int pos;
+ int emphasis_italics;
g_return_val_if_fail(text != NULL, NULL);
+ emphasis_italics = settings_get_bool("emphasis_italics");
+
str = g_string_new(text);
for (pos = 0; pos < str->len; pos++) {
@@ -62,9 +65,11 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
bgn = str->str + pos;
- if (*bgn == '*')
+ if (*bgn == '*')
type = 2; /* bold */
- else if (*bgn == '_')
+ else if (*bgn == '/' && emphasis_italics)
+ type = 29; /* italics */
+ else if (*bgn == '_')
type = 31; /* underlined */
else
continue;
@@ -92,7 +97,7 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
found = nicklist_find(CHANNEL(item), bgn) != NULL;
end[1] = c;
if (found) continue;
-
+
/* check if the whole 'word' (e.g. "_foo_^") is a nick
in "_foo_^ ", end will be the second _, end2 the ^ */
end2 = end;
@@ -680,6 +685,7 @@ void fe_messages_init(void)
settings_add_bool("lookandfeel", "emphasis", TRUE);
settings_add_bool("lookandfeel", "emphasis_replace", FALSE);
settings_add_bool("lookandfeel", "emphasis_multiword", FALSE);
+ settings_add_bool("lookandfeel", "emphasis_italics", FALSE);
settings_add_bool("lookandfeel", "show_nickmode", TRUE);
settings_add_bool("lookandfeel", "show_nickmode_empty", TRUE);
settings_add_bool("lookandfeel", "print_active_channel", FALSE);
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 770caaa1..375b00eb 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -207,6 +207,11 @@ int format_expand_styles(GString *out, const char **format, int *flags)
g_string_append_c(out, 4);
g_string_append_c(out, FORMAT_STYLE_REVERSE);
break;
+ case 'I':
+ /* italic */
+ g_string_append_c(out, 4);
+ g_string_append_c(out, FORMAT_STYLE_ITALIC);
+ break;
case ':':
/* Newline */
g_string_append_c(out, '\n');
@@ -913,6 +918,14 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
/* normal */
flags &= ~GUI_PRINT_FLAG_BOLD;
break;
+ case 3:
+ /* italic */
+ flags |= GUI_PRINT_FLAG_ITALIC;
+ break;
+ case 23:
+ /* not italic */
+ flags &= ~GUI_PRINT_FLAG_ITALIC;
+ break;
case 4:
/* underline */
flags |= GUI_PRINT_FLAG_UNDERLINE;
@@ -1085,7 +1098,7 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
#define IS_COLOR_CODE(c) \
((c) == 2 || (c) == 3 || (c) == 4 || (c) == 6 || (c) == 7 || \
- (c) == 15 || (c) == 22 || (c) == 27 || (c) == 31)
+ (c) == 15 || (c) == 22 || (c) == 27 || (c) == 29 || (c) == 31)
/* Return how many characters in `str' must be skipped before `len'
characters of text is skipped. */
@@ -1282,6 +1295,9 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
case FORMAT_STYLE_REVERSE:
flags ^= GUI_PRINT_FLAG_REVERSE;
break;
+ case FORMAT_STYLE_ITALIC:
+ flags ^= GUI_PRINT_FLAG_ITALIC;
+ break;
case FORMAT_STYLE_MONOSPACE:
flags ^= GUI_PRINT_FLAG_MONOSPACE;
break;
@@ -1356,6 +1372,11 @@ void format_send_to_gui(TEXT_DEST_REC *dest, const char *text)
if (!hide_text_style)
flags ^= GUI_PRINT_FLAG_REVERSE;
break;
+ case 29:
+ /* italic */
+ if (!hide_text_style)
+ flags ^= GUI_PRINT_FLAG_ITALIC;
+ break;
case 31:
/* underline */
if (!hide_text_style)
diff --git a/src/fe-common/core/formats.h b/src/fe-common/core/formats.h
index 037aa424..07e1832c 100644
--- a/src/fe-common/core/formats.h
+++ b/src/fe-common/core/formats.h
@@ -10,6 +10,7 @@
#define GUI_PRINT_FLAG_BLINK 0x0008
#define GUI_PRINT_FLAG_MIRC_COLOR 0x0010
#define GUI_PRINT_FLAG_INDENT 0x0020
+#define GUI_PRINT_FLAG_ITALIC 0x0040
#define GUI_PRINT_FLAG_NEWLINE 0x0080
#define GUI_PRINT_FLAG_CLRTOEOL 0x0100
#define GUI_PRINT_FLAG_MONOSPACE 0x0200
@@ -139,6 +140,7 @@ 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_ITALIC (0x06 + FORMAT_STYLE_SPECIAL)
#define FORMAT_STYLE_DEFAULTS (0x07 + FORMAT_STYLE_SPECIAL)
#define FORMAT_STYLE_CLRTOEOL (0x08 + FORMAT_STYLE_SPECIAL)
#define FORMAT_STYLE_MONOSPACE (0x09 + FORMAT_STYLE_SPECIAL)