summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks.c17
-rw-r--r--src/bookmarks.h1
-rw-r--r--src/gmutil.c7
-rw-r--r--src/gmutil.h2
-rw-r--r--src/ui/color.c6
-rw-r--r--src/ui/color.h1
-rw-r--r--src/ui/documentwidget.c1
-rw-r--r--src/ui/lookupwidget.c2
-rw-r--r--src/ui/sidebarwidget.c27
-rw-r--r--src/ui/text.c32
-rw-r--r--src/ui/text.h6
-rw-r--r--src/ui/util.c23
-rw-r--r--src/ui/window.c11
13 files changed, 109 insertions, 27 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c
index e54c6239..7cf7f5a1 100644
--- a/src/bookmarks.c
+++ b/src/bookmarks.c
@@ -216,6 +216,23 @@ iBool remove_Bookmarks(iBookmarks *d, uint32_t id) {
216 return bm != NULL; 216 return bm != NULL;
217} 217}
218 218
219iBool updateBookmarkIcon_Bookmarks(iBookmarks *d, const iString *url, iChar icon) {
220 iBool changed = iFalse;
221 lock_Mutex(d->mtx);
222 const uint32_t id = findUrl_Bookmarks(d, url);
223 if (id) {
224 iBookmark *bm = get_Bookmarks(d, id);
225 if (!hasTag_Bookmark(bm, "remote")) {
226 if (icon != bm->icon) {
227 bm->icon = icon;
228 changed = iTrue;
229 }
230 }
231 }
232 unlock_Mutex(d->mtx);
233 return changed;
234}
235
219iBookmark *get_Bookmarks(iBookmarks *d, uint32_t id) { 236iBookmark *get_Bookmarks(iBookmarks *d, uint32_t id) {
220 return (iBookmark *) value_Hash(&d->bookmarks, id); 237 return (iBookmark *) value_Hash(&d->bookmarks, id);
221} 238}
diff --git a/src/bookmarks.h b/src/bookmarks.h
index 2975b082..26bd9a47 100644
--- a/src/bookmarks.h
+++ b/src/bookmarks.h
@@ -62,6 +62,7 @@ void requestFinished_Bookmarks (iBookmarks *, iGmRequest *req);
62void add_Bookmarks (iBookmarks *, const iString *url, const iString *title, 62void add_Bookmarks (iBookmarks *, const iString *url, const iString *title,
63 const iString *tags, iChar icon); 63 const iString *tags, iChar icon);
64iBool remove_Bookmarks (iBookmarks *, uint32_t id); 64iBool remove_Bookmarks (iBookmarks *, uint32_t id);
65iBool updateBookmarkIcon_Bookmarks (iBookmarks *, const iString *url, iChar icon);
65iBookmark * get_Bookmarks (iBookmarks *, uint32_t id); 66iBookmark * get_Bookmarks (iBookmarks *, uint32_t id);
66uint32_t findUrl_Bookmarks (const iBookmarks *, const iString *url); /* O(n) */ 67uint32_t findUrl_Bookmarks (const iBookmarks *, const iString *url); /* O(n) */
67 68
diff --git a/src/gmutil.c b/src/gmutil.c
index afca4978..cf96cfd8 100644
--- a/src/gmutil.c
+++ b/src/gmutil.c
@@ -315,7 +315,7 @@ void urlEncodeSpaces_String(iString *d) {
315 } 315 }
316} 316}
317 317
318const iString *feedEntryOpenCommand_String(const iString *url) { 318const iString *feedEntryOpenCommand_String(const iString *url, int newTab) {
319 if (!isEmpty_String(url)) { 319 if (!isEmpty_String(url)) {
320 iString *cmd = collectNew_String(); 320 iString *cmd = collectNew_String();
321 const size_t fragPos = indexOf_String(url, '#'); 321 const size_t fragPos = indexOf_String(url, '#');
@@ -323,14 +323,15 @@ const iString *feedEntryOpenCommand_String(const iString *url) {
323 iString *head = newRange_String( 323 iString *head = newRange_String(
324 (iRangecc){ constBegin_String(url) + fragPos + 1, constEnd_String(url) }); 324 (iRangecc){ constBegin_String(url) + fragPos + 1, constEnd_String(url) });
325 format_String(cmd, 325 format_String(cmd,
326 "open gotourlheading:%s url:%s", 326 "open newtab:%d gotourlheading:%s url:%s",
327 newTab,
327 cstr_String(head), 328 cstr_String(head),
328 cstr_Rangecc((iRangecc){ constBegin_String(url), 329 cstr_Rangecc((iRangecc){ constBegin_String(url),
329 constBegin_String(url) + fragPos })); 330 constBegin_String(url) + fragPos }));
330 delete_String(head); 331 delete_String(head);
331 } 332 }
332 else { 333 else {
333 format_String(cmd, "open url:%s", cstr_String(url)); 334 format_String(cmd, "open newtab:%d url:%s", newTab, cstr_String(url));
334 } 335 }
335 return cmd; 336 return cmd;
336 } 337 }
diff --git a/src/gmutil.h b/src/gmutil.h
index 88ed1f32..a9c8c42a 100644
--- a/src/gmutil.h
+++ b/src/gmutil.h
@@ -110,4 +110,4 @@ iString * makeFileUrl_String (const iString *localFilePath);
110const char * makeFileUrl_CStr (const char *localFilePath); 110const char * makeFileUrl_CStr (const char *localFilePath);
111void urlEncodeSpaces_String (iString *); 111void urlEncodeSpaces_String (iString *);
112 112
113const iString * feedEntryOpenCommand_String (const iString *url); /* checks fragment */ 113const iString * feedEntryOpenCommand_String (const iString *url, int newTab); /* checks fragment */
diff --git a/src/ui/color.c b/src/ui/color.c
index 7cbb468b..1bab8538 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -82,6 +82,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
82 copy_(uiText_ColorId, gray75_ColorId); 82 copy_(uiText_ColorId, gray75_ColorId);
83 copy_(uiTextPressed_ColorId, black_ColorId); 83 copy_(uiTextPressed_ColorId, black_ColorId);
84 copy_(uiTextStrong_ColorId, white_ColorId); 84 copy_(uiTextStrong_ColorId, white_ColorId);
85 copy_(uiTextDim_ColorId, gray75_ColorId);
85 copy_(uiTextSelected_ColorId, white_ColorId); 86 copy_(uiTextSelected_ColorId, white_ColorId);
86 copy_(uiTextFramelessHover_ColorId, white_ColorId); 87 copy_(uiTextFramelessHover_ColorId, white_ColorId);
87 copy_(uiTextDisabled_ColorId, gray25_ColorId); 88 copy_(uiTextDisabled_ColorId, gray25_ColorId);
@@ -126,6 +127,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
126 copy_(uiText_ColorId, gray75_ColorId); 127 copy_(uiText_ColorId, gray75_ColorId);
127 copy_(uiTextPressed_ColorId, black_ColorId); 128 copy_(uiTextPressed_ColorId, black_ColorId);
128 copy_(uiTextStrong_ColorId, white_ColorId); 129 copy_(uiTextStrong_ColorId, white_ColorId);
130 copy_(uiTextDim_ColorId, gray75_ColorId);
129 copy_(uiTextSelected_ColorId, white_ColorId); 131 copy_(uiTextSelected_ColorId, white_ColorId);
130 copy_(uiTextDisabled_ColorId, gray50_ColorId); 132 copy_(uiTextDisabled_ColorId, gray50_ColorId);
131 copy_(uiTextFramelessHover_ColorId, white_ColorId); 133 copy_(uiTextFramelessHover_ColorId, white_ColorId);
@@ -167,7 +169,8 @@ void setThemePalette_Color(enum iColorTheme theme) {
167 copy_(uiBackgroundPressed_ColorId, cyan_ColorId); 169 copy_(uiBackgroundPressed_ColorId, cyan_ColorId);
168 copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId); 170 copy_(uiBackgroundFramelessHover_ColorId, orange_ColorId);
169 copy_(uiText_ColorId, black_ColorId); 171 copy_(uiText_ColorId, black_ColorId);
170 copy_(uiTextStrong_ColorId, teal_ColorId); 172 copy_(uiTextStrong_ColorId, black_ColorId);
173 copy_(uiTextDim_ColorId, gray25_ColorId);
171 copy_(uiTextPressed_ColorId, black_ColorId); 174 copy_(uiTextPressed_ColorId, black_ColorId);
172 copy_(uiTextSelected_ColorId, black_ColorId); 175 copy_(uiTextSelected_ColorId, black_ColorId);
173 copy_(uiTextDisabled_ColorId, gray50_ColorId); 176 copy_(uiTextDisabled_ColorId, gray50_ColorId);
@@ -213,6 +216,7 @@ void setThemePalette_Color(enum iColorTheme theme) {
213 copy_(uiTextPressed_ColorId, black_ColorId); 216 copy_(uiTextPressed_ColorId, black_ColorId);
214 copy_(uiTextDisabled_ColorId, gray75_ColorId); 217 copy_(uiTextDisabled_ColorId, gray75_ColorId);
215 copy_(uiTextStrong_ColorId, black_ColorId); 218 copy_(uiTextStrong_ColorId, black_ColorId);
219 copy_(uiTextDim_ColorId, gray25_ColorId);
216 copy_(uiTextSelected_ColorId, black_ColorId); 220 copy_(uiTextSelected_ColorId, black_ColorId);
217 copy_(uiTextFramelessHover_ColorId, black_ColorId); 221 copy_(uiTextFramelessHover_ColorId, black_ColorId);
218 copy_(uiTextShortcut_ColorId, brown_ColorId); 222 copy_(uiTextShortcut_ColorId, brown_ColorId);
diff --git a/src/ui/color.h b/src/ui/color.h
index bc2f04f6..61da37c0 100644
--- a/src/ui/color.h
+++ b/src/ui/color.h
@@ -103,6 +103,7 @@ enum iColorId {
103 uiMarked_ColorId, 103 uiMarked_ColorId,
104 uiMatching_ColorId, 104 uiMatching_ColorId,
105 uiBackgroundUnfocusedSelection_ColorId, 105 uiBackgroundUnfocusedSelection_ColorId,
106 uiTextDim_ColorId,
106 107
107 /* content theme colors */ 108 /* content theme colors */
108 tmFirst_ColorId, 109 tmFirst_ColorId,
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index da66c65d..0a8197b5 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1181,6 +1181,7 @@ static void checkResponse_DocumentWidget_(iDocumentWidget *d) {
1181 "document.input.submit"); 1181 "document.input.submit");
1182 setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"), 1182 setSensitiveContent_InputWidget(findChild_Widget(dlg, "input"),
1183 statusCode == sensitiveInput_GmStatusCode); 1183 statusCode == sensitiveInput_GmStatusCode);
1184 updateTheme_DocumentWidget_(d);
1184 break; 1185 break;
1185 } 1186 }
1186 case categorySuccess_GmStatusCode: 1187 case categorySuccess_GmStatusCode:
diff --git a/src/ui/lookupwidget.c b/src/ui/lookupwidget.c
index b80170d2..284d518e 100644
--- a/src/ui/lookupwidget.c
+++ b/src/ui/lookupwidget.c
@@ -535,7 +535,7 @@ static void presentResults_LookupWidget_(iLookupWidget *d) {
535 cstr_String(&res->label), 535 cstr_String(&res->label),
536 uiText_ColorEscape, 536 uiText_ColorEscape,
537 cstr_String(&res->meta)); 537 cstr_String(&res->meta));
538 const iString *cmd = feedEntryOpenCommand_String(&res->url); 538 const iString *cmd = feedEntryOpenCommand_String(&res->url, 0);
539 if (cmd) { 539 if (cmd) {
540 set_String(&item->command, cmd); 540 set_String(&item->command, cmd);
541 } 541 }
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 6adf1d1b..317e74bd 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -524,7 +524,8 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, const iSidebarItem *it
524 break; 524 break;
525 } 525 }
526 case feeds_SidebarMode: { 526 case feeds_SidebarMode: {
527 postCommandString_App(feedEntryOpenCommand_String(&item->url)); 527 postCommandString_App(
528 feedEntryOpenCommand_String(&item->url, openTabMode_Sym(SDL_GetModState())));
528 break; 529 break;
529 } 530 }
530 case bookmarks_SidebarMode: 531 case bookmarks_SidebarMode:
@@ -898,7 +899,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
898 uiHeading_ColorEscape "IDENTITY NOTES", 899 uiHeading_ColorEscape "IDENTITY NOTES",
899 format_CStr("Notes about %s:", cstr_String(name_GmIdentity(ident))), 900 format_CStr("Notes about %s:", cstr_String(name_GmIdentity(ident))),
900 uiTextAction_ColorEscape "OK", 901 uiTextAction_ColorEscape "OK",
901 format_CStr("ident.setnotes ident:%p", ident)); 902 format_CStr("!ident.setnotes ident:%p ptr:%p", ident, d));
902 } 903 }
903 return iTrue; 904 return iTrue;
904 } 905 }
@@ -1173,8 +1174,9 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1173 } 1174 }
1174 else { 1175 else {
1175 const iBool isUnread = (d->indent != 0); 1176 const iBool isUnread = (d->indent != 0);
1177 const int titleFont = isUnread ? uiContentBold_FontId : uiContent_FontId;
1176 const int h1 = lineHeight_Text(uiLabel_FontId); 1178 const int h1 = lineHeight_Text(uiLabel_FontId);
1177 const int h2 = lineHeight_Text(uiContent_FontId); 1179 const int h2 = lineHeight_Text(titleFont);
1178 const int iconPad = 9 * gap_UI; 1180 const int iconPad = 9 * gap_UI;
1179 iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) }; 1181 iRect iconArea = { addY_I2(pos, 0), init_I2(iconPad, itemHeight) };
1180 if (isUnread) { 1182 if (isUnread) {
@@ -1198,7 +1200,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1198 deinit_String(&str); 1200 deinit_String(&str);
1199 } 1201 }
1200 /* Select the layout based on how the title fits. */ 1202 /* Select the layout based on how the title fits. */
1201 iInt2 titleSize = advanceRange_Text(uiContent_FontId, range_String(&d->label)); 1203 iInt2 titleSize = advanceRange_Text(titleFont, range_String(&d->label));
1202 const iInt2 metaSize = advanceRange_Text(uiLabel_FontId, range_String(&d->meta)); 1204 const iInt2 metaSize = advanceRange_Text(uiLabel_FontId, range_String(&d->meta));
1203 pos.x += iconPad; 1205 pos.x += iconPad;
1204 const int avail = width_Rect(itemRect) - iconPad - 3 * gap_UI; 1206 const int avail = width_Rect(itemRect) - iconPad - 3 * gap_UI;
@@ -1213,12 +1215,12 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1213 const char *endPos; 1215 const char *endPos;
1214 tryAdvance_Text( 1216 tryAdvance_Text(
1215 uiContent_FontId, range_String(&d->label), avail - skip, &endPos); 1217 uiContent_FontId, range_String(&d->label), avail - skip, &endPos);
1216 drawRange_Text(uiContent_FontId, 1218 drawRange_Text(titleFont,
1217 cur, 1219 cur,
1218 labelFg, 1220 labelFg,
1219 (iRangecc){ constBegin_String(&d->label), endPos }); 1221 (iRangecc){ constBegin_String(&d->label), endPos });
1220 if (endPos < constEnd_String(&d->label)) { 1222 if (endPos < constEnd_String(&d->label)) {
1221 drawRange_Text(uiContent_FontId, 1223 drawRange_Text(titleFont,
1222 addY_I2(pos, h2), labelFg, 1224 addY_I2(pos, h2), labelFg,
1223 (iRangecc){ endPos, constEnd_String(&d->label) }); 1225 (iRangecc){ endPos, constEnd_String(&d->label) });
1224 } 1226 }
@@ -1226,7 +1228,7 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1226 else { 1228 else {
1227 pos.y += (itemHeight - h1 - h2) / 2; 1229 pos.y += (itemHeight - h1 - h2) / 2;
1228 drawRange_Text(uiLabel_FontId, pos, fg, range_String(&d->meta)); 1230 drawRange_Text(uiLabel_FontId, pos, fg, range_String(&d->meta));
1229 drawRange_Text(uiContent_FontId, addY_I2(pos, h1), labelFg, range_String(&d->label)); 1231 drawRange_Text(titleFont, addY_I2(pos, h1), labelFg, range_String(&d->label));
1230 } 1232 }
1231 } 1233 }
1232 } 1234 }
@@ -1265,8 +1267,6 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1265 } 1267 }
1266 else if (sidebar->mode == history_SidebarMode) { 1268 else if (sidebar->mode == history_SidebarMode) {
1267 iBeginCollect(); 1269 iBeginCollect();
1268 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
1269 : uiText_ColorId;
1270 if (d->listItem.isSeparator) { 1270 if (d->listItem.isSeparator) {
1271 if (!isEmpty_String(&d->meta)) { 1271 if (!isEmpty_String(&d->meta)) {
1272 iInt2 drawPos = addY_I2(topLeft_Rect(itemRect), d->id); 1272 iInt2 drawPos = addY_I2(topLeft_Rect(itemRect), d->id);
@@ -1283,6 +1283,8 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1283 } 1283 }
1284 } 1284 }
1285 else { 1285 else {
1286 const int fg = isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
1287 : uiTextDim_ColorId;
1286 iUrl parts; 1288 iUrl parts;
1287 init_Url(&parts, &d->label); 1289 init_Url(&parts, &d->label);
1288 const iBool isAbout = equalCase_Rangecc(parts.scheme, "about"); 1290 const iBool isAbout = equalCase_Rangecc(parts.scheme, "about");
@@ -1315,11 +1317,14 @@ static void draw_SidebarItem_(const iSidebarItem *d, iPaint *p, iRect itemRect,
1315 2)); 1317 2));
1316 const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId 1318 const int metaFg = isHover ? permanent_ColorId | (isPressing ? uiTextPressed_ColorId
1317 : uiTextFramelessHover_ColorId) 1319 : uiTextFramelessHover_ColorId)
1318 : uiText_ColorId; 1320 : uiTextDim_ColorId;
1319 drawRange_Text( 1321 drawRange_Text(
1320 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon)); 1322 font, cPos, d->listItem.isSelected ? iconColor : metaFg, range_String(&icon));
1321 deinit_String(&icon); 1323 deinit_String(&icon);
1322 drawRange_Text(font, add_I2(cPos, init_I2(6 * gap_UI, 0)), fg, range_String(&d->label)); 1324 drawRange_Text(d->listItem.isSelected ? uiContentBold_FontId : font,
1325 add_I2(cPos, init_I2(6 * gap_UI, 0)),
1326 fg,
1327 range_String(&d->label));
1323 drawRange_Text(default_FontId, 1328 drawRange_Text(default_FontId,
1324 add_I2(cPos, init_I2(6 * gap_UI, lineHeight_Text(font))), 1329 add_I2(cPos, init_I2(6 * gap_UI, lineHeight_Text(font))),
1325 metaFg, 1330 metaFg,
diff --git a/src/ui/text.c b/src/ui/text.c
index 2ab40387..2b3e187d 100644
--- a/src/ui/text.c
+++ b/src/ui/text.c
@@ -130,10 +130,15 @@ static void init_Font(iFont *d, const iBlock *data, int height, float scale,
130 memset(d->indexTable, 0xff, sizeof(d->indexTable)); 130 memset(d->indexTable, 0xff, sizeof(d->indexTable));
131} 131}
132 132
133static void deinit_Font(iFont *d) { 133static void clearGlyphs_Font_(iFont *d) {
134 iForEach(Hash, i, &d->glyphs) { 134 iForEach(Hash, i, &d->glyphs) {
135 delete_Glyph((iGlyph *) i.value); 135 delete_Glyph((iGlyph *) i.value);
136 } 136 }
137 clear_Hash(&d->glyphs);
138}
139
140static void deinit_Font(iFont *d) {
141 clearGlyphs_Font_(d);
137 deinit_Hash(&d->glyphs); 142 deinit_Hash(&d->glyphs);
138 delete_Block(d->data); 143 delete_Block(d->data);
139} 144}
@@ -149,6 +154,8 @@ static uint32_t glyphIndex_Font_(iFont *d, iChar ch) {
149 return stbtt_FindGlyphIndex(&d->font, ch); 154 return stbtt_FindGlyphIndex(&d->font, ch);
150} 155}
151 156
157/*----------------------------------------------------------------------------------------------*/
158
152iDeclareType(Text) 159iDeclareType(Text)
153iDeclareType(CacheRow) 160iDeclareType(CacheRow)
154 161
@@ -224,7 +231,9 @@ static void initFonts_Text_(iText *d) {
224 int symbolsFont; 231 int symbolsFont;
225 } fontData[max_FontId] = { 232 } fontData[max_FontId] = {
226 { &fontSourceSansProRegular_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId }, 233 { &fontSourceSansProRegular_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
234 { &fontSourceSansProBold_Embedded, fontSize_UI, 1.0f, defaultSymbols_FontId },
227 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId }, 235 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
236 { &fontSourceSansProBold_Embedded, fontSize_UI * 1.125f, 1.0f, defaultMediumSymbols_FontId },
228 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId }, 237 { &fontSourceSansProRegular_Embedded, fontSize_UI * 1.666f, 1.0f, defaultLargeSymbols_FontId },
229 { &fontIosevkaTermExtended_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId }, 238 { &fontIosevkaTermExtended_Embedded, fontSize_UI * 0.866f, 1.0f, defaultSymbols_FontId },
230 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId }, 239 { &fontSourceSansProRegular_Embedded, textSize, scaling, symbols_FontId },
@@ -330,11 +339,15 @@ static void deinitFonts_Text_(iText *d) {
330 } 339 }
331} 340}
332 341
342static int maxGlyphHeight_Text_(const iText *d) {
343 return 2 * d->contentFontSize * fontSize_UI;
344}
345
333static void initCache_Text_(iText *d) { 346static void initCache_Text_(iText *d) {
334 init_Array(&d->cacheRows, sizeof(iCacheRow)); 347 init_Array(&d->cacheRows, sizeof(iCacheRow));
335 const int textSize = d->contentFontSize * fontSize_UI; 348 const int textSize = d->contentFontSize * fontSize_UI;
336 iAssert(textSize > 0); 349 iAssert(textSize > 0);
337 const iInt2 cacheDims = init_I2(16, 80); 350 const iInt2 cacheDims = init_I2(16, 40);
338 d->cacheSize = mul_I2(cacheDims, init1_I2(iMax(textSize, fontSize_UI))); 351 d->cacheSize = mul_I2(cacheDims, init1_I2(iMax(textSize, fontSize_UI)));
339 SDL_RendererInfo renderInfo; 352 SDL_RendererInfo renderInfo;
340 SDL_GetRendererInfo(d->render, &renderInfo); 353 SDL_GetRendererInfo(d->render, &renderInfo);
@@ -417,6 +430,14 @@ void setContentFontSize_Text(float fontSizeFactor) {
417 } 430 }
418} 431}
419 432
433static void resetCache_Text_(iText *d) {
434 deinitCache_Text_(d);
435 for (int i = 0; i < max_FontId; i++) {
436 clearGlyphs_Font_(&d->fonts[i]);
437 }
438 initCache_Text_(d);
439}
440
420void resetFonts_Text(void) { 441void resetFonts_Text(void) {
421 iText *d = &text_; 442 iText *d = &text_;
422 deinitFonts_Text_(d); 443 deinitFonts_Text_(d);
@@ -572,6 +593,13 @@ static const iGlyph *glyph_Font_(iFont *d, iChar ch) {
572 iGlyph *glyph = new_Glyph(ch); 593 iGlyph *glyph = new_Glyph(ch);
573 glyph->glyphIndex = glyphIndex; 594 glyph->glyphIndex = glyphIndex;
574 glyph->font = font; 595 glyph->font = font;
596 /* If the cache is running out of space, clear it and we'll recache what's needed currently. */
597 if (text_.cacheBottom > text_.cacheSize.y - maxGlyphHeight_Text_(&text_)) {
598#if !defined (NDEBUG)
599 printf("[Text] glyph cache is full, clearing!\n"); fflush(stdout);
600#endif
601 resetCache_Text_(&text_);
602 }
575 SDL_Texture *oldTarget = SDL_GetRenderTarget(text_.render); 603 SDL_Texture *oldTarget = SDL_GetRenderTarget(text_.render);
576 SDL_SetRenderTarget(text_.render, text_.cache); 604 SDL_SetRenderTarget(text_.render, text_.cache);
577 cache_Font_(font, glyph, 0); 605 cache_Font_(font, glyph, 0);
diff --git a/src/ui/text.h b/src/ui/text.h
index f78f570a..217bdd13 100644
--- a/src/ui/text.h
+++ b/src/ui/text.h
@@ -31,10 +31,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
31 31
32enum iFontId { 32enum iFontId {
33 default_FontId, 33 default_FontId,
34 defaultBold_FontId,
34 defaultMedium_FontId, 35 defaultMedium_FontId,
36 defaultMediumBold_FontId,
35 defaultLarge_FontId, 37 defaultLarge_FontId,
36 defaultMonospace_FontId, 38 defaultMonospace_FontId,
37 defaultContentSized_FontId, 39 defaultContentSized_FontId,
38 /* content fonts */ 40 /* content fonts */
39 regular_FontId, 41 regular_FontId,
40 monospace_FontId, 42 monospace_FontId,
@@ -96,10 +98,12 @@ enum iFontId {
96 98
97 /* UI fonts: */ 99 /* UI fonts: */
98 uiLabel_FontId = default_FontId, 100 uiLabel_FontId = default_FontId,
101 uiLabelBold_FontId = defaultBold_FontId,
99 uiLabelLarge_FontId = defaultLarge_FontId, 102 uiLabelLarge_FontId = defaultLarge_FontId,
100 uiShortcuts_FontId = default_FontId, 103 uiShortcuts_FontId = default_FontId,
101 uiInput_FontId = defaultMonospace_FontId, 104 uiInput_FontId = defaultMonospace_FontId,
102 uiContent_FontId = defaultMedium_FontId, 105 uiContent_FontId = defaultMedium_FontId,
106 uiContentBold_FontId = defaultMediumBold_FontId,
103 uiContentSymbols_FontId = defaultMediumSymbols_FontId, 107 uiContentSymbols_FontId = defaultMediumSymbols_FontId,
104 /* Document fonts: */ 108 /* Document fonts: */
105 paragraph_FontId = regular_FontId, 109 paragraph_FontId = regular_FontId,
diff --git a/src/ui/util.c b/src/ui/util.c
index 0361cd72..c626759a 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -872,12 +872,13 @@ iWidget *makeValueInput_Widget(iWidget *parent, const iString *initialValue, con
872 iWidget *div = new_Widget(); { 872 iWidget *div = new_Widget(); {
873 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 873 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
874 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 874 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
875 addChild_Widget( 875 iLabelWidget *accept = addChild_Widget(
876 div, 876 div,
877 iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK", 877 iClob(newKeyMods_LabelWidget(acceptLabel ? acceptLabel : uiTextAction_ColorEscape "OK",
878 SDLK_RETURN, 878 SDLK_RETURN,
879 0, 879 0,
880 "valueinput.accept"))); 880 "valueinput.accept")));
881 setFont_LabelWidget(accept, uiLabelBold_FontId);
881 } 882 }
882 addChild_Widget(dlg, iClob(div)); 883 addChild_Widget(dlg, iClob(div));
883 centerSheet_Widget(dlg); 884 centerSheet_Widget(dlg);
@@ -924,8 +925,12 @@ iWidget *makeQuestion_Widget(const char *title, const char *msg, const char *lab
924 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 925 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
925 for (size_t i = 0; i < count; ++i) { 926 for (size_t i = 0; i < count; ++i) {
926 /* The last one is the default option. */ 927 /* The last one is the default option. */
927 const int key = (i == count - 1 ? SDLK_RETURN : 0); 928 const int key = (i == count - 1 ? SDLK_RETURN : 0);
928 addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i]))); 929 iLabelWidget *btn =
930 addChild_Widget(div, iClob(newKeyMods_LabelWidget(labels[i], key, 0, commands[i])));
931 if (key) {
932 setFont_LabelWidget(btn, uiLabelBold_FontId);
933 }
929 } 934 }
930 } 935 }
931 addChild_Widget(dlg, iClob(div)); 936 addChild_Widget(dlg, iClob(div));
@@ -1168,7 +1173,10 @@ iWidget *makePreferences_Widget(void) {
1168 } 1173 }
1169 iWidget *div = new_Widget(); { 1174 iWidget *div = new_Widget(); {
1170 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1175 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1171 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))); 1176 setFont_LabelWidget(
1177 addChild_Widget(
1178 div, iClob(newKeyMods_LabelWidget("Dismiss", SDLK_ESCAPE, 0, "prefs.dismiss"))),
1179 uiLabelBold_FontId);
1172 } 1180 }
1173 addChild_Widget(dlg, iClob(div)); 1181 addChild_Widget(dlg, iClob(div));
1174 addChild_Widget(get_Window()->root, iClob(dlg)); 1182 addChild_Widget(get_Window()->root, iClob(dlg));
@@ -1205,10 +1213,11 @@ iWidget *makeBookmarkEditor_Widget(void) {
1205 iWidget *div = new_Widget(); { 1213 iWidget *div = new_Widget(); {
1206 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1214 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1207 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1215 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1208 addChild_Widget( 1216 iLabelWidget *accept = addChild_Widget(
1209 div, 1217 div,
1210 iClob(newKeyMods_LabelWidget( 1218 iClob(newKeyMods_LabelWidget(
1211 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept"))); 1219 uiTextCaution_ColorEscape "Save Bookmark", SDLK_RETURN, KMOD_PRIMARY, "bmed.accept")));
1220 setFont_LabelWidget(accept, uiLabelBold_FontId);
1212 } 1221 }
1213 addChild_Widget(dlg, iClob(div)); 1222 addChild_Widget(dlg, iClob(div));
1214 addChild_Widget(get_Window()->root, iClob(dlg)); 1223 addChild_Widget(get_Window()->root, iClob(dlg));
@@ -1345,6 +1354,7 @@ iWidget *makeFeedSettings_Widget(uint32_t bookmarkId) {
1345 KMOD_PRIMARY, 1354 KMOD_PRIMARY,
1346 format_CStr("feedcfg.accept bmid:%d", bookmarkId)))), 1355 format_CStr("feedcfg.accept bmid:%d", bookmarkId)))),
1347 "feedcfg.save"); 1356 "feedcfg.save");
1357 setFont_LabelWidget(findChild_Widget(div, "feedcfg.save"), uiLabelBold_FontId);
1348 } 1358 }
1349 addChild_Widget(dlg, iClob(div)); 1359 addChild_Widget(dlg, iClob(div));
1350 arrange_Widget(dlg); 1360 arrange_Widget(dlg);
@@ -1421,10 +1431,11 @@ iWidget *makeIdentityCreation_Widget(void) {
1421 iWidget *div = new_Widget(); { 1431 iWidget *div = new_Widget(); {
1422 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue); 1432 setFlags_Widget(div, arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag, iTrue);
1423 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel"))); 1433 addChild_Widget(div, iClob(newKeyMods_LabelWidget("Cancel", SDLK_ESCAPE, 0, "cancel")));
1424 addChild_Widget( 1434 iLabelWidget *accept = addChild_Widget(
1425 div, 1435 div,
1426 iClob(newKeyMods_LabelWidget( 1436 iClob(newKeyMods_LabelWidget(
1427 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept"))); 1437 uiTextAction_ColorEscape "Create Identity", SDLK_RETURN, KMOD_PRIMARY, "ident.accept")));
1438 setFont_LabelWidget(accept, uiLabelBold_FontId);
1428 } 1439 }
1429 addChild_Widget(dlg, iClob(div)); 1440 addChild_Widget(dlg, iClob(div));
1430 addChild_Widget(get_Window()->root, iClob(dlg)); 1441 addChild_Widget(get_Window()->root, iClob(dlg));
diff --git a/src/ui/window.c b/src/ui/window.c
index e1bb1c0b..c13d5843 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -27,6 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
27#include "documentwidget.h" 27#include "documentwidget.h"
28#include "sidebarwidget.h" 28#include "sidebarwidget.h"
29#include "lookupwidget.h" 29#include "lookupwidget.h"
30#include "bookmarks.h"
30#include "embedded.h" 31#include "embedded.h"
31#include "command.h" 32#include "command.h"
32#include "paint.h" 33#include "paint.h"
@@ -396,6 +397,14 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
396 setText_InputWidget(url, urlStr); 397 setText_InputWidget(url, urlStr);
397 checkLoadAnimation_Window_(get_Window()); 398 checkLoadAnimation_Window_(get_Window());
398 updateNavBarIdentity_(navBar); 399 updateNavBarIdentity_(navBar);
400 /* Icon updates should be limited to automatically chosen icons if the user
401 is allowed to pick their own in the future. */
402 if (updateBookmarkIcon_Bookmarks(
403 bookmarks_App(),
404 urlStr,
405 siteIcon_GmDocument(document_DocumentWidget(document_App())))) {
406 postCommand_App("bookmarks.changed");
407 }
399 return iFalse; 408 return iFalse;
400 } 409 }
401 else if (equal_Command(cmd, "document.request.cancelled")) { 410 else if (equal_Command(cmd, "document.request.cancelled")) {
@@ -960,7 +969,7 @@ void draw_Window(iWindow *d) {
960#if 0 969#if 0
961 /* Text cache debugging. */ { 970 /* Text cache debugging. */ {
962 SDL_Texture *cache = glyphCache_Text(); 971 SDL_Texture *cache = glyphCache_Text();
963 SDL_Rect rect = { d->root->rect.size.x - 640, 0, 640, 5 * 640 }; 972 SDL_Rect rect = { d->root->rect.size.x - 640, 0, 640, 2.5 * 640 };
964 SDL_SetRenderDrawColor(d->render, 0, 0, 0, 255); 973 SDL_SetRenderDrawColor(d->render, 0, 0, 0, 255);
965 SDL_RenderFillRect(d->render, &rect); 974 SDL_RenderFillRect(d->render, &rect);
966 SDL_RenderCopy(d->render, glyphCache_Text(), NULL, &rect); 975 SDL_RenderCopy(d->render, glyphCache_Text(), NULL, &rect);