File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ data CmdLine
2525 ,json :: Bool
2626 ,jsonl :: Bool
2727 ,link :: Bool
28+ ,hyperlink :: Bool
2829 ,numbers :: Bool
2930 ,info :: Bool
3031 ,database :: FilePath
@@ -114,6 +115,7 @@ search_ = Search
114115 ,json = def &= name " json" &= help " Get result as JSON"
115116 ,jsonl = def &= name " jsonl" &= help " Get result as JSONL (JSON Lines)"
116117 ,link = def &= help " Give URL's for each result"
118+ ,hyperlink = def &= help " Hyperlink results with ANSI escape sequences"
117119 ,numbers = def &= help " Give counter for each result"
118120 ,info = def &= help " Give extended information about the first result"
119121 ,database = def &= typFile &= help " Name of database to use (use .hoo extension)"
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ actionSearch Search{..} = replicateM_ repeat_ $ -- deliberately reopen the datab
4343 count' <- pure $ fromMaybe 10 count
4444 (q, res) <- pure $ search store $ parseQuery $ unwords query
4545 whenLoud $ putStrLn $ " Query: " ++ unescapeHTML (LBS. unpack $ renderMarkup $ renderQuery q)
46- let (shown, hidden) = splitAt count' $ nubOrd $ map (targetResultDisplay link) res
46+ let (shown, hidden) = splitAt count' $ nubOrd $ map (targetResultDisplay link hyperlink ) res
4747 if null res then
4848 putStrLn " No results found"
4949 else if info then do
@@ -71,11 +71,13 @@ targetInfo Target{..} =
7171
7272-- | Returns the Target formatted as an item to display in the results
7373-- | Bool argument decides whether links are shown
74- targetResultDisplay :: Bool -> Target -> String
75- targetResultDisplay link Target {.. } = unHTML $ unwords $
74+ targetResultDisplay :: Bool -> Bool -> Target -> String
75+ targetResultDisplay link hyperlink Target {.. } = unHTML $ unwords $
7676 map fst (maybeToList targetModule) ++
77- [targetItem] ++
77+ [if hyperlink then targetItemHyperlink else targetItem] ++
7878 [" -- " ++ targetURL | link]
79+ where
80+ targetItemHyperlink = " \ESC ]8;;" ++ targetURL ++ " \BEL " ++ targetItem ++ " \ESC ]8;;\BEL "
7981
8082unHTMLtargetItem :: Target -> Target
8183unHTMLtargetItem target = target {targetItem = unHTML $ targetItem target}
You can’t perform that action at this time.
0 commit comments