From 1f2127c520b48e35a5fb335c9e711559733dfd23 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 2 Aug 2012 09:15:08 -0400 Subject: [PATCH] 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.) --- Assistant/Alert.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs index 5877ba069c..6b32fde1d9 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