summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c33
-rw-r--r--src/gmdocument.c38
-rw-r--r--src/prefs.c2
-rw-r--r--src/prefs.h2
-rw-r--r--src/ui/labelwidget.c2
-rw-r--r--src/ui/labelwidget.h2
-rw-r--r--src/ui/text.c14
-rw-r--r--src/ui/text.h4
-rw-r--r--src/ui/util.c21
9 files changed, 89 insertions, 29 deletions
diff --git a/src/app.c b/src/app.c
index d7cedc42..5971f0ed 100644
--- a/src/app.c
+++ b/src/app.c
@@ -179,6 +179,8 @@ static iString *serializePrefs_App_(const iApp *d) {
179 appendFormat_String(str, "prefs.dialogtab arg:%d\n", d->prefs.dialogTab); 179 appendFormat_String(str, "prefs.dialogtab arg:%d\n", d->prefs.dialogTab);
180 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font); 180 appendFormat_String(str, "font.set arg:%d\n", d->prefs.font);
181 appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont); 181 appendFormat_String(str, "headingfont.set arg:%d\n", d->prefs.headingFont);
182 appendFormat_String(str, "prefs.mono.gemini.changed arg:%d\n", d->prefs.monospaceGemini);
183 appendFormat_String(str, "prefs.mono.gopher.changed arg:%d\n", d->prefs.monospaceGopher);
182 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent); 184 appendFormat_String(str, "zoom.set arg:%d\n", d->prefs.zoomPercent);
183 appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling); 185 appendFormat_String(str, "smoothscroll arg:%d\n", d->prefs.smoothScrolling);
184 appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth); 186 appendFormat_String(str, "linewidth.set arg:%d\n", d->prefs.lineWidth);
@@ -724,7 +726,7 @@ static void updateColorThemeButton_(iLabelWidget *button, int theme) {
724 iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(button), "menu"))) { 726 iForEach(ObjectList, i, children_Widget(findChild_Widget(as_Widget(button), "menu"))) {
725 iLabelWidget *item = i.object; 727 iLabelWidget *item = i.object;
726 if (!cmp_String(command_LabelWidget(item), command)) { 728 if (!cmp_String(command_LabelWidget(item), command)) {
727 updateText_LabelWidget(button, label_LabelWidget(item)); 729 updateText_LabelWidget(button, text_LabelWidget(item));
728 break; 730 break;
729 } 731 }
730 } 732 }
@@ -987,6 +989,29 @@ iBool handleCommand_App(const char *cmd) {
987 postCommand_App("document.layout.changed"); 989 postCommand_App("document.layout.changed");
988 return iTrue; 990 return iTrue;
989 } 991 }
992 else if (equal_Command(cmd, "prefs.mono.gemini.changed") ||
993 equal_Command(cmd, "prefs.mono.gopher.changed")) {
994 const iBool isSet = (arg_Command(cmd) != 0);
995 setFreezeDraw_Window(d->window, iTrue);
996 if (startsWith_CStr(cmd, "prefs.mono.gemini")) {
997 d->prefs.monospaceGemini = isSet;
998 }
999 else {
1000 d->prefs.monospaceGopher = isSet;
1001 }
1002 resetFonts_Text(); /* clear the glyph cache */
1003 postCommand_App("font.changed");
1004 postCommand_App("window.unfreeze");
1005 return iTrue;
1006 }
1007 else if (equal_Command(cmd, "prefs.mono.gopher.changed")) {
1008 setFreezeDraw_Window(d->window, iTrue);
1009 d->prefs.monospaceGopher = arg_Command(cmd) != 0;
1010 resetFonts_Text(); /* clear the glyph cache */
1011 postCommand_App("font.changed");
1012 postCommand_App("window.unfreeze");
1013 return iTrue;
1014 }
990 else if (equal_Command(cmd, "prefs.biglede.changed")) { 1015 else if (equal_Command(cmd, "prefs.biglede.changed")) {
991 d->prefs.bigFirstParagraph = arg_Command(cmd) != 0; 1016 d->prefs.bigFirstParagraph = arg_Command(cmd) != 0;
992 postCommand_App("document.layout.changed"); 1017 postCommand_App("document.layout.changed");
@@ -1137,6 +1162,12 @@ iBool handleCommand_App(const char *cmd) {
1137 findChild_Widget(dlg, format_CStr("prefs.headingfont.%d", d->prefs.headingFont)), 1162 findChild_Widget(dlg, format_CStr("prefs.headingfont.%d", d->prefs.headingFont)),
1138 selected_WidgetFlag, 1163 selected_WidgetFlag,
1139 iTrue); 1164 iTrue);
1165 setFlags_Widget(findChild_Widget(dlg, "prefs.mono.gemini"),
1166 selected_WidgetFlag,
1167 d->prefs.monospaceGemini);
1168 setFlags_Widget(findChild_Widget(dlg, "prefs.mono.gopher"),
1169 selected_WidgetFlag,
1170 d->prefs.monospaceGopher);
1140 setFlags_Widget( 1171 setFlags_Widget(
1141 findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)), 1172 findChild_Widget(dlg, format_CStr("prefs.linewidth.%d", d->prefs.lineWidth)),
1142 selected_WidgetFlag, 1173 selected_WidgetFlag,
diff --git a/src/gmdocument.c b/src/gmdocument.c
index 4e8b5ace..923c20c9 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -235,24 +235,29 @@ static void clearLinks_GmDocument_(iGmDocument *d) {
235 clear_PtrArray(&d->links); 235 clear_PtrArray(&d->links);
236} 236}
237 237
238#if 0 238static iBool isForcedMonospace_GmDocument_(const iGmDocument *d) {
239static iBool isGopher_GmDocument_(const iGmDocument *d) { 239 const iRangecc scheme = urlScheme_String(&d->url);
240 return equalCase_Rangecc(urlScheme_String(&d->url), "gopher"); 240 if (equalCase_Rangecc(scheme, "gemini")) {
241 return prefs_App()->monospaceGemini;
242 }
243 if (equalCase_Rangecc(scheme, "gopher")) {
244 return prefs_App()->monospaceGopher;
245 }
246 return iFalse;
241} 247}
242#endif
243 248
244static void doLayout_GmDocument_(iGmDocument *d) { 249static void doLayout_GmDocument_(iGmDocument *d) {
245 const iBool isGemini = iTrue; // !isGopher_GmDocument_(d); 250 const iBool isMono = isForcedMonospace_GmDocument_(d);
246 /* TODO: Collect these parameters into a GmTheme. */ 251 /* TODO: Collect these parameters into a GmTheme. */
247 const int fonts[max_GmLineType] = { 252 const int fonts[max_GmLineType] = {
248 isGemini ? paragraph_FontId : preformatted_FontId, 253 isMono ? regularMonospace_FontId : paragraph_FontId,
249 isGemini ? paragraph_FontId : preformatted_FontId, /* bullet */ 254 isMono ? regularMonospace_FontId : paragraph_FontId, /* bullet */
250 preformatted_FontId, 255 preformatted_FontId,
251 quote_FontId, 256 isMono ? regularMonospace_FontId : quote_FontId,
252 isGemini ? heading1_FontId : preformatted_FontId, 257 heading1_FontId,
253 isGemini ? heading2_FontId : preformatted_FontId, 258 heading2_FontId,
254 isGemini ? heading3_FontId : preformatted_FontId, 259 heading3_FontId,
255 regular_FontId, 260 isMono ? regularMonospace_FontId : regular_FontId,
256 }; 261 };
257 static const int colors[max_GmLineType] = { 262 static const int colors[max_GmLineType] = {
258 tmParagraph_ColorId, 263 tmParagraph_ColorId,
@@ -292,7 +297,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
292 const iRangecc content = range_String(&d->source); 297 const iRangecc content = range_String(&d->source);
293 iRangecc contentLine = iNullRange; 298 iRangecc contentLine = iNullRange;
294 iInt2 pos = zero_I2(); 299 iInt2 pos = zero_I2();
295 iBool isFirstText = isGemini && prefs->bigFirstParagraph; 300 iBool isFirstText = prefs->bigFirstParagraph;
296 iBool addQuoteIcon = prefs->quoteIcon; 301 iBool addQuoteIcon = prefs->quoteIcon;
297 iBool isPreformat = iFalse; 302 iBool isPreformat = iFalse;
298 iRangecc preAltText = iNullRange; 303 iRangecc preAltText = iNullRange;
@@ -363,7 +368,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
363 addSiteBanner = iFalse; /* overrides the banner */ 368 addSiteBanner = iFalse; /* overrides the banner */
364 continue; 369 continue;
365 } 370 }
366 run.font = preFont; 371 run.font = (d->format == plainText_GmDocumentFormat ? regularMonospace_FontId : preFont);
367 indent = indents[type]; 372 indent = indents[type];
368 } 373 }
369 if (addSiteBanner) { 374 if (addSiteBanner) {
@@ -463,6 +468,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
463 : link->flags & mailto_GmLinkFlag 468 : link->flags & mailto_GmLinkFlag
464 ? envelope 469 ? envelope
465 : link->flags & remote_GmLinkFlag ? globe : arrow); 470 : link->flags & remote_GmLinkFlag ? globe : arrow);
471 icon.font = regular_FontId;
466 if (link->flags & remote_GmLinkFlag) { 472 if (link->flags & remote_GmLinkFlag) {
467 icon.visBounds.pos.x -= gap_Text / 2; 473 icon.visBounds.pos.x -= gap_Text / 2;
468 } 474 }
@@ -477,7 +483,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
477 /* Special formatting for the first paragraph (e.g., subtitle, introduction, or lede). */ 483 /* Special formatting for the first paragraph (e.g., subtitle, introduction, or lede). */
478 int bigCount = 0; 484 int bigCount = 0;
479 if (type == text_GmLineType && isFirstText) { 485 if (type == text_GmLineType && isFirstText) {
480 run.font = firstParagraph_FontId; 486 if (!isMono) run.font = firstParagraph_FontId;
481 run.color = tmFirstParagraph_ColorId; 487 run.color = tmFirstParagraph_ColorId;
482 bigCount = 15; /* max lines -- what if the whole document is one paragraph? */ 488 bigCount = 15; /* max lines -- what if the whole document is one paragraph? */
483 isFirstText = iFalse; 489 isFirstText = iFalse;
@@ -520,7 +526,7 @@ static void doLayout_GmDocument_(iGmDocument *d) {
520 trimStart_Rangecc(&runLine); 526 trimStart_Rangecc(&runLine);
521 pos.y += lineHeight_Text(run.font); 527 pos.y += lineHeight_Text(run.font);
522 if (--bigCount == 0) { 528 if (--bigCount == 0) {
523 run.font = paragraph_FontId; 529 run.font = fonts[text_GmLineType];
524 run.color = colors[text_GmLineType]; 530 run.color = colors[text_GmLineType];
525 } 531 }
526 } 532 }
diff --git a/src/prefs.c b/src/prefs.c
index 815dac52..5c73833e 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -33,6 +33,8 @@ void init_Prefs(iPrefs *d) {
33 d->quoteIcon = iTrue; 33 d->quoteIcon = iTrue;
34 d->font = nunito_TextFont; 34 d->font = nunito_TextFont;
35 d->headingFont = nunito_TextFont; 35 d->headingFont = nunito_TextFont;
36 d->monospaceGemini = iFalse;
37 d->monospaceGopher = iFalse;
36 d->lineWidth = 40; 38 d->lineWidth = 40;
37 d->bigFirstParagraph = iTrue; 39 d->bigFirstParagraph = iTrue;
38 d->sideIcon = iTrue; 40 d->sideIcon = iTrue;
diff --git a/src/prefs.h b/src/prefs.h
index bf642600..2488d43b 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -46,6 +46,8 @@ struct Impl_Prefs {
46 /* Content */ 46 /* Content */
47 enum iTextFont font; 47 enum iTextFont font;
48 enum iTextFont headingFont; 48 enum iTextFont headingFont;
49 iBool monospaceGemini;
50 iBool monospaceGopher;
49 int lineWidth; 51 int lineWidth;
50 iBool bigFirstParagraph; 52 iBool bigFirstParagraph;
51 iBool forceLineWrap; 53 iBool forceLineWrap;
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c
index 9c489123..1f0e7b4d 100644
--- a/src/ui/labelwidget.c
+++ b/src/ui/labelwidget.c
@@ -330,7 +330,7 @@ void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) {
330 updateSize_LabelWidget(d); 330 updateSize_LabelWidget(d);
331} 331}
332 332
333const iString *label_LabelWidget(const iLabelWidget *d) { 333const iString *text_LabelWidget(const iLabelWidget *d) {
334 return &d->label; 334 return &d->label;
335} 335}
336 336
diff --git a/src/ui/labelwidget.h b/src/ui/labelwidget.h
index 066c9b33..5b2efc42 100644
--- a/src/ui/labelwidget.h
+++ b/src/ui/labelwidget.h
@@ -38,7 +38,7 @@ void updateSize_LabelWidget (iLabelWidget *);
38void updateText_LabelWidget (iLabelWidget *, const iString *text); /* not resized */ 38void updateText_LabelWidget (iLabelWidget *, const iString *text); /* not resized */
39void updateTextCStr_LabelWidget (iLabelWidget *, const char *text); /* not resized */ 39void updateTextCStr_LabelWidget (iLabelWidget *, const char *text); /* not resized */
40 40
41const iString *label_LabelWidget (const iLabelWidget *); 41const iString *text_LabelWidget (const iLabelWidget *);
42const iString *command_LabelWidget (const iLabelWidget *); 42const iString *command_LabelWidget (const iLabelWidget *);
43 43
44iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command); 44iLabelWidget *newKeyMods_LabelWidget(const char *label, int key, int kmods, const char *command);
diff --git a/src/ui/text.c b/src/ui/text.c
index 1ff3fb12..15959150 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -213,15 +213,17 @@ static void initFonts_Text_(iText *d) {
213 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId }, 213 { &fontFiraMonoRegular_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId },
214 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, 214 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId },
215 /* content fonts */ 215 /* content fonts */
216 { regularFont, textSize, scaling, symbols_FontId }, 216 { regularFont, textSize, scaling, symbols_FontId },
217 { &fontFiraMonoRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId }, 217 { &fontFiraMonoRegular_Embedded, monoSize, 1.0f, monospaceSymbols_FontId },
218 { &fontFiraMonoRegular_Embedded, monoSize * 0.750f, 1.0f, monospaceSmallSymbols_FontId }, 218 { &fontFiraMonoRegular_Embedded, monoSize * 0.750f, 1.0f, monospaceSmallSymbols_FontId },
219 { regularFont, textSize * 1.200f, scaling, mediumSymbols_FontId }, 219 { regularFont, textSize * 1.200f, scaling, mediumSymbols_FontId },
220 { h3Font, textSize * 1.333f, scaling, bigSymbols_FontId }, 220 { h3Font, textSize * 1.333f, scaling, bigSymbols_FontId },
221 { italicFont, textSize, scaling, symbols_FontId }, 221 { italicFont, textSize, scaling, symbols_FontId },
222 { h12Font, textSize * 1.666f, h123Scaling, largeSymbols_FontId }, 222 { h12Font, textSize * 1.666f, h123Scaling, largeSymbols_FontId },
223 { h12Font, textSize * 2.000f, h123Scaling, hugeSymbols_FontId }, 223 { h12Font, textSize * 2.000f, h123Scaling, hugeSymbols_FontId },
224 { lightFont, textSize * 1.666f, scaling, largeSymbols_FontId }, 224 { lightFont, textSize * 1.666f, scaling, largeSymbols_FontId },
225 /* monospace content fonts */
226 { &fontFiraMonoRegular_Embedded, textSize, 0.8f, symbols_FontId },
225 /* symbol fonts */ 227 /* symbol fonts */
226 { &fontSymbola_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId }, 228 { &fontSymbola_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
227 { &fontSymbola_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 229 { &fontSymbola_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
diff --git a/src/ui/text.h b/src/ui/text.h
index 25312973..e95b75d2 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -44,7 +44,9 @@ enum iFontId {
44 italic_FontId, 44 italic_FontId,
45 largeBold_FontId, 45 largeBold_FontId,
46 hugeBold_FontId, 46 hugeBold_FontId,
47 largeLight_FontId, 47 largeLight_FontId,
48 /* monospace content fonts */
49 regularMonospace_FontId,
48 /* symbol fonts */ 50 /* symbol fonts */
49 defaultSymbols_FontId, 51 defaultSymbols_FontId,
50 defaultMediumSymbols_FontId, 52 defaultMediumSymbols_FontId,
diff --git a/src/ui/util.c b/src/ui/util.c
index bf044c03..98f0fb18 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -907,8 +907,15 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab
907void setToggle_Widget(iWidget *d, iBool active) { 907void setToggle_Widget(iWidget *d, iBool active) {
908 if (d) { 908 if (d) {
909 setFlags_Widget(d, selected_WidgetFlag, active); 909 setFlags_Widget(d, selected_WidgetFlag, active);
910 updateText_LabelWidget((iLabelWidget *) d, 910 iLabelWidget *label = (iLabelWidget *) d;
911 collectNewFormat_String("%s", isSelected_Widget(d) ? "YES" : "NO")); 911 if (!cmp_String(text_LabelWidget(label), "YES") ||
912 !cmp_String(text_LabelWidget(label), "NO")) {
913 updateText_LabelWidget((iLabelWidget *) d,
914 collectNewFormat_String("%s", isSelected_Widget(d) ? "YES" : "NO"));
915 }
916 else {
917 refresh_Widget(d);
918 }
912 } 919 }
913} 920}
914 921
@@ -1067,6 +1074,14 @@ iWidget *makePreferences_Widget(void) {
1067 fonts = new_Widget(); 1074 fonts = new_Widget();
1068 addFontButtons_(fonts, "font"); 1075 addFontButtons_(fonts, "font");
1069 addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 1076 addChildFlags_Widget(values, iClob(fonts), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1077 addChild_Widget(headings, iClob(makeHeading_Widget("Monospace body:")));
1078 iWidget *mono = new_Widget();
1079 /* TODO: Needs labels! */
1080 setTextCStr_LabelWidget(
1081 addChild_Widget(mono, iClob(makeToggle_Widget("prefs.mono.gemini"))), "Gemini");
1082 setTextCStr_LabelWidget(
1083 addChild_Widget(mono, iClob(makeToggle_Widget("prefs.mono.gopher"))), "Gopher");
1084 addChildFlags_Widget(values, iClob(mono), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1070 } 1085 }
1071 addChild_Widget(headings, iClob(makePadding_Widget(2 * gap_UI))); 1086 addChild_Widget(headings, iClob(makePadding_Widget(2 * gap_UI)));
1072 addChild_Widget(values, iClob(makePadding_Widget(2 * gap_UI))); 1087 addChild_Widget(values, iClob(makePadding_Widget(2 * gap_UI)));
@@ -1173,7 +1188,7 @@ static iBool handleBookmarkCreationCommands_SidebarWidget_(iWidget *editor, cons
1173 url, 1188 url,
1174 title, 1189 title,
1175 tags, 1190 tags,
1176 first_String(label_LabelWidget(findChild_Widget(editor, "bmed.icon")))); 1191 first_String(text_LabelWidget(findChild_Widget(editor, "bmed.icon"))));
1177 postCommand_App("bookmarks.changed"); 1192 postCommand_App("bookmarks.changed");
1178 } 1193 }
1179 destroy_Widget(editor); 1194 destroy_Widget(editor);