Permalink
Browse files

optionally render /foo/ as italics

  • Loading branch information...
1 parent e4a611a commit ee4fee04f1e076cb12065974ce15c5dbd2e98ff8 @mauke committed Nov 29, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/fe-common/core/fe-messages.c
@@ -45,26 +45,31 @@
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++) {
char type, *bgn, *end;
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;
@@ -643,6 +648,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);

0 comments on commit ee4fee0

Please sign in to comment.