summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-08-16 22:00:44 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-08-16 22:00:44 +0300
commit6ace08ae5a11e705a18c10da85f617532b4a9862 (patch)
treebb5cb46fa45221dffc677a10e6a5cca68effd0ee /src
parent69ea47be1cee7298b65db8104f1c88e51554ba48 (diff)
Keyboard-based link navigation; general improvements
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c152
-rw-r--r--src/ui/inputwidget.c2
-rw-r--r--src/ui/sidebarwidget.c16
-rw-r--r--src/ui/sidebarwidget.h2
-rw-r--r--src/ui/window.c12
5 files changed, 138 insertions, 46 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index eb126a0f..47d7f755 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -17,9 +17,9 @@
17#include <the_Foundation/ptrarray.h> 17#include <the_Foundation/ptrarray.h>
18#include <the_Foundation/regexp.h> 18#include <the_Foundation/regexp.h>
19#include <the_Foundation/stringarray.h> 19#include <the_Foundation/stringarray.h>
20
21#include <SDL_clipboard.h> 20#include <SDL_clipboard.h>
22#include <SDL_timer.h> 21#include <SDL_timer.h>
22#include <ctype.h>
23 23
24iDeclareClass(MediaRequest) 24iDeclareClass(MediaRequest)
25 25
@@ -130,6 +130,7 @@ struct Impl_DocumentWidget {
130 iPtrArray visibleLinks; 130 iPtrArray visibleLinks;
131 const iGmRun *hoverLink; 131 const iGmRun *hoverLink;
132 iBool noHoverWhileScrolling; 132 iBool noHoverWhileScrolling;
133 iBool showLinkNumbers;
133 iClick click; 134 iClick click;
134 float initialNormScrollY; 135 float initialNormScrollY;
135 int scrollY; 136 int scrollY;
@@ -165,6 +166,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
165 d->pageMargin = 5; 166 d->pageMargin = 5;
166 d->hoverLink = NULL; 167 d->hoverLink = NULL;
167 d->noHoverWhileScrolling = iFalse; 168 d->noHoverWhileScrolling = iFalse;
169 d->showLinkNumbers = iFalse;
168 d->arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); 170 d->arrowCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW);
169 d->beamCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM); 171 d->beamCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_IBEAM);
170 d->handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND); 172 d->handCursor = SDL_CreateSystemCursor(SDL_SYSTEM_CURSOR_HAND);
@@ -580,6 +582,19 @@ const iGmDocument *document_DocumentWidget(const iDocumentWidget *d) {
580 return d->doc; 582 return d->doc;
581} 583}
582 584
585static void parseUser_DocumentWidget_(iDocumentWidget *d) {
586 clear_String(d->titleUser);
587 iRegExp *userPats[2] = { new_RegExp("~([^/?]+)", 0),
588 new_RegExp("/users/([^/?]+)", caseInsensitive_RegExpOption) };
589 iRegExpMatch m;
590 iForIndices(i, userPats) {
591 if (matchString_RegExp(userPats[i], d->mod.url, &m)) {
592 setRange_String(d->titleUser, capturedRange_RegExpMatch(&m, 1));
593 }
594 iRelease(userPats[i]);
595 }
596}
597
583static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) { 598static iBool updateFromHistory_DocumentWidget_(iDocumentWidget *d) {
584 const iRecentUrl *recent = findUrl_History(d->mod.history, d->mod.url); 599 const iRecentUrl *recent = findUrl_History(d->mod.history, d->mod.url);
585 if (recent && recent->cachedResponse) { 600 if (recent && recent->cachedResponse) {
@@ -607,24 +622,15 @@ void serializeState_DocumentWidget(const iDocumentWidget *d, iStream *outs) {
607 622
608void deserializeState_DocumentWidget(iDocumentWidget *d, iStream *ins) { 623void deserializeState_DocumentWidget(iDocumentWidget *d, iStream *ins) {
609 deserialize_Model(&d->mod, ins); 624 deserialize_Model(&d->mod, ins);
625 parseUser_DocumentWidget_(d);
610 updateFromHistory_DocumentWidget_(d); 626 updateFromHistory_DocumentWidget_(d);
611} 627}
612 628
613void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) { 629void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) {
614 if (cmpStringSc_String(d->mod.url, url, &iCaseInsensitive)) { 630 if (cmpStringSc_String(d->mod.url, url, &iCaseInsensitive)) {
615 set_String(d->mod.url, url); 631 set_String(d->mod.url, url);
616 /* See if there a username in the URL. */ { 632 /* See if there a username in the URL. */
617 clear_String(d->titleUser); 633 parseUser_DocumentWidget_(d);
618 iRegExp *userPats[2] = { new_RegExp("~([^/?]+)", 0),
619 new_RegExp("/users/([^/?]+)", caseInsensitive_RegExpOption) };
620 iRegExpMatch m;
621 iForIndices(i, userPats) {
622 if (matchString_RegExp(userPats[i], d->mod.url, &m)) {
623 setRange_String(d->titleUser, capturedRange_RegExpMatch(&m, 1));
624 }
625 iRelease(userPats[i]);
626 }
627 }
628 if (!isFromCache || !updateFromHistory_DocumentWidget_(d)) { 634 if (!isFromCache || !updateFromHistory_DocumentWidget_(d)) {
629 fetch_DocumentWidget_(d); 635 fetch_DocumentWidget_(d);
630 } 636 }
@@ -869,6 +875,7 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
869 refresh_Widget(w); 875 refresh_Widget(w);
870 } 876 }
871 else if (equal_Command(cmd, "tabs.changed")) { 877 else if (equal_Command(cmd, "tabs.changed")) {
878 d->showLinkNumbers = iFalse;
872 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) { 879 if (cmp_String(id_Widget(w), suffixPtr_Command(cmd, "id")) == 0) {
873 /* Set palette for our document. */ 880 /* Set palette for our document. */
874 updateTheme_DocumentWidget_(d); 881 updateTheme_DocumentWidget_(d);
@@ -1062,6 +1069,21 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
1062 return iFalse; 1069 return iFalse;
1063} 1070}
1064 1071
1072static size_t visibleLinkOrdinal_DocumentWidget_(const iDocumentWidget *d, iGmLinkId linkId) {
1073 size_t ord = 0;
1074 const iRangei visRange = visibleRange_DocumentWidget_(d);
1075 iConstForEach(PtrArray, i, &d->visibleLinks) {
1076 const iGmRun *run = i.ptr;
1077 if (top_Rect(run->visBounds) >= visRange.start + gap_UI * d->pageMargin * 4 / 5) {
1078 if (run->flags & decoration_GmRunFlag && run->linkId) {
1079 if (run->linkId == linkId) return ord;
1080 ord++;
1081 }
1082 }
1083 }
1084 return iInvalidPos;
1085}
1086
1065static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *ev) { 1087static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *ev) {
1066 iWidget *w = as_Widget(d); 1088 iWidget *w = as_Widget(d);
1067 if (ev->type == SDL_USEREVENT && ev->user.code == command_UserEventCode) { 1089 if (ev->type == SDL_USEREVENT && ev->user.code == command_UserEventCode) {
@@ -1071,17 +1093,64 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1071 } 1093 }
1072 return iTrue; 1094 return iTrue;
1073 } 1095 }
1096 if (ev->type == SDL_KEYUP) {
1097 const int key = ev->key.keysym.sym;
1098 switch (key) {
1099 case SDLK_LALT:
1100 case SDLK_RALT:
1101 if (document_App() == d) {
1102 d->showLinkNumbers = iFalse;
1103 refresh_Widget(w);
1104 }
1105 break;
1106 }
1107 }
1074 if (ev->type == SDL_KEYDOWN) { 1108 if (ev->type == SDL_KEYDOWN) {
1075 const int mods = keyMods_Sym(ev->key.keysym.mod); 1109 const int mods = keyMods_Sym(ev->key.keysym.mod);
1076 const int key = ev->key.keysym.sym; 1110 const int key = ev->key.keysym.sym;
1111 if (d->showLinkNumbers && ((key >= '1' && key <= '9') ||
1112 (key >= 'a' && key <= 'z'))) {
1113 const size_t ord = isdigit(key) ? key - SDLK_1 : (key - 'a' + 9);
1114 iConstForEach(PtrArray, i, &d->visibleLinks) {
1115 const iGmRun *run = i.ptr;
1116 if (run->flags & decoration_GmRunFlag &&
1117 visibleLinkOrdinal_DocumentWidget_(d, run->linkId) == ord) {
1118 postCommandf_App("open newtab:%d url:%s",
1119 (SDL_GetModState() & KMOD_PRIMARY) != 0,
1120 cstr_String(linkUrl_GmDocument(d->doc, run->linkId)));
1121 return iTrue;
1122 }
1123 }
1124 }
1077 switch (key) { 1125 switch (key) {
1126 case SDLK_LALT:
1127 case SDLK_RALT:
1128 if (document_App() == d) {
1129 d->showLinkNumbers = iTrue;
1130 refresh_Widget(w);
1131 }
1132 break;
1133 case SDLK_1:
1134 case SDLK_2:
1135 case SDLK_3:
1136 case SDLK_4:
1137 case SDLK_5:
1138 case SDLK_6:
1139 case SDLK_7:
1140 case SDLK_8:
1141 case SDLK_9:
1142 if (mods == KMOD_ALT || mods == (KMOD_ALT | KMOD_PRIMARY)) {
1143 }
1144 break;
1078 case SDLK_HOME: 1145 case SDLK_HOME:
1079 d->scrollY = 0; 1146 d->scrollY = 0;
1147 scroll_DocumentWidget_(d, 0);
1080 updateVisible_DocumentWidget_(d); 1148 updateVisible_DocumentWidget_(d);
1081 refresh_Widget(w); 1149 refresh_Widget(w);
1082 return iTrue; 1150 return iTrue;
1083 case SDLK_END: 1151 case SDLK_END:
1084 d->scrollY = scrollMax_DocumentWidget_(d); 1152 d->scrollY = scrollMax_DocumentWidget_(d);
1153 scroll_DocumentWidget_(d, 0);
1085 updateVisible_DocumentWidget_(d); 1154 updateVisible_DocumentWidget_(d);
1086 refresh_Widget(w); 1155 refresh_Widget(w);
1087 return iTrue; 1156 return iTrue;
@@ -1098,6 +1167,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1098 case ' ': 1167 case ' ':
1099 postCommand_Widget(w, "scroll.page arg:%d", key == SDLK_PAGEUP ? -1 : +1); 1168 postCommand_Widget(w, "scroll.page arg:%d", key == SDLK_PAGEUP ? -1 : +1);
1100 return iTrue; 1169 return iTrue;
1170#if 0
1101 case SDLK_9: { 1171 case SDLK_9: {
1102 iBlock *seed = new_Block(64); 1172 iBlock *seed = new_Block(64);
1103 for (size_t i = 0; i < 64; ++i) { 1173 for (size_t i = 0; i < 64; ++i) {
@@ -1108,6 +1178,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1108 refresh_Widget(w); 1178 refresh_Widget(w);
1109 break; 1179 break;
1110 } 1180 }
1181#endif
1111#if 0 1182#if 0
1112 case '0': { 1183 case '0': {
1113 extern int enableHalfPixelGlyphs_Text; 1184 extern int enableHalfPixelGlyphs_Text;
@@ -1241,6 +1312,7 @@ struct Impl_DrawContext {
1241 iPaint paint; 1312 iPaint paint;
1242 iBool inSelectMark; 1313 iBool inSelectMark;
1243 iBool inFoundMark; 1314 iBool inFoundMark;
1315 iBool showLinkNumbers;
1244}; 1316};
1245 1317
1246static void fillRange_DrawContext_(iDrawContext *d, const iGmRun *run, enum iColorId color, 1318static void fillRange_DrawContext_(iDrawContext *d, const iGmRun *run, enum iColorId color,
@@ -1329,10 +1401,22 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1329 deinit_String(&bannerText); 1401 deinit_String(&bannerText);
1330 } 1402 }
1331 else { 1403 else {
1404 if (d->showLinkNumbers && run->linkId && run->flags & decoration_GmRunFlag) {
1405 const size_t ord = visibleLinkOrdinal_DocumentWidget_(d->widget, run->linkId);
1406 if (ord < 9 + 26) {
1407 const iChar ordChar = ord < 9 ? 0x278a + ord : (0x24b6 + ord - 9);
1408 drawString_Text(run->font,
1409 init_I2(left_Rect(d->bounds) - gap_UI / 2, visPos.y),
1410 fg,
1411 collect_String(newUnicodeN_String(&ordChar, 1)));
1412 goto runDrawn;
1413 }
1414 }
1332 drawRange_Text(run->font, visPos, fg, run->text); 1415 drawRange_Text(run->font, visPos, fg, run->text);
1416 runDrawn:;
1333 } 1417 }
1334 /* Presentation of links. */ 1418 /* Presentation of links. */
1335 if (run->linkId) { 1419 if (run->linkId && ~run->flags & decoration_GmRunFlag) {
1336 const int metaFont = paragraph_FontId; 1420 const int metaFont = paragraph_FontId;
1337 /* TODO: Show status of an ongoing media request. */ 1421 /* TODO: Show status of an ongoing media request. */
1338 const int flags = linkFlags_GmDocument(doc, run->linkId); 1422 const int flags = linkFlags_GmDocument(doc, run->linkId);
@@ -1341,24 +1425,23 @@ static void drawRun_DrawContext_(void *context, const iGmRun *run) {
1341 /* Show inline content. */ 1425 /* Show inline content. */
1342 if (flags & content_GmLinkFlag) { 1426 if (flags & content_GmLinkFlag) {
1343 fg = linkColor_GmDocument(doc, run->linkId, textHover_GmLinkPart); 1427 fg = linkColor_GmDocument(doc, run->linkId, textHover_GmLinkPart);
1344 if (!isEmpty_Rect(run->bounds)) { 1428 iAssert(!isEmpty_Rect(run->bounds));
1345 iGmImageInfo info; 1429 iGmImageInfo info;
1346 imageInfo_GmDocument(doc, linkImage_GmDocument(doc, run->linkId), &info); 1430 imageInfo_GmDocument(doc, linkImage_GmDocument(doc, run->linkId), &info);
1347 iString text; 1431 iString text;
1348 init_String(&text); 1432 init_String(&text);
1349 format_String(&text, "%s \u2014 %d x %d \u2014 %.1fMB", 1433 format_String(&text, "%s \u2014 %d x %d \u2014 %.1fMB",
1350 info.mime, info.size.x, info.size.y, info.numBytes / 1.0e6f); 1434 info.mime, info.size.x, info.size.y, info.numBytes / 1.0e6f);
1351 if (findMediaRequest_DocumentWidget_(d->widget, run->linkId)) { 1435 if (findMediaRequest_DocumentWidget_(d->widget, run->linkId)) {
1352 appendFormat_String( 1436 appendFormat_String(
1353 &text, " %s\u2a2f", isHover ? escape_Color(tmLinkText_ColorId) : ""); 1437 &text, " %s\u2a2f", isHover ? escape_Color(tmLinkText_ColorId) : "");
1354 }
1355 drawAlign_Text(metaFont,
1356 add_I2(topRight_Rect(run->bounds), origin),
1357 fg,
1358 right_Alignment,
1359 "%s", cstr_String(&text));
1360 deinit_String(&text);
1361 } 1438 }
1439 drawAlign_Text(metaFont,
1440 add_I2(topRight_Rect(run->bounds), origin),
1441 fg,
1442 right_Alignment,
1443 "%s", cstr_String(&text));
1444 deinit_String(&text);
1362 } 1445 }
1363 else if (run->flags & endOfLine_GmRunFlag && 1446 else if (run->flags & endOfLine_GmRunFlag &&
1364 (mr = findMediaRequest_DocumentWidget_(d->widget, run->linkId)) != NULL) { 1447 (mr = findMediaRequest_DocumentWidget_(d->widget, run->linkId)) != NULL) {
@@ -1440,13 +1523,18 @@ static void draw_DocumentWidget_(const iDocumentWidget *d) {
1440 .widget = d, 1523 .widget = d,
1441 .widgetBounds = /* omit scrollbar width */ 1524 .widgetBounds = /* omit scrollbar width */
1442 adjusted_Rect(bounds, zero_I2(), init_I2(-constAs_Widget(d->scroll)->rect.size.x, 0)), 1525 adjusted_Rect(bounds, zero_I2(), init_I2(-constAs_Widget(d->scroll)->rect.size.x, 0)),
1443 .bounds = documentBounds_DocumentWidget_(d) 1526 .bounds = documentBounds_DocumentWidget_(d),
1527 .showLinkNumbers = d->showLinkNumbers,
1444 }; 1528 };
1445 init_Paint(&ctx.paint); 1529 init_Paint(&ctx.paint);
1446 fillRect_Paint(&ctx.paint, bounds, tmBackground_ColorId); 1530 fillRect_Paint(&ctx.paint, bounds, tmBackground_ColorId);
1447 setClip_Paint(&ctx.paint, bounds); 1531 setClip_Paint(&ctx.paint, bounds);
1448 render_GmDocument(d->doc, visibleRange_DocumentWidget_(d), drawRun_DrawContext_, &ctx); 1532 render_GmDocument(d->doc, visibleRange_DocumentWidget_(d), drawRun_DrawContext_, &ctx);
1449 unsetClip_Paint(&ctx.paint); 1533 unsetClip_Paint(&ctx.paint);
1534// drawRect_Paint(&ctx.paint,
1535// moved_Rect((iRect){ zero_I2(), size_GmDocument(d->doc) },
1536// add_I2(topLeft_Rect(ctx.bounds), init_I2(0, -d->scrollY))),
1537// green_ColorId);
1450 draw_Widget(w); 1538 draw_Widget(w);
1451} 1539}
1452 1540
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index 8534c54f..d367952d 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -181,7 +181,7 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
181 setFocus_Widget(as_Widget(d)); 181 setFocus_Widget(as_Widget(d));
182 return iTrue; 182 return iTrue;
183 } 183 }
184 if (ev->type == SDL_KEYUP) { 184 if (ev->type == SDL_KEYUP && isFocused_Widget(w)) {
185 return iTrue; 185 return iTrue;
186 } 186 }
187 const size_t curMax = iMin(size_Array(&d->text), d->maxLen - 1); 187 const size_t curMax = iMin(size_Array(&d->text), d->maxLen - 1);
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index ed2e1fd8..de576f72 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -166,7 +166,7 @@ void setMode_SidebarWidget(iSidebarWidget *d, enum iSidebarMode mode) {
166 for (enum iSidebarMode i = 0; i < max_SidebarMode; i++) { 166 for (enum iSidebarMode i = 0; i < max_SidebarMode; i++) {
167 setFlags_Widget(as_Widget(d->modeButtons[i]), selected_WidgetFlag, i == d->mode); 167 setFlags_Widget(as_Widget(d->modeButtons[i]), selected_WidgetFlag, i == d->mode);
168 } 168 }
169 const float heights[max_SidebarMode] = { 1.2f, 1.5f, 3, 3 }; 169 const float heights[max_SidebarMode] = { 1.5f, 3, 3, 1.2f };
170 d->itemHeight = heights[mode] * lineHeight_Text(default_FontId); 170 d->itemHeight = heights[mode] * lineHeight_Text(default_FontId);
171} 171}
172 172
@@ -179,17 +179,17 @@ int width_SidebarWidget(const iSidebarWidget *d) {
179} 179}
180 180
181static const char *normalModeLabels_[max_SidebarMode] = { 181static const char *normalModeLabels_[max_SidebarMode] = {
182 "\U0001f5b9 Outline",
183 "\U0001f588 Bookmarks", 182 "\U0001f588 Bookmarks",
184 "\U0001f553 History", 183 "\U0001f553 History",
185 "\U0001f464 Identities", 184 "\U0001f464 Identities",
185 "\U0001f5b9 Outline",
186}; 186};
187 187
188static const char *tightModeLabels_[max_SidebarMode] = { 188static const char *tightModeLabels_[max_SidebarMode] = {
189 "\U0001f5b9",
190 "\U0001f588", 189 "\U0001f588",
191 "\U0001f553", 190 "\U0001f553",
192 "\U0001f464", 191 "\U0001f464",
192 "\U0001f5b9",
193}; 193};
194 194
195void init_SidebarWidget(iSidebarWidget *d) { 195void init_SidebarWidget(iSidebarWidget *d) {
@@ -496,10 +496,14 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
496 const iBool isPressing = d->click.isActive && contains_Rect(bounds, pos_Click(&d->click)); 496 const iBool isPressing = d->click.isActive && contains_Rect(bounds, pos_Click(&d->click));
497 iPaint p; 497 iPaint p;
498 init_Paint(&p); 498 init_Paint(&p);
499 fillRect_Paint(&p,
500 bounds_Widget(w),
501 d->mode == documentOutline_SidebarMode ? tmBackground_ColorId
502 : uiBackground_ColorId);
499 /* Draw the items. */ { 503 /* Draw the items. */ {
500 const int font = default_FontId; 504 const int font = default_FontId;
501 const iRanges visRange = visRange_SidebarWidget_(d); 505 const iRanges visRange = visRange_SidebarWidget_(d);
502 iInt2 pos = addY_I2(topLeft_Rect(bounds), -(d->scrollY % d->itemHeight)); 506 iInt2 pos = addY_I2(topLeft_Rect(bounds), -(d->scrollY % d->itemHeight));
503 for (size_t i = visRange.start; i < visRange.end; i++) { 507 for (size_t i = visRange.start; i < visRange.end; i++) {
504 const iSidebarItem *item = constAt_Array(&d->items, i); 508 const iSidebarItem *item = constAt_Array(&d->items, i);
505 const iRect itemRect = { pos, init_I2(width_Rect(bounds), d->itemHeight) }; 509 const iRect itemRect = { pos, init_I2(width_Rect(bounds), d->itemHeight) };
@@ -514,7 +518,7 @@ static void draw_SidebarWidget_(const iSidebarWidget *d) {
514 if (d->mode == documentOutline_SidebarMode) { 518 if (d->mode == documentOutline_SidebarMode) {
515 const int fg = 519 const int fg =
516 isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId) 520 isHover ? (isPressing ? uiTextPressed_ColorId : uiTextFramelessHover_ColorId)
517 : (item->indent == 0 ? uiTextStrong_ColorId : uiText_ColorId); 521 : (tmHeading1_ColorId + item->indent / (4 * gap_UI));
518 drawRange_Text(font, init_I2(pos.x + 3 * gap_UI + item->indent, 522 drawRange_Text(font, init_I2(pos.x + 3 * gap_UI + item->indent,
519 mid_Rect(itemRect).y - lineHeight_Text(font) / 2), 523 mid_Rect(itemRect).y - lineHeight_Text(font) / 2),
520 fg, range_String(&item->label)); 524 fg, range_String(&item->label));
diff --git a/src/ui/sidebarwidget.h b/src/ui/sidebarwidget.h
index 1645207e..3ff20b7f 100644
--- a/src/ui/sidebarwidget.h
+++ b/src/ui/sidebarwidget.h
@@ -3,10 +3,10 @@
3#include "widget.h" 3#include "widget.h"
4 4
5enum iSidebarMode { 5enum iSidebarMode {
6 documentOutline_SidebarMode,
7 bookmarks_SidebarMode, 6 bookmarks_SidebarMode,
8 history_SidebarMode, 7 history_SidebarMode,
9 identities_SidebarMode, 8 identities_SidebarMode,
9 documentOutline_SidebarMode,
10 max_SidebarMode 10 max_SidebarMode
11}; 11};
12 12
diff --git a/src/ui/window.c b/src/ui/window.c
index 75c848e1..71d383ab 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -74,7 +74,7 @@ static const iMenuItem navMenuItems[] = {
74 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" }, 74 { "Copy Source Text", SDLK_c, KMOD_PRIMARY, "copy" },
75 { "Bookmark This Page", SDLK_d, KMOD_PRIMARY, "bookmark.add" }, 75 { "Bookmark This Page", SDLK_d, KMOD_PRIMARY, "bookmark.add" },
76 { "---", 0, 0, NULL }, 76 { "---", 0, 0, NULL },
77 { "Toggle Sidebar", SDLK_s, KMOD_PRIMARY | KMOD_ALT, "sidebar.toggle" }, 77 { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
78 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" }, 78 { "Zoom In", SDLK_EQUALS, KMOD_PRIMARY, "zoom.delta arg:10" },
79 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" }, 79 { "Zoom Out", SDLK_MINUS, KMOD_PRIMARY, "zoom.delta arg:-10" },
80 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" }, 80 { "Reset Zoom", SDLK_0, KMOD_PRIMARY, "zoom.set arg:100" },
@@ -99,11 +99,11 @@ static const iMenuItem editMenuItems[] = {
99}; 99};
100 100
101static const iMenuItem viewMenuItems[] = { 101static const iMenuItem viewMenuItems[] = {
102 { "Show Page Outline", '1', KMOD_PRIMARY, "sidebar.mode arg:0 show:1" }, 102 { "Show Bookmarks", '1', KMOD_PRIMARY, "sidebar.mode arg:0 show:1" },
103 { "Show Bookmarks", '2', KMOD_PRIMARY, "sidebar.mode arg:1 show:1" }, 103 { "Show History", '2', KMOD_PRIMARY, "sidebar.mode arg:1 show:1" },
104 { "Show History", '3', KMOD_PRIMARY, "sidebar.mode arg:2 show:1" }, 104 { "Show Identities", '3', KMOD_PRIMARY, "sidebar.mode arg:2 show:1" },
105 { "Show Identities", '4', KMOD_PRIMARY, "sidebar.mode arg:3 show:1" }, 105 { "Show Page Outline", '4', KMOD_PRIMARY, "sidebar.mode arg:3 show:1" },
106 { "Toggle Sidebar", SDLK_s, KMOD_PRIMARY | KMOD_ALT, "sidebar.toggle" }, 106 { "Toggle Sidebar", SDLK_l, KMOD_PRIMARY | KMOD_SHIFT, "sidebar.toggle" },
107 { "---", 0, 0, NULL }, 107 { "---", 0, 0, NULL },
108 { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" }, 108 { "Go Back", SDLK_LEFTBRACKET, KMOD_PRIMARY, "navigate.back" },
109 { "Go Forward", SDLK_RIGHTBRACKET, KMOD_PRIMARY, "navigate.forward" }, 109 { "Go Forward", SDLK_RIGHTBRACKET, KMOD_PRIMARY, "navigate.forward" },