diff --git a/yi/src/library/Yi/UI/SimpleLayout.hs b/yi/src/library/Yi/UI/SimpleLayout.hs index f50994f30..cbc75f387 100644 --- a/yi/src/library/Yi/UI/SimpleLayout.hs +++ b/yi/src/library/Yi/UI/SimpleLayout.hs @@ -18,6 +18,7 @@ import Control.Lens import Control.Monad.State (evalState, get, put) import Data.Foldable import Data.List (partition) +import Data.Maybe (fromJust) import qualified Data.List.PointedList.Circular as PL import qualified Data.Map.Strict as M import Data.Monoid @@ -78,7 +79,8 @@ layout colCount rowCount e = heights miniWindowsWithHeights = fmap (\win -> layoutWindow win e colCount 1) miniWs - Just newWindows = PL.fromList (miniWindowsWithHeights <> bigWindowsWithHeights) + newWindows = + merge (miniWindowsWithHeights <> bigWindowsWithHeights) (windows e) winRects = M.fromList (bigWindowsWithRects <> miniWindowsWithRects) bigWindowsWithRects = zipWith (\w offset -> (wkey w, Rect 0 (offset + tabbarHeight) colCount (height w))) @@ -87,6 +89,11 @@ layout colCount rowCount e = miniWindowsWithRects = map (\w -> (wkey w, Rect 0 (rowCount - 1) colCount 1)) miniWindowsWithHeights + merge :: [Window] -> PL.PointedList Window -> PL.PointedList Window + merge updates = + let replace (Window { wkey = k }) = fromJust (find ((== k) . wkey) updates) + in fmap replace + layoutWindow :: Window -> Editor -> Int -> Int -> Window layoutWindow win e w h = win diff --git a/yi/src/library/Yi/UI/Vty.hs b/yi/src/library/Yi/UI/Vty.hs index cd09b0147..03dc5561a 100644 --- a/yi/src/library/Yi/UI/Vty.hs +++ b/yi/src/library/Yi/UI/Vty.hs @@ -180,11 +180,11 @@ refresh fs e = do (Vty.vertCat (fmap formatCmdLine niceCmd)) cursorPos = let (w, image) = PL._focus windowsAndImages - in case (isMini w, cursor image, winRects M.! wkey w) of - (False, Just (y, x), SL.Rect ox oy _ _) -> - Vty.Cursor (toEnum (x + ox)) (toEnum (y + oy - 1)) - (True, Just (_, x), _) -> Vty.Cursor (toEnum x) (toEnum (rowCount - 1)) - (_, Nothing, _) -> Vty.NoCursor + in case (isMini w, cursor image) of + (False, Just (y, x)) -> + Vty.Cursor (toEnum x) (toEnum y) + (True, Just (_, x)) -> Vty.Cursor (toEnum x) (toEnum (rowCount - 1)) + (_, Nothing) -> Vty.NoCursor logPutStrLn "refreshing screen." Vty.update (fsVty fs) (Vty.picForLayers ([tabBarImage, cmdImage] ++ bigImages ++ miniImages))