summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-04-05 14:26:49 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-04-05 14:26:49 +0300
commit1137e9ab552ed2fecb019cc5574826f1dcce5cb7 (patch)
treebc727e677a8a4b15dd40f9141cdc80c4c52a8aa0 /src
parentcc35373ce184f6aedb2f92979ed162710c7b4840 (diff)
Added option to disable bold links
IssueID #233
Diffstat (limited to 'src')
-rw-r--r--src/app.c21
-rw-r--r--src/gmdocument.c13
-rw-r--r--src/prefs.c2
-rw-r--r--src/prefs.h2
-rw-r--r--src/ui/util.c53
5 files changed, 71 insertions, 20 deletions
diff --git a/src/app.c b/src/app.c
index 54f35373..5cfa8af1 100644
--- a/src/app.c
+++ b/src/app.c
@@ -226,6 +226,8 @@ static iString *serializePrefs_App_(const iApp *d) {
226 /* TODO: Set up an array of booleans in Prefs and do these in a loop. */ 226 /* TODO: Set up an array of booleans in Prefs and do these in a loop. */
227 appendFormat_String(str, "prefs.mono.gemini.changed arg:%d\n", d->prefs.monospaceGemini); 227 appendFormat_String(str, "prefs.mono.gemini.changed arg:%d\n", d->prefs.monospaceGemini);
228 appendFormat_String(str, "prefs.mono.gopher.changed arg:%d\n", d->prefs.monospaceGopher); 228 appendFormat_String(str, "prefs.mono.gopher.changed arg:%d\n", d->prefs.monospaceGopher);
229 appendFormat_String(str, "prefs.boldlink.dark.changed arg:%d\n", d->prefs.boldLinkDark);
230 appendFormat_String(str, "prefs.boldlink.light.changed arg:%d\n", d->prefs.boldLinkLight);
229 appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph); 231 appendFormat_String(str, "prefs.biglede.changed arg:%d\n", d->prefs.bigFirstParagraph);
230 appendFormat_String(str, "prefs.plaintext.wrap.changed arg:%d\n", d->prefs.plainTextWrap); 232 appendFormat_String(str, "prefs.plaintext.wrap.changed arg:%d\n", d->prefs.plainTextWrap);
231 appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon); 233 appendFormat_String(str, "prefs.sideicon.changed arg:%d\n", d->prefs.sideIcon);
@@ -1697,6 +1699,19 @@ iBool handleCommand_App(const char *cmd) {
1697 postCommand_App("window.unfreeze"); 1699 postCommand_App("window.unfreeze");
1698 return iTrue; 1700 return iTrue;
1699 } 1701 }
1702 else if (equal_Command(cmd, "prefs.boldlink.dark.changed") ||
1703 equal_Command(cmd, "prefs.boldlink.light.changed")) {
1704 const iBool isSet = (arg_Command(cmd) != 0);
1705 if (startsWith_CStr(cmd, "prefs.boldlink.dark")) {
1706 d->prefs.boldLinkDark = isSet;
1707 }
1708 else {
1709 d->prefs.boldLinkLight = isSet;
1710 }
1711 resetFonts_Text(); /* clear the glyph cache */
1712 postCommand_App("font.changed");
1713 return iTrue;
1714 }
1700 else if (equal_Command(cmd, "prefs.biglede.changed")) { 1715 else if (equal_Command(cmd, "prefs.biglede.changed")) {
1701 d->prefs.bigFirstParagraph = arg_Command(cmd) != 0; 1716 d->prefs.bigFirstParagraph = arg_Command(cmd) != 0;
1702 postCommand_App("document.layout.changed"); 1717 postCommand_App("document.layout.changed");
@@ -1938,6 +1953,12 @@ iBool handleCommand_App(const char *cmd) {
1938 setFlags_Widget(findChild_Widget(dlg, "prefs.mono.gopher"), 1953 setFlags_Widget(findChild_Widget(dlg, "prefs.mono.gopher"),
1939 selected_WidgetFlag, 1954 selected_WidgetFlag,
1940 d->prefs.monospaceGopher); 1955 d->prefs.monospaceGopher);
1956 setFlags_Widget(findChild_Widget(dlg, "prefs.boldlink.dark"),
1957 selected_WidgetFlag,
1958 d->prefs.boldLinkDark);
1959 setFlags_Widget(findChild_Widget(dlg, "prefs.boldlink.light"),
1960 selected_WidgetFlag,
1961 d->prefs.boldLinkLight);
1941 setFlags_Widget( 1962 setFlags_Widget(
1942 findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)), 1963 findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)),
1943 selected_WidgetFlag, 1964 selected_WidgetFlag,
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 184951d3..2a31fe77 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -336,8 +336,11 @@ static void alignDecoration_GmRun_(iGmRun *run, iBool isCentered) {
336} 336}
337 337
338static void doLayout_GmDocument_(iGmDocument *d) { 338static void doLayout_GmDocument_(iGmDocument *d) {
339 const iBool isMono = isForcedMonospace_GmDocument_(d); 339 const iPrefs *prefs = prefs_App();
340 const iBool isNarrow = d->size.x < 90 * gap_Text; 340 const iBool isMono = isForcedMonospace_GmDocument_(d);
341 const iBool isNarrow = d->size.x < 90 * gap_Text;
342 const iBool isDarkBg = isDark_GmDocumentTheme(
343 isDark_ColorTheme(colorTheme_App()) ? prefs->docThemeDark : prefs->docThemeLight);
341 /* TODO: Collect these parameters into a GmTheme. */ 344 /* TODO: Collect these parameters into a GmTheme. */
342 const int fonts[max_GmLineType] = { 345 const int fonts[max_GmLineType] = {
343 isMono ? regularMonospace_FontId : paragraph_FontId, 346 isMono ? regularMonospace_FontId : paragraph_FontId,
@@ -347,7 +350,10 @@ static void doLayout_GmDocument_(iGmDocument *d) {
347 heading1_FontId, 350 heading1_FontId,
348 heading2_FontId, 351 heading2_FontId,
349 heading3_FontId, 352 heading3_FontId,
350 isMono ? regularMonospace_FontId : bold_FontId, 353 isMono ? regularMonospace_FontId
354 : ((isDarkBg && prefs->boldLinkDark) || (!isDarkBg && prefs->boldLinkLight))
355 ? bold_FontId
356 : paragraph_FontId,
351 }; 357 };
352 static const int colors[max_GmLineType] = { 358 static const int colors[max_GmLineType] = {
353 tmParagraph_ColorId, 359 tmParagraph_ColorId,
@@ -376,7 +382,6 @@ static void doLayout_GmDocument_(iGmDocument *d) {
376 static const char *quote = "\u201c"; 382 static const char *quote = "\u201c";
377 static const char *magnifyingGlass = "\U0001f50d"; 383 static const char *magnifyingGlass = "\U0001f50d";
378 static const char *pointingFinger = "\U0001f449"; 384 static const char *pointingFinger = "\U0001f449";
379 const iPrefs *prefs = prefs_App();
380 clear_Array(&d->layout); 385 clear_Array(&d->layout);
381 clearLinks_GmDocument_(d); 386 clearLinks_GmDocument_(d);
382 clear_Array(&d->headings); 387 clear_Array(&d->headings);
diff --git a/src/prefs.c b/src/prefs.c
index bb0bb3ee..4c1d8dc2 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -47,6 +47,8 @@ void init_Prefs(iPrefs *d) {
47 d->headingFont = nunito_TextFont; 47 d->headingFont = nunito_TextFont;
48 d->monospaceGemini = iFalse; 48 d->monospaceGemini = iFalse;
49 d->monospaceGopher = iFalse; 49 d->monospaceGopher = iFalse;
50 d->boldLinkDark = iTrue;
51 d->boldLinkLight = iTrue;
50 d->lineWidth = 38; 52 d->lineWidth = 38;
51 d->bigFirstParagraph = iTrue; 53 d->bigFirstParagraph = iTrue;
52 d->quoteIcon = iTrue; 54 d->quoteIcon = iTrue;
diff --git a/src/prefs.h b/src/prefs.h
index 232c6fc3..6be7fd41 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -71,6 +71,8 @@ struct Impl_Prefs {
71 enum iTextFont headingFont; 71 enum iTextFont headingFont;
72 iBool monospaceGemini; 72 iBool monospaceGemini;
73 iBool monospaceGopher; 73 iBool monospaceGopher;
74 iBool boldLinkDark;
75 iBool boldLinkLight;
74 int lineWidth; 76 int lineWidth;
75 iBool bigFirstParagraph; 77 iBool bigFirstParagraph;
76 iBool quoteIcon; 78 iBool quoteIcon;
diff --git a/src/ui/util.c b/src/ui/util.c
index 4793f447..cdc58154 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1933,7 +1933,7 @@ iWidget *makePreferences_Widget(void) {
1933 setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId); 1933 setBackgroundColor_Widget(findChild_Widget(tabs, "tabs.buttons"), uiBackgroundSidebar_ColorId);
1934 setId_Widget(tabs, "prefs.tabs"); 1934 setId_Widget(tabs, "prefs.tabs");
1935 iWidget *headings, *values; 1935 iWidget *headings, *values;
1936 const int lineGap = lineHeight_Text(uiLabel_FontId); 1936 const int bigGap = lineHeight_Text(uiLabel_FontId) * 3 / 4;
1937 /* General preferences. */ { 1937 /* General preferences. */ {
1938 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values); 1938 appendTwoColumnPage_(tabs, "${heading.prefs.general}", '1', &headings, &values);
1939#if defined (LAGRANGE_DOWNLOAD_EDIT) 1939#if defined (LAGRANGE_DOWNLOAD_EDIT)
@@ -1942,8 +1942,8 @@ iWidget *makePreferences_Widget(void) {
1942#endif 1942#endif
1943 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.searchurl}"))); 1943 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.searchurl}")));
1944 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.searchurl"); 1944 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.searchurl");
1945 addChild_Widget(headings, iClob(makePadding_Widget(lineGap))); 1945 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1946 addChild_Widget(values, iClob(makePadding_Widget(lineGap))); 1946 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1947 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.collapsepreonload}"))); 1947 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.collapsepreonload}")));
1948 addChild_Widget(values, iClob(makeToggle_Widget("prefs.collapsepreonload"))); 1948 addChild_Widget(values, iClob(makeToggle_Widget("prefs.collapsepreonload")));
1949 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.plaintext.wrap}"))); 1949 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.plaintext.wrap}")));
@@ -1952,8 +1952,8 @@ iWidget *makePreferences_Widget(void) {
1952 addChild_Widget(values, iClob(makeToggle_Widget("prefs.centershort"))); 1952 addChild_Widget(values, iClob(makeToggle_Widget("prefs.centershort")));
1953 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.hoverlink}"))); 1953 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.hoverlink}")));
1954 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink"))); 1954 addChild_Widget(values, iClob(makeToggle_Widget("prefs.hoverlink")));
1955 addChild_Widget(headings, iClob(makePadding_Widget(lineGap))); 1955 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
1956 addChild_Widget(values, iClob(makePadding_Widget(lineGap))); 1956 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
1957 /* UI languages. */ { 1957 /* UI languages. */ {
1958 iArray *uiLangs = collectNew_Array(sizeof(iMenuItem)); 1958 iArray *uiLangs = collectNew_Array(sizeof(iMenuItem));
1959 const iMenuItem langItems[] = { 1959 const iMenuItem langItems[] = {
@@ -2076,17 +2076,36 @@ iWidget *makePreferences_Widget(void) {
2076 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.font}"))); 2076 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.font}")));
2077 addFontButtons_(values, "font"); 2077 addFontButtons_(values, "font");
2078 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.mono}"))); 2078 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.mono}")));
2079 iWidget *mono = new_Widget(); 2079 iWidget *mono = new_Widget(); {
2080 iWidget *tog; 2080 iWidget *tog;
2081 setTextCStr_LabelWidget( 2081 setTextCStr_LabelWidget(
2082 addChild_Widget(mono, tog = iClob(makeToggle_Widget("prefs.mono.gemini"))), "${prefs.mono.gemini}"); 2082 addChild_Widget(mono, tog = iClob(makeToggle_Widget("prefs.mono.gemini"))),
2083 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse); 2083 "${prefs.mono.gemini}");
2084 updateSize_LabelWidget((iLabelWidget *) tog); 2084 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse);
2085 setTextCStr_LabelWidget( 2085 updateSize_LabelWidget((iLabelWidget *) tog);
2086 addChild_Widget(mono, tog = iClob(makeToggle_Widget("prefs.mono.gopher"))), "${prefs.mono.gopher}"); 2086 setTextCStr_LabelWidget(
2087 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse); 2087 addChild_Widget(mono, tog = iClob(makeToggle_Widget("prefs.mono.gopher"))),
2088 updateSize_LabelWidget((iLabelWidget *) tog); 2088 "${prefs.mono.gopher}");
2089 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse);
2090 updateSize_LabelWidget((iLabelWidget *) tog);
2091 }
2089 addChildFlags_Widget(values, iClob(mono), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 2092 addChildFlags_Widget(values, iClob(mono), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
2093 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.boldlink}")));
2094 iWidget *boldLink = new_Widget(); {
2095 /* TODO: Add a utility function for this type of toggles? (also for above) */
2096 iWidget *tog;
2097 setTextCStr_LabelWidget(
2098 addChild_Widget(boldLink, tog = iClob(makeToggle_Widget("prefs.boldlink.dark"))),
2099 "${prefs.boldlink.dark}");
2100 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse);
2101 updateSize_LabelWidget((iLabelWidget *) tog);
2102 setTextCStr_LabelWidget(
2103 addChild_Widget(boldLink, tog = iClob(makeToggle_Widget("prefs.boldlink.light"))),
2104 "${prefs.boldlink.light}");
2105 setFlags_Widget(tog, fixedWidth_WidgetFlag, iFalse);
2106 updateSize_LabelWidget((iLabelWidget *) tog);
2107 }
2108 addChildFlags_Widget(values, iClob(boldLink), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
2090 } 2109 }
2091 makeTwoColumnHeading_("${heading.prefs.paragraph}", headings, values); 2110 makeTwoColumnHeading_("${heading.prefs.paragraph}", headings, values);
2092 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.linewidth}"))); 2111 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.linewidth}")));
@@ -2108,7 +2127,9 @@ iWidget *makePreferences_Widget(void) {
2108 addChildFlags_Widget(values, iClob(quote), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 2127 addChildFlags_Widget(values, iClob(quote), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
2109 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.biglede}"))); 2128 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.biglede}")));
2110 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede"))); 2129 addChild_Widget(values, iClob(makeToggle_Widget("prefs.biglede")));
2111 makeTwoColumnHeading_("${heading.prefs.widelayout}", headings, values); 2130// makeTwoColumnHeading_("${heading.prefs.widelayout}", headings, values);
2131 addChild_Widget(headings, iClob(makePadding_Widget(bigGap)));
2132 addChild_Widget(values, iClob(makePadding_Widget(bigGap)));
2112 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.sideicon}"))); 2133 addChild_Widget(headings, iClob(makeHeading_Widget("${prefs.sideicon}")));
2113 addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon"))); 2134 addChild_Widget(values, iClob(makeToggle_Widget("prefs.sideicon")));
2114 } 2135 }