From baf4f8d5b02952e4adfcf60acdd1ac904c132c89 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Mon, 18 Oct 2021 09:07:21 +0300 Subject: Preferences: ANSI escape flags FG color and font style escapes can be enabled separately. FG color remains enabled by default like before. --- src/app.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/app.c') diff --git a/src/app.c b/src/app.c index 5b12db14..485c2495 100644 --- a/src/app.c +++ b/src/app.c @@ -234,6 +234,7 @@ static iString *serializePrefs_App_(const iApp *d) { iConstForEach(StringSet, fp, d->prefs.disabledFontPacks) { appendFormat_String(str, "fontpack.disable id:%s\n", cstr_String(fp.value)); } + appendFormat_String(str, "ansiescape arg:%d\n", d->prefs.gemtextAnsiEscapes); /* TODO: This array belongs in Prefs. It can then be used for command handling as well. */ const struct { const char * id; @@ -241,7 +242,6 @@ static iString *serializePrefs_App_(const iApp *d) { } boolPrefs[] = { { "prefs.animate", &d->prefs.uiAnimations }, { "prefs.font.smooth", &d->prefs.fontSmoothing }, - { "prefs.gemtext.ansi", &d->prefs.gemtextAnsiEscapes }, { "prefs.mono.gemini", &d->prefs.monospaceGemini }, { "prefs.mono.gopher", &d->prefs.monospaceGopher }, { "prefs.boldlink.visited", &d->prefs.boldLinkVisited }, @@ -2387,8 +2387,16 @@ iBool handleCommand_App(const char *cmd) { } return iTrue; } - else if (equal_Command(cmd, "prefs.gemtext.ansi.changed")) { - d->prefs.gemtextAnsiEscapes = arg_Command(cmd) != 0; + else if (equal_Command(cmd, "ansiescape")) { + d->prefs.gemtextAnsiEscapes = arg_Command(cmd); + return iTrue; + } + else if (equal_Command(cmd, "prefs.gemtext.ansi.fg.changed")) { + iChangeFlags(d->prefs.gemtextAnsiEscapes, allowFg_AnsiFlag, arg_Command(cmd)); + return iTrue; + } + else if (equal_Command(cmd, "prefs.gemtext.ansi.fontstyle.changed")) { + iChangeFlags(d->prefs.gemtextAnsiEscapes, allowFontStyle_AnsiFlag, arg_Command(cmd)); return iTrue; } else if (equal_Command(cmd, "prefs.mono.gemini.changed") || @@ -2822,7 +2830,10 @@ iBool handleCommand_App(const char *cmd) { setFlags_Widget(findChild_Widget(dlg, "prefs.boldlink.light"), selected_WidgetFlag, d->prefs.boldLinkLight); - setToggle_Widget(findChild_Widget(dlg, "prefs.gemtext.ansi"), d->prefs.gemtextAnsiEscapes); + setToggle_Widget(findChild_Widget(dlg, "prefs.gemtext.ansi.fg"), + d->prefs.gemtextAnsiEscapes & allowFg_AnsiFlag); + setToggle_Widget(findChild_Widget(dlg, "prefs.gemtext.ansi.fontstyle"), + d->prefs.gemtextAnsiEscapes & allowFontStyle_AnsiFlag); setToggle_Widget(findChild_Widget(dlg, "prefs.font.smooth"), d->prefs.fontSmoothing); setFlags_Widget( findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)), -- cgit v1.2.3