manatee-anything 0.0.1 → 0.0.2
raw patch · 3 files changed
+39/−21 lines, 3 filesdep ~manatee-core
Dependency ranges changed: manatee-core
Files
- Manatee/Plugin/Anything/AnythingLocate.hs +11/−11
- Manatee/Plugin/Anything/AnythingView.hs +26/−8
- manatee-anything.cabal +2/−2
Manatee/Plugin/Anything/AnythingLocate.hs view
@@ -76,17 +76,17 @@ -- | Search local files. anythingLocateSearch :: Bool -> AnythingInput -> Client -> IO [FileInfo] anythingLocateSearch filterDir filepath _ = do- home <- getEnv "HOME"- let -- Expand '~' with HOME value. - path = if ("~" :: String) `isPrefixOf` filepath- then home ++ drop (length ("~" :: String)) filepath- else filepath- -- Try to get upper directory of current file path.- upperDir | hasTrailingPathSeparator path- = fromString path- | otherwise- = fromString $ getUpperDirectory path- anythingLocateGetFileInfos upperDir filterDir+ home <- getEnv "HOME"+ let -- Expand '~' with HOME value. + path = if ("~" :: String) `isPrefixOf` filepath+ then home ++ drop (length ("~" :: String)) filepath+ else filepath+ -- Try to get upper directory of current file path.+ upperDir | hasTrailingPathSeparator path+ = fromString path+ | otherwise+ = fromString $ getUpperDirectory path+ anythingLocateGetFileInfos upperDir filterDir -- | Get FileInfo. anythingLocateGetFileInfos :: ByteString -> Bool -> IO [FileInfo]
Manatee/Plugin/Anything/AnythingView.hs view
@@ -17,6 +17,7 @@ -- along with this program. If not, see <http://www.gnu.org/licenses/>. {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} module Manatee.Plugin.Anything.AnythingView where import Control.Applicative hiding (empty)@@ -44,6 +45,7 @@ import Manatee.Toolkit.Gtk.ModelView import qualified Data.Map as M+import qualified Control.Exception as Exc -- | The max limit of rows in candidate view. anythingCandidateViewLimit :: Int@@ -310,7 +312,7 @@ >?>= \ AnythingCandidateView {acavTreeView = treeView} -> do treeViewY <- rectangleY <$> widgetGetAllocation treeView vAdjust <- scrolledWindowGetVAdjustment $ avCandidateScrolledWindow view- adjustmentSetValue vAdjust (integralToDouble treeViewY)+ adjustmentSetValue vAdjust (i2d treeViewY) -- | Focus default candidate. anythingViewFocusFirstCandidate :: AnythingView -> Bool -> IO () @@ -410,8 +412,8 @@ -- Transform treeView coordinate to avCandidateBox coordinate. widgetTranslateCoordinates treeView (avCandidateBox view) cx cy >?>= \(_, by) -> do- let candidateY = integralToDouble by- candidateH = integralToDouble ch+ let candidateY = i2d by+ candidateH = i2d ch scrolledWindow = avCandidateScrolledWindow view -- Get vertical adjustment information. @@ -428,7 +430,7 @@ -- make sure header can scroll to visible area of screen. atFirstToplevelNode <- treeViewAtFirstToplevelNode treeView adjustValue <- if atFirstToplevelNode - then integralToDouble <$> treeViewGetHeaderHeight treeView+ then i2d <$> treeViewGetHeaderHeight treeView else return 0 adjustmentSetValue vAdjust (candidateY - adjustValue) else @@ -621,9 +623,25 @@ anythingViewRunCommand True -- | Get match candidate for current input.-anythingViewGetMatches :: AnythingInput -> Client -> AnythingSearch -> AnythingFilterRule -> IO [AnythingCandidateWrap]-anythingViewGetMatches path client (AnythingSearch searchFun) filterRule = do- candidates <- map AnythingCandidateWrap <$> searchFun path client+anythingViewGetMatches :: AnythingName+ -> AnythingInput + -> Client + -> AnythingSearch + -> AnythingFilterRule + -> IO [AnythingCandidateWrap]+anythingViewGetMatches name path client (AnythingSearch searchFun) filterRule = do+ candidates <- + -- Protect search algorithm won't crash.+ -- If any unexpected exception throw, + -- just return [] to hide current search candidate.+ -- Avoid one search exception crash all process.+ Exc.catch + (map AnythingCandidateWrap <$> searchFun path client)+ (\ (_ :: Exc.IOException) -> do+ putStrLn $ "anythingViewGetMatches: Catch exception when search candidate for `" + ++ name+ ++ "` please report this bug to author!"+ return []) return $ filter (\ (AnythingCandidateWrap x) -> filterRule path (candidateFilterName x)) candidates -- | Output completion candidates on TreeView.@@ -657,7 +675,7 @@ getMatches = do -- Start spinner animation. titleWidgetStart (acavTitleWidget candidateView)- anythingViewGetMatches path client searchFun filterRule+ anythingViewGetMatches name path client searchFun filterRule -- Update UI after candidates calculate finished. setCandidates name cacheTVar candidates = do -- Stop spinner animation.
manatee-anything.cabal view
@@ -1,5 +1,5 @@ name: manatee-anything-version: 0.0.1+version: 0.0.2 Cabal-Version: >= 1.6 license: GPL-3 license-file: LICENSE@@ -20,7 +20,7 @@ Library build-depends: base >= 4 && < 5, gtk >= 0.12.0, containers >= 0.3.0.0, text >= 0.7.1.0,- gio >= 0.12.0, filepath >= 1.1.0.3, manatee-core >= 0.0.1, dbus-client >= 0.3 && < 0.4,+ gio >= 0.12.0, filepath >= 1.1.0.3, manatee-core >= 0.0.2, dbus-client >= 0.3 && < 0.4, network >= 2.2.1.5, utf8-string >= 0.3.4, proc >= 0.0.8, mtl >= 1.1.0.2, stm >= 2.1.2.0, unix >= 2.4.0.0, regex-tdfa >= 1.1.2, bytestring, GoogleSuggest >= 0.0.3, dataenc, dbus-core, split