summaryrefslogtreecommitdiff
path: root/Assistant/Alert.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-02 13:47:26 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-02 13:50:35 -0400
commitd2f975944380aab57047a9e84af620e15464fa15 (patch)
tree7c6c756b82f2971841cf961054613ebbda8cbaf7 /Assistant/Alert.hs
parent6b38227bad8c303470a5b29f50360cea0206d9a1 (diff)
refactor
Diffstat (limited to 'Assistant/Alert.hs')
-rw-r--r--Assistant/Alert.hs19
1 files changed, 11 insertions, 8 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index b234d2a5a..16ce222ad 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -247,18 +247,11 @@ sanityCheckFixAlert msg = Alert
combinemessage _ _ = Nothing
addFileAlert :: FilePath -> Alert
-addFileAlert file = (activityAlert (Just "Added") $ trim $ takeFileName file)
+addFileAlert file = (activityAlert (Just "Added") $ shortFile $ takeFileName file)
{ alertName = Just AddFileAlert
, alertCombiner = messageCombiner combinemessage
}
where
- trim f
- | len < maxlen = f
- | otherwise = take half f ++ ".." ++ drop (len - half) f
- where
- len = length f
- maxlen = 20
- half = (maxlen - 2) `div` 2
combinemessage (StringAlert new) (StringAlert old) =
Just $ StringAlert $
unlines $ take 10 $ new : lines old
@@ -274,3 +267,13 @@ messageCombiner combinemessage = Just go
Nothing -> Nothing
Just !m -> Just $! old { alertMessage = m }
| otherwise = Nothing
+
+shortFile :: FilePath -> String
+shortFile f
+ | len < maxlen = f
+ | otherwise = take half f ++ ".." ++ drop (len - half) f
+ where
+ len = length f
+ maxlen = 20
+ half = (maxlen - 2) `div` 2
+