summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/about/version.gmi5
-rw-r--r--src/app.c4
-rw-r--r--src/gmdocument.c6
-rw-r--r--src/ui/documentwidget.c36
-rw-r--r--src/ui/util.c5
-rw-r--r--src/ui/util.h1
6 files changed, 36 insertions, 21 deletions
diff --git a/res/about/version.gmi b/res/about/version.gmi
index 0d0835da..28263653 100644
--- a/res/about/version.gmi
+++ b/res/about/version.gmi
@@ -7,9 +7,10 @@
7# Release notes 7# Release notes
8 8
9## 1.0 9## 1.0
10* Export bookmarks via "about:bookmarks". 10* Export bookmarks via "about:bookmarks". Added a menu item for showing this page.
11* Listing all bookmarks by tag or creation time. 11* Listing all bookmarks by tag or creation time.
12* Import all links on page as bookmark. 12* Import all links on page as bookmarks.
13* Open links with an unrecognized scheme in the default browser.
13 14
14## 0.13.2 15## 0.13.2
15* Added a little spinner to indicate ongoing requests. 16* Added a little spinner to indicate ongoing requests.
diff --git a/src/app.c b/src/app.c
index ae21d078..12d4024d 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1195,7 +1195,7 @@ iBool handleCommand_App(const char *cmd) {
1195 const iBool noProxy = argLabel_Command(cmd, "noproxy"); 1195 const iBool noProxy = argLabel_Command(cmd, "noproxy");
1196 iUrl parts; 1196 iUrl parts;
1197 init_Url(&parts, url); 1197 init_Url(&parts, url);
1198 if (equalCase_Rangecc(parts.scheme, "mailto") || 1198 if (argLabel_Command(cmd, "default") || equalCase_Rangecc(parts.scheme, "mailto") ||
1199 ((noProxy || isEmpty_String(&d->prefs.httpProxy)) && 1199 ((noProxy || isEmpty_String(&d->prefs.httpProxy)) &&
1200 (equalCase_Rangecc(parts.scheme, "http") || 1200 (equalCase_Rangecc(parts.scheme, "http") ||
1201 equalCase_Rangecc(parts.scheme, "https")))) { 1201 equalCase_Rangecc(parts.scheme, "https")))) {
@@ -1205,7 +1205,7 @@ iBool handleCommand_App(const char *cmd) {
1205 iDocumentWidget *doc = document_Command(cmd); 1205 iDocumentWidget *doc = document_Command(cmd);
1206 const int newTab = argLabel_Command(cmd, "newtab"); 1206 const int newTab = argLabel_Command(cmd, "newtab");
1207 if (newTab) { 1207 if (newTab) {
1208 doc = newTab_App(NULL, (newTab & 1) != 0); /* newtab:2 to open in background */ 1208 doc = newTab_App(NULL, (newTab & 1) != 0); /* "newtab:2" to open in background */
1209 } 1209 }
1210 iHistory *history = history_DocumentWidget(doc); 1210 iHistory *history = history_DocumentWidget(doc);
1211 const iBool isHistory = argLabel_Command(cmd, "history") != 0; 1211 const iBool isHistory = argLabel_Command(cmd, "history") != 0;
diff --git a/src/gmdocument.c b/src/gmdocument.c
index d01ba0b9..1f8ecb75 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -1365,9 +1365,9 @@ enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum
1365 const iGmLink *link = link_GmDocument_(d, linkId); 1365 const iGmLink *link = link_GmDocument_(d, linkId);
1366 const int www_GmLinkFlag = http_GmLinkFlag | mailto_GmLinkFlag; 1366 const int www_GmLinkFlag = http_GmLinkFlag | mailto_GmLinkFlag;
1367 if (link) { 1367 if (link) {
1368 const iBool isBad = (link->flags & supportedProtocol_GmLinkFlag) == 0; 1368 const iBool isUnsupported = (link->flags & supportedProtocol_GmLinkFlag) == 0;
1369 if (part == icon_GmLinkPart) { 1369 if (part == icon_GmLinkPart) {
1370 if (isBad) { 1370 if (isUnsupported) {
1371 return tmBadLink_ColorId; 1371 return tmBadLink_ColorId;
1372 } 1372 }
1373 if (link->flags & visited_GmLinkFlag) { 1373 if (link->flags & visited_GmLinkFlag) {
@@ -1394,7 +1394,7 @@ enum iColorId linkColor_GmDocument(const iGmDocument *d, iGmLinkId linkId, enum
1394 : tmLinkTextHover_ColorId; 1394 : tmLinkTextHover_ColorId;
1395 } 1395 }
1396 if (part == domain_GmLinkPart) { 1396 if (part == domain_GmLinkPart) {
1397 if (isBad) { 1397 if (isUnsupported) {
1398 return tmBadLink_ColorId; 1398 return tmBadLink_ColorId;
1399 } 1399 }
1400 return link->flags & www_GmLinkFlag 1400 return link->flags & www_GmLinkFlag
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 22fa29f8..3f3e453a 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -370,7 +370,7 @@ static void addVisible_DocumentWidget_(void *context, const iGmRun *run) {
370 if (run->audioId) { 370 if (run->audioId) {
371 pushBack_PtrArray(&d->visiblePlayers, run); 371 pushBack_PtrArray(&d->visiblePlayers, run);
372 } 372 }
373 if (run->linkId && linkFlags_GmDocument(d->doc, run->linkId) & supportedProtocol_GmLinkFlag) { 373 if (run->linkId) {
374 pushBack_PtrArray(&d->visibleLinks, run); 374 pushBack_PtrArray(&d->visibleLinks, run);
375 } 375 }
376} 376}
@@ -2147,13 +2147,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2147 const iGmRun *run = i.ptr; 2147 const iGmRun *run = i.ptr;
2148 if (run->flags & decoration_GmRunFlag && 2148 if (run->flags & decoration_GmRunFlag &&
2149 visibleLinkOrdinal_DocumentWidget_(d, run->linkId) == ord) { 2149 visibleLinkOrdinal_DocumentWidget_(d, run->linkId) == ord) {
2150 const int kmods = keyMods_Sym(SDL_GetModState());
2151 postCommandf_App("open newtab:%d url:%s", 2150 postCommandf_App("open newtab:%d url:%s",
2152 ((kmods & KMOD_PRIMARY) && (kmods & KMOD_SHIFT)) ? 1 2151 openTabMode_Sym(SDL_GetModState()),
2153 : (kmods & KMOD_PRIMARY) ? 2
2154 : 0,
2155 cstr_String(absoluteUrl_String( 2152 cstr_String(absoluteUrl_String(
2156 d->mod.url, linkUrl_GmDocument(d->doc, run->linkId)))); 2153 d->mod.url, linkUrl_GmDocument(d->doc, run->linkId))));
2157 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iFalse); 2154 iChangeFlags(d->flags, showLinkNumbers_DocumentWidgetFlag, iFalse);
2158 invalidateVisibleLinks_DocumentWidget_(d); 2155 invalidateVisibleLinks_DocumentWidget_(d);
2159 refresh_Widget(d); 2156 refresh_Widget(d);
@@ -2315,7 +2312,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2315 &(iMenuItem){ "Open Link in Default Browser", 2312 &(iMenuItem){ "Open Link in Default Browser",
2316 0, 2313 0,
2317 0, 2314 0,
2318 format_CStr("!open url:%s", cstr_String(linkUrl)) }); 2315 format_CStr("!open default:1 url:%s", cstr_String(linkUrl)) });
2319 } 2316 }
2320 if (willUseProxy_App(scheme)) { 2317 if (willUseProxy_App(scheme)) {
2321 pushBackN_Array( 2318 pushBackN_Array(
@@ -2437,10 +2434,10 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2437 setFocus_Widget(NULL); 2434 setFocus_Widget(NULL);
2438 if (d->hoverLink) { 2435 if (d->hoverLink) {
2439 const iGmLinkId linkId = d->hoverLink->linkId; 2436 const iGmLinkId linkId = d->hoverLink->linkId;
2437 const int linkFlags = linkFlags_GmDocument(d->doc, linkId);
2440 iAssert(linkId); 2438 iAssert(linkId);
2441 /* Media links are opened inline by default. */ 2439 /* Media links are opened inline by default. */
2442 if (isMediaLink_GmDocument(d->doc, linkId)) { 2440 if (isMediaLink_GmDocument(d->doc, linkId)) {
2443 const int linkFlags = linkFlags_GmDocument(d->doc, linkId);
2444 if (linkFlags & content_GmLinkFlag && linkFlags & permanent_GmLinkFlag) { 2441 if (linkFlags & content_GmLinkFlag && linkFlags & permanent_GmLinkFlag) {
2445 /* We have the content and it cannot be dismissed, so nothing 2442 /* We have the content and it cannot be dismissed, so nothing
2446 further to do. */ 2443 further to do. */
@@ -2490,15 +2487,26 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
2490 } 2487 }
2491 refresh_Widget(w); 2488 refresh_Widget(w);
2492 } 2489 }
2493 else { 2490 else if (linkFlags & supportedProtocol_GmLinkFlag) {
2494 const int kmods = keyMods_Sym(SDL_GetModState());
2495 postCommandf_App("open newtab:%d url:%s", 2491 postCommandf_App("open newtab:%d url:%s",
2496 ((kmods & KMOD_PRIMARY) && (kmods & KMOD_SHIFT)) ? 1 2492 openTabMode_Sym(SDL_GetModState()),
2497 : (kmods & KMOD_PRIMARY) ? 2
2498 : 0,
2499 cstr_String(absoluteUrl_String( 2493 cstr_String(absoluteUrl_String(
2500 d->mod.url, linkUrl_GmDocument(d->doc, linkId)))); 2494 d->mod.url, linkUrl_GmDocument(d->doc, linkId))));
2501 } 2495 }
2496 else {
2497 const iString *url = absoluteUrl_String(
2498 d->mod.url, linkUrl_GmDocument(d->doc, linkId));
2499 makeQuestion_Widget(
2500 uiTextCaution_ColorEscape "OPEN LINK",
2501 format_CStr(
2502 "Open this link in the default browser?\n" uiTextAction_ColorEscape
2503 "%s",
2504 cstr_String(url)),
2505 (const char *[]){ "Cancel", uiTextCaution_ColorEscape "Open Link" },
2506 (const char *[]){
2507 "cancel", format_CStr("!open default:1 url:%s", cstr_String(url)) },
2508 2);
2509 }
2502 } 2510 }
2503 if (d->selectMark.start) { 2511 if (d->selectMark.start) {
2504 d->selectMark = iNullRange; 2512 d->selectMark = iNullRange;
diff --git a/src/ui/util.c b/src/ui/util.c
index b6378055..855f0fb3 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -135,6 +135,11 @@ int keyMods_Sym(int kmods) {
135 return kmods; 135 return kmods;
136} 136}
137 137
138int openTabMode_Sym(int kmods) {
139 const int km = keyMods_Sym(kmods);
140 return ((km & KMOD_PRIMARY) && (km & KMOD_SHIFT)) ? 1 : (km & KMOD_PRIMARY) ? 2 : 0;
141}
142
138iRangei intersect_Rangei(iRangei a, iRangei b) { 143iRangei intersect_Rangei(iRangei a, iRangei b) {
139 if (a.end < b.start || a.start > b.end) { 144 if (a.end < b.start || a.start > b.end) {
140 return (iRangei){ 0, 0 }; 145 return (iRangei){ 0, 0 };
diff --git a/src/ui/util.h b/src/ui/util.h
index c9f464ad..a280fedb 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -52,6 +52,7 @@ iBool isMod_Sym (int key);
52int normalizedMod_Sym (int key); 52int normalizedMod_Sym (int key);
53int keyMods_Sym (int kmods); /* shift, alt, control, or gui */ 53int keyMods_Sym (int kmods); /* shift, alt, control, or gui */
54void toString_Sym (int key, int kmods, iString *str); 54void toString_Sym (int key, int kmods, iString *str);
55int openTabMode_Sym (int kmods);
55 56
56iRangei intersect_Rangei (iRangei a, iRangei b); 57iRangei intersect_Rangei (iRangei a, iRangei b);
57iRangei union_Rangei (iRangei a, iRangei b); 58iRangei union_Rangei (iRangei a, iRangei b);