summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/X11/Draw.hs
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2020-11-15 16:38:12 +0000
committerTomas Janousek <tomi@nomi.cz>2020-11-15 16:45:12 +0000
commitc7c26b047919b8f365b7fa79a958812ca2f77a01 (patch)
tree0a0b382d78a3341ac1303ed91e890d7ae065b753 /src/Xmobar/X11/Draw.hs
parent8ea89a00a951b303f8b661c3b22a666c6887cfcb (diff)
downloadxmobar-c7c26b047919b8f365b7fa79a958812ca2f77a01.tar.gz
xmobar-c7c26b047919b8f365b7fa79a958812ca2f77a01.tar.bz2
Fix crash on <fn=1>x</fn> when no additional fonts are specified
This fixes the following crash that happens with the default xmobar configuration (using HOME=/ makes xmobar ignore ~/.xmobarrc): $ echo "<fn=1>x</fn>" | HOME=/ xmobar xmobar: Prelude.!!: index too large Commit 3e9e1cb9d300 ("Fix crashes/busy looping happening via index") meant to fix this but apparently it only fixed indexing of fontlist, not voffs, so the crash was still there. Fixes: https://github.com/jaor/xmobar/issues/504
Diffstat (limited to 'src/Xmobar/X11/Draw.hs')
-rw-r--r--src/Xmobar/X11/Draw.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/Xmobar/X11/Draw.hs b/src/Xmobar/X11/Draw.hs
index 1ded312..6c00ee6 100644
--- a/src/Xmobar/X11/Draw.hs
+++ b/src/Xmobar/X11/Draw.hs
@@ -131,7 +131,7 @@ printString dpy drw fs@(Xft fonts) _ fc bc x y ay ht s al =
#endif
-- | An easy way to print the stuff we need to print
-printStrings :: Drawable -> GC -> NE.NonEmpty XFont -> [Int] -> Position
+printStrings :: Drawable -> GC -> NE.NonEmpty XFont -> NE.NonEmpty Int -> Position
-> Align -> [((Position, Position), Box)] -> [(Widget, TextRenderInfo, Int, Position)] -> X ()
printStrings _ _ _ _ _ _ _ [] = return ()
printStrings dr gc fontlist voffs offs a boxes sl@((s,c,i,l):xs) = do
@@ -142,6 +142,7 @@ printStrings dr gc fontlist voffs offs a boxes sl@((s,c,i,l):xs) = do
totSLen = foldr (\(_,_,_,len) -> (+) len) 0 sl
remWidth = fi wid - fi totSLen
fontst = safeIndex fontlist i
+ voff = safeIndex voffs i
offset = case a of
C -> (remWidth + offs) `div` 2
R -> remWidth
@@ -149,7 +150,7 @@ printStrings dr gc fontlist voffs offs a boxes sl@((s,c,i,l):xs) = do
(fc,bc) = case break (==',') (tColorsString c) of
(f,',':b) -> (f, b )
(f, _) -> (f, bgColor conf)
- valign <- verticalOffset ht s fontst (voffs !! i) conf
+ valign <- verticalOffset ht s fontst voff conf
let (ht',ay) = case (tBgTopOffset c, tBgBottomOffset c) of
(-1,_) -> (0, -1)
(_,-1) -> (0, -1)