summaryrefslogtreecommitdiffhomepage
path: root/Main.hs
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2008-03-16 13:11:00 +0100
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2008-03-16 13:11:00 +0100
commit5b753d8c1aa2ce271fb15b7c9aa1af83f8de0d3a (patch)
treebdde146cd302b48910d79e627f6790a8b4dd50b9 /Main.hs
parentff8ef5fa74fb5bce3dcb82ef1cd81e0d123d0ac1 (diff)
downloadxmobar-5b753d8c1aa2ce271fb15b7c9aa1af83f8de0d3a.tar.gz
xmobar-5b753d8c1aa2ce271fb15b7c9aa1af83f8de0d3a.tar.bz2
add XFT support and make UTF-8 support configurable
This patch includes many changes: - moved font and printing functions to XUtil.hs and created an abstraction layer to font management; - ported the core, StdinReader and PipeReader to the new font management system. To enable UTF-8 support configure with the "with_utf8" flag (requires utf8-string): runhaskell Setup.lhs configure --flags darcs-hash:20080316121100-d6583-828134da356b706744b56a9d81203129b0e8e484.gz
Diffstat (limited to 'Main.hs')
-rw-r--r--Main.hs24
1 files changed, 10 insertions, 14 deletions
diff --git a/Main.hs b/Main.hs
index 34440cd..9ac16d4 100644
--- a/Main.hs
+++ b/Main.hs
@@ -22,16 +22,14 @@ module Main ( -- * Main Stuff
import Xmobar
import Parsers
import Config
-import HsLocale
+import XUtil
-import Prelude hiding (readFile)
+import Prelude
import Data.IORef
import Graphics.X11.Xlib
-import Graphics.X11.Xlib.Extras
import System.Console.GetOpt
import System.Exit
import System.Environment
-import System.IO.UTF8 (readFile)
import System.Posix.Files
-- $main
@@ -40,7 +38,6 @@ import System.Posix.Files
main :: IO ()
main = do
d <- openDisplay ""
- setupLocale
args <- getArgs
(o,file) <- getOpts args
c <- case file of
@@ -51,22 +48,21 @@ main = do
rootw <- rootWindow d (defaultScreen d)
selectInput d rootw structureNotifyMask
- civ <- newIORef c
+ civ <- newIORef c
doOpts civ o
- conf <- readIORef civ
- let loadFont = createFontSet d . font
- (_,_,fs) <- catch (loadFont conf) (const $ loadFont defaultConfig)
- cl <- parseTemplate conf (template conf)
- vars <- mapM startCommand cl
- (r,w) <- createWin d fs conf
+ conf <- readIORef civ
+ fs <- initFont d (font conf)
+ cl <- parseTemplate conf (template conf)
+ vars <- mapM startCommand cl
+ (r,w) <- createWin d fs conf
eventLoop (XConf d r w fs conf) vars
- freeFontSet d fs
+ releaseFont d fs
-- | Reads the configuration files or quits with an error
readConfig :: FilePath -> IO Config
readConfig f = do
file <- fileExist f
- s <- if file then readFile f else error $ f ++ ": file not found!\n" ++ usage
+ s <- if file then readFileSafe f else error $ f ++ ": file not found!\n" ++ usage
case reads s of
[(conf,_)] -> return conf
[] -> error $ f ++ ": configuration file contains errors!\n" ++ usage