From 637f52294ef1a7ee6bbaf3fa8eda8e35472d316e Mon Sep 17 00:00:00 2001 From: defanor Date: Mon, 18 Feb 2019 12:05:36 +0300 Subject: Add the "gs" command for Gopher search --- Pancake.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Pancake.hs') diff --git a/Pancake.hs b/Pancake.hs index 5420530..45fef50 100644 --- a/Pancake.hs +++ b/Pancake.hs @@ -283,6 +283,16 @@ command (GoTo t (RNumber i)) = do if length (rLinks $ rendered st) > i then command (GoTo t $ RURI $ rLinks (rendered st) !! i) else putErrLn "No such link" +command (GopherSearch i q) = do + st <- get + if length (rLinks $ rendered st) > i + then + let refURIString = uriToString id (rLinks (rendered st) !! i) "" + searchString = refURIString ++ "%09" ++ escapeURIString isUnreserved q + in maybe (putErrLn "Failed to compose a valid search URI") + (command . GoTo Nothing . RURI) + (parseURI searchString) + else putErrLn "No such link" command Back = do st <- get case history st of -- cgit v1.2.3