mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
XMonad.Prompt.Unicode: respect searchPredicate and sorter from XPConfig
This commit is contained in:
parent
9c09072843
commit
a69794892b
@ -124,6 +124,8 @@
|
|||||||
Reworked internally to be call `spawnPipe` (asynchronous) instead of
|
Reworked internally to be call `spawnPipe` (asynchronous) instead of
|
||||||
`runProcessWithInput` (synchronous), which fixes `typeUnicodePrompt`.
|
`runProcessWithInput` (synchronous), which fixes `typeUnicodePrompt`.
|
||||||
|
|
||||||
|
Now respects `searchPredicate` and `sorter` from user-supplied `XPConfig`.
|
||||||
|
|
||||||
* `XMonad.Hooks.DynamicLog`
|
* `XMonad.Hooks.DynamicLog`
|
||||||
|
|
||||||
Added `statusBar'` function, like existing `statusBar` but accepts a pretty
|
Added `statusBar'` function, like existing `statusBar` but accepts a pretty
|
||||||
|
@ -96,20 +96,27 @@ parseUnicodeData = mapMaybe parseLine . BS.lines
|
|||||||
[(c,"")] <- return . readHex $ BS.unpack field1
|
[(c,"")] <- return . readHex $ BS.unpack field1
|
||||||
return (chr c, field2)
|
return (chr c, field2)
|
||||||
|
|
||||||
searchUnicode :: [(Char, BS.ByteString)] -> String -> [(Char, String)]
|
type Predicate = String -> String -> Bool
|
||||||
searchUnicode entries s = map (second BS.unpack) $ filter go entries
|
|
||||||
where w = map BS.pack . filter (all isAscii) . filter ((> 1) . length) . words $ map toUpper s
|
searchUnicode :: [(Char, BS.ByteString)] -> Predicate -> String -> [(Char, String)]
|
||||||
go (c,d) = all (`BS.isInfixOf` d) w
|
searchUnicode entries p s = map (second BS.unpack) $ filter go entries
|
||||||
|
where w = filter (all isAscii) . filter ((> 1) . length) . words $ map toUpper s
|
||||||
|
go (c,d) = all (`p` (BS.unpack d)) w
|
||||||
|
|
||||||
mkUnicodePrompt :: String -> [String] -> String -> XPConfig -> X ()
|
mkUnicodePrompt :: String -> [String] -> String -> XPConfig -> X ()
|
||||||
mkUnicodePrompt prog args unicodeDataFilename config =
|
mkUnicodePrompt prog args unicodeDataFilename config =
|
||||||
whenX (populateEntries unicodeDataFilename) $ do
|
whenX (populateEntries unicodeDataFilename) $ do
|
||||||
entries <- fmap getUnicodeData (XS.get :: X UnicodeData)
|
entries <- fmap getUnicodeData (XS.get :: X UnicodeData)
|
||||||
mkXPrompt Unicode config (unicodeCompl entries) paste
|
mkXPrompt
|
||||||
|
Unicode
|
||||||
|
(config {sorter = sorter config . map toUpper})
|
||||||
|
(unicodeCompl entries $ searchPredicate config)
|
||||||
|
paste
|
||||||
where
|
where
|
||||||
unicodeCompl _ [] = return []
|
unicodeCompl :: [(Char, BS.ByteString)] -> Predicate -> String -> IO [String]
|
||||||
unicodeCompl entries s = do
|
unicodeCompl _ _ "" = return []
|
||||||
let m = searchUnicode entries s
|
unicodeCompl entries p s = do
|
||||||
|
let m = searchUnicode entries p s
|
||||||
return . map (\(c,d) -> printf "%s %s" [c] d) $ take 20 m
|
return . map (\(c,d) -> printf "%s %s" [c] d) $ take 20 m
|
||||||
paste [] = return ()
|
paste [] = return ()
|
||||||
paste (c:_) = liftIO $ do
|
paste (c:_) = liftIO $ do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user