summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/MarqueePipeReader.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2016-07-28 00:30:21 +0200
committerjao <jao@gnu.org>2016-07-28 00:30:21 +0200
commit5e783dc34abb507f4d9715f0fd30ed8db016772a (patch)
tree8ffade9020f5cf770ff7bdb104f645465a2f55a8 /src/Plugins/MarqueePipeReader.hs
parent6af854ffa7ca840857876629690a10e143396e1f (diff)
downloadxmobar-5e783dc34abb507f4d9715f0fd30ed8db016772a.tar.gz
xmobar-5e783dc34abb507f4d9715f0fd30ed8db016772a.tar.bz2
Fixing compatibility with GHC 7.6
Diffstat (limited to 'src/Plugins/MarqueePipeReader.hs')
-rw-r--r--src/Plugins/MarqueePipeReader.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Plugins/MarqueePipeReader.hs b/src/Plugins/MarqueePipeReader.hs
index 0b3a710..c46fff4 100644
--- a/src/Plugins/MarqueePipeReader.hs
+++ b/src/Plugins/MarqueePipeReader.hs
@@ -22,9 +22,10 @@ import Control.Concurrent(forkIO, threadDelay)
import Control.Concurrent.STM (TChan, atomically, writeTChan, tryReadTChan, newTChan)
import Control.Exception
import Control.Monad(forever, unless)
+import Control.Applicative ((<$>))
type Length = Int -- length of the text to display
-type Rate = Int -- delay in tenth seconds
+type Rate = Int -- delay in tenth seconds
type Separator = String -- if text wraps around, use separator
data MarqueePipeReader = MarqueePipeReader String (Length, Rate, Separator) String
@@ -48,16 +49,16 @@ instance Exec MarqueePipeReader where
pipeToChan :: Handle -> TChan String -> IO ()
pipeToChan h chan = do
- line <- hGetLineSafe h
+ line <- hGetLineSafe h
atomically $ writeTChan chan line
writer :: String -> Separator -> Length -> Rate -> TChan String -> (String -> IO ()) -> IO ()
-writer txt sep len rate chan cb = do
+writer txt sep len rate chan cb = do
cb (take len txt)
mbnext <- atomically $ tryReadTChan chan
case mbnext of
Just new -> writer (toInfTxt new sep) sep len rate chan cb
- Nothing -> tenthSeconds rate >> writer (drop 1 txt) sep len rate chan cb
+ Nothing -> tenthSeconds rate >> writer (drop 1 txt) sep len rate chan cb
toInfTxt :: String -> String -> String
toInfTxt line sep = concat (repeat $ line ++ " " ++ sep ++ " ")