summaryrefslogtreecommitdiff
path: root/Assistant/Alert.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-08-02 09:15:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-08-02 09:15:08 -0400
commit1f2127c520b48e35a5fb335c9e711559733dfd23 (patch)
tree16959d9fe5f689b001e975cef45fb7ad82ebe241 /Assistant/Alert.hs
parent520a0463a7172314298db0ce507fa355dc1238a3 (diff)
trim long filenames (have to fit on the sidebar)
30 characters would mostly work, but 20 is safer due to some wider letters like 'w'. Of course this is very heuristic based on filesize anyway. (Bootstrap does a surprisingly bad job at dealing with overlong words in the sidebar.)
Diffstat (limited to 'Assistant/Alert.hs')
-rw-r--r--Assistant/Alert.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index 5877ba069..6b32fde1d 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -247,11 +247,18 @@ sanityCheckFixAlert msg = Alert
combinemessage _ _ = Nothing
addFileAlert :: FilePath -> Alert
-addFileAlert file = (activityAlert (Just "Added") $ takeFileName file)
+addFileAlert file = (activityAlert (Just "Added") $ trim $ 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