Skip to content

Commit

Permalink
Fix window switching in vty.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethercrow committed Oct 19, 2014
1 parent 73ceab7 commit c7fd95d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion yi/src/library/Yi/UI/SimpleLayout.hs
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions yi/src/library/Yi/UI/Vty.hs
Expand Up @@ -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))
Expand Down

0 comments on commit c7fd95d

Please sign in to comment.