summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-01-29 18:00:01 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-01-29 18:00:01 +0200
commit07804493ac17ff430302c7940f44b7525c0620e8 (patch)
tree885db4fd4576ef65df77d4d47a3ae354efdba01e /src/ui
parent8d46b523f2948992343a9491a12dcec73f109c87 (diff)
Hierarchical navigation with Gopher and Titan
With Gopher, ensure that the item type changes to 1, and with Titan, change to normal Gemini.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/documentwidget.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 2e15cdce..86513368 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -36,6 +36,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36#include "gmdocument.h" 36#include "gmdocument.h"
37#include "gmrequest.h" 37#include "gmrequest.h"
38#include "gmutil.h" 38#include "gmutil.h"
39#include "gopher.h"
39#include "history.h" 40#include "history.h"
40#include "indicatorwidget.h" 41#include "indicatorwidget.h"
41#include "inputwidget.h" 42#include "inputwidget.h"
@@ -4315,20 +4316,31 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd)
4315 } 4316 }
4316 iString *parentUrl = collectNewRange_String((iRangecc){ constBegin_String(d->mod.url), 4317 iString *parentUrl = collectNewRange_String((iRangecc){ constBegin_String(d->mod.url),
4317 parts.path.end }); 4318 parts.path.end });
4318 if (equalCase_Rangecc(parts.scheme, "gopher")) { 4319 /* Always go to a gophermap. */
4319 /* Always go to a gophermap. */ 4320 setUrlItemType_Gopher(parentUrl, '1');
4320 iZap(parts); 4321 /* Hierarchical navigation doesn't make sense with Titan. */
4321 init_Url(&parts, parentUrl); 4322 if (startsWith_String(parentUrl, "titan://")) {
4322 if (parts.path.start && size_Range(&parts.path) >= 2) { 4323 /* We have no way of knowing if the corresponding URL is valid for Gemini,
4323 ((char *) parts.path.start)[1] = '1'; 4324 but let's try anyway. */
4324 } 4325 set_String(parentUrl, withScheme_String(parentUrl, "gemini"));
4326 stripUrlPort_String(parentUrl);
4325 } 4327 }
4326 postCommandf_Root(w->root, "open url:%s", cstr_String(parentUrl)); 4328 postCommandf_Root(w->root, "open url:%s", cstr_String(parentUrl));
4327 } 4329 }
4328 return iTrue; 4330 return iTrue;
4329 } 4331 }
4330 else if (equal_Command(cmd, "navigate.root") && document_App() == d) { 4332 else if (equal_Command(cmd, "navigate.root") && document_App() == d) {
4331 postCommandf_Root(w->root, "open url:%s/", cstr_Rangecc(urlRoot_String(d->mod.url))); 4333 iString *rootUrl = collectNewRange_String(urlRoot_String(d->mod.url));
4334 /* Always go to a gophermap. */
4335 setUrlItemType_Gopher(rootUrl, '1');
4336 /* Hierarchical navigation doesn't make sense with Titan. */
4337 if (startsWith_String(rootUrl, "titan://")) {
4338 /* We have no way of knowing if the corresponding URL is valid for Gemini,
4339 but let's try anyway. */
4340 set_String(rootUrl, withScheme_String(rootUrl, "gemini"));
4341 stripUrlPort_String(rootUrl);
4342 }
4343 postCommandf_Root(w->root, "open url:%s/", cstr_String(rootUrl));
4332 return iTrue; 4344 return iTrue;
4333 } 4345 }
4334 else if (equalWidget_Command(cmd, w, "scroll.moved")) { 4346 else if (equalWidget_Command(cmd, w, "scroll.moved")) {