summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.c15
-rw-r--r--src/app.h1
-rw-r--r--src/ui/documentwidget.c52
3 files changed, 53 insertions, 15 deletions
diff --git a/src/app.c b/src/app.c
index 3a86150f..354d34d6 100644
--- a/src/app.c
+++ b/src/app.c
@@ -880,6 +880,18 @@ static iBool handleIdentityCreationCommands_(iWidget *dlg, const char *cmd) {
880 return iFalse; 880 return iFalse;
881} 881}
882 882
883iBool willUseProxy_App(const iRangecc scheme) {
884 iApp *d = &app_;
885 if (!isEmpty_String(&d->prefs.httpProxy) && (equalCase_Rangecc(scheme, "http") ||
886 equalCase_Rangecc(scheme, "https"))) {
887 return iTrue;
888 }
889 if (!isEmpty_String(&d->prefs.gopherProxy) && equalCase_Rangecc(scheme, "gopher")) {
890 return iTrue;
891 }
892 return iFalse;
893}
894
883iBool handleCommand_App(const char *cmd) { 895iBool handleCommand_App(const char *cmd) {
884 iApp *d = &app_; 896 iApp *d = &app_;
885 if (equal_Command(cmd, "prefs.dialogtab")) { 897 if (equal_Command(cmd, "prefs.dialogtab")) {
@@ -996,7 +1008,8 @@ iBool handleCommand_App(const char *cmd) {
996 else if (equal_Command(cmd, "proxy.http")) { 1008 else if (equal_Command(cmd, "proxy.http")) {
997 setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address")); 1009 setCStr_String(&d->prefs.httpProxy, suffixPtr_Command(cmd, "address"));
998 return iTrue; 1010 return iTrue;
999 } else if (equal_Command(cmd, "downloads")) { 1011 }
1012 else if (equal_Command(cmd, "downloads")) {
1000 setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path")); 1013 setCStr_String(&d->prefs.downloadDir, suffixPtr_Command(cmd, "path"));
1001 return iTrue; 1014 return iTrue;
1002 } 1015 }
diff --git a/src/app.h b/src/app.h
index bf310d98..9c4bb669 100644
--- a/src/app.h
+++ b/src/app.h
@@ -64,6 +64,7 @@ iBool forceLineWrap_App (void);
64iBool forceSoftwareRender_App(void); 64iBool forceSoftwareRender_App(void);
65enum iColorTheme colorTheme_App (void); 65enum iColorTheme colorTheme_App (void);
66const iString * schemeProxy_App (iRangecc scheme); 66const iString * schemeProxy_App (iRangecc scheme);
67iBool willUseProxy_App (const iRangecc scheme);
67 68
68iGmCerts * certs_App (void); 69iGmCerts * certs_App (void);
69iVisited * visited_App (void); 70iVisited * visited_App (void);
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 423dee6d..13f21df6 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -1906,20 +1906,44 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e
1906 init_Array(&items, sizeof(iMenuItem)); 1906 init_Array(&items, sizeof(iMenuItem));
1907 if (d->contextLink) { 1907 if (d->contextLink) {
1908 const iString *linkUrl = linkUrl_GmDocument(d->doc, d->contextLink->linkId); 1908 const iString *linkUrl = linkUrl_GmDocument(d->doc, d->contextLink->linkId);
1909 pushBackN_Array( 1909 const iRangecc scheme = urlScheme_String(linkUrl);
1910 &items, 1910 if (willUseProxy_App(scheme) || equalCase_Rangecc(scheme, "gemini")) {
1911 (iMenuItem[]){ 1911 /* Regular Gemini links. */
1912 { "Open Link in New Tab", 1912 pushBackN_Array(
1913 0, 1913 &items,
1914 0, 1914 (iMenuItem[]){
1915 format_CStr("!open newtab:1 url:%s", cstr_String(linkUrl)) }, 1915 { "Open Link in New Tab",
1916 { "Open Link in Background Tab", 1916 0,
1917 0, 1917 0,
1918 0, 1918 format_CStr("!open newtab:1 url:%s", cstr_String(linkUrl)) },
1919 format_CStr("!open newtab:2 url:%s", cstr_String(linkUrl)) }, 1919 { "Open Link in Background Tab",
1920 { "---", 0, 0, NULL }, 1920 0,
1921 { "Copy Link", 0, 0, "document.copylink" } }, 1921 0,
1922 4); 1922 format_CStr("!open newtab:2 url:%s", cstr_String(linkUrl)) } },
1923 2);
1924 }
1925 else if (!willUseProxy_App(scheme)) {
1926 pushBack_Array(
1927 &items,
1928 &(iMenuItem){ "Open Link in Default Browser",
1929 0,
1930 0,
1931 format_CStr("!open url:%s", cstr_String(linkUrl)) });
1932 }
1933 if (willUseProxy_App(scheme)) {
1934 pushBackN_Array(&items,
1935 (iMenuItem[]){ { "---", 0, 0, NULL },
1936 { "Open Link in Default Browser",
1937 0,
1938 0,
1939 format_CStr("!open noproxy:1 url:%s",
1940 cstr_String(linkUrl)) } },
1941 2);
1942 }
1943 pushBackN_Array(&items,
1944 (iMenuItem[]){ { "---", 0, 0, NULL },
1945 { "Copy Link", 0, 0, "document.copylink" } },
1946 2);
1923 } 1947 }
1924 else { 1948 else {
1925 if (!isEmpty_Range(&d->selectMark)) { 1949 if (!isEmpty_Range(&d->selectMark)) {