From 5b753d8c1aa2ce271fb15b7c9aa1af83f8de0d3a Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Sun, 16 Mar 2008 13:11:00 +0100 Subject: 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 --- Main.hs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'Main.hs') 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 -- cgit v1.2.3