1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

optionally render /foo/ as italics

This commit is contained in:
Lukas Mai 2011-11-30 00:54:42 +01:00 committed by Ailin Nemui
parent 0e294d5c2e
commit 225d149968

View File

@ -45,16 +45,19 @@
GHashTable *printnicks; 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 */ underlining or bolding */
char *expand_emphasis(WI_ITEM_REC *item, const char *text) char *expand_emphasis(WI_ITEM_REC *item, const char *text)
{ {
GString *str; GString *str;
char *ret; char *ret;
int pos; int pos;
int emphasis_italics;
g_return_val_if_fail(text != NULL, NULL); g_return_val_if_fail(text != NULL, NULL);
emphasis_italics = settings_get_bool("emphasis_italics");
str = g_string_new(text); str = g_string_new(text);
for (pos = 0; pos < str->len; pos++) { 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; bgn = str->str + pos;
if (*bgn == '*') if (*bgn == '*')
type = 2; /* bold */ type = 2; /* bold */
else if (*bgn == '_') else if (*bgn == '/' && emphasis_italics)
type = 29; /* italics */
else if (*bgn == '_')
type = 31; /* underlined */ type = 31; /* underlined */
else else
continue; continue;
@ -92,7 +97,7 @@ char *expand_emphasis(WI_ITEM_REC *item, const char *text)
found = nicklist_find(CHANNEL(item), bgn) != NULL; found = nicklist_find(CHANNEL(item), bgn) != NULL;
end[1] = c; end[1] = c;
if (found) continue; if (found) continue;
/* check if the whole 'word' (e.g. "_foo_^") is a nick /* check if the whole 'word' (e.g. "_foo_^") is a nick
in "_foo_^ ", end will be the second _, end2 the ^ */ in "_foo_^ ", end will be the second _, end2 the ^ */
end2 = end; end2 = end;
@ -680,6 +685,7 @@ void fe_messages_init(void)
settings_add_bool("lookandfeel", "emphasis", TRUE); settings_add_bool("lookandfeel", "emphasis", TRUE);
settings_add_bool("lookandfeel", "emphasis_replace", FALSE); settings_add_bool("lookandfeel", "emphasis_replace", FALSE);
settings_add_bool("lookandfeel", "emphasis_multiword", 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", TRUE);
settings_add_bool("lookandfeel", "show_nickmode_empty", TRUE); settings_add_bool("lookandfeel", "show_nickmode_empty", TRUE);
settings_add_bool("lookandfeel", "print_active_channel", FALSE); settings_add_bool("lookandfeel", "print_active_channel", FALSE);