diff options
-rw-r--r-- | Pancake.hs | 10 | ||||
-rw-r--r-- | Pancake/Command.hs | 12 | ||||
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | pancake.1 | 2 |
4 files changed, 25 insertions, 0 deletions
@@ -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 diff --git a/Pancake/Command.hs b/Pancake/Command.hs index 4686924..297a438 100644 --- a/Pancake/Command.hs +++ b/Pancake/Command.hs @@ -52,6 +52,7 @@ data Command = Quit | More | GoTo (Maybe String) Reference -- ^ Document type, reference + | GopherSearch Int String | Save Reference (Maybe FilePath) | Back | Forward @@ -166,6 +167,16 @@ loadConf = string "load config" *> (LoadConfig <$> optionMaybe (space *> many1 anyChar)) <* eof +gopherSearch :: String -> Parser Command +gopherSearch digits = do + string "gs" + space + ref <- pNumber digits + _ <- space + query <- many1 anyChar + _ <- eof + pure $ GopherSearch ref query + -- | Command parser. command :: Config -> Parser Command command c = @@ -181,4 +192,5 @@ command c = , setPos <?> "set position" , loadConf <?> "load config" , goTo <?> "follow uri" + , gopherSearch (referenceDigits c) <?> "gopher search" ]) @@ -77,6 +77,7 @@ Commands :set width[ <columns>]: set terminal/window width manually :set position[ <line>]: set current terminal/window line :redisplay: redisplay current document +:gs [,]<number> <query>: Gopher search, using a given reference and query pancake-mode provides additional aliases and commands, see built-in emacs documentation (``C-h m``) for those. @@ -70,6 +70,8 @@ set terminal/window width manually set current terminal/window line .IP "\fBredisplay\fR" redisplay current document +.IP "\fBgs\fR [\fB,\fR]\fInumber\fR \fIquery\fR" +Gopher search, using a given reference and query .SH DEFAULT SHORTCUTS .IP "\fBg\fR" |