@@ -43,6 +43,7 @@ module Reflex.Vty.Widget
4343 , mouseScroll
4444 , pane
4545 , splitV
46+ , splitH
4647 , splitVDrag
4748 , boxTitle
4849 , box
@@ -475,6 +476,35 @@ splitV sizeFunD focD wA wB = do
475476 rb <- pane regB (snd <$> focD) wB
476477 return (ra,rb)
477478
479+-- | A plain split of the available space into horizontally stacked panes.
480+-- No visual separator is built in here.
481+splitH :: (Reflex t, Monad m, MonadNodeId m)
482+ => Dynamic t (Int -> Int)
483+ -- ^ Function used to determine size of first pane based on available size
484+ -> Dynamic t (Bool, Bool)
485+ -- ^ How to focus the two sub-panes, given that we are focused.
486+ -> VtyWidget t m a
487+ -- ^ Widget for first pane
488+ -> VtyWidget t m b
489+ -- ^ Widget for second pane
490+ -> VtyWidget t m (a,b)
491+splitH sizeFunD focD wA wB = do
492+ dw <- displayWidth
493+ dh <- displayHeight
494+ let regA = DynRegion
495+ { _dynRegion_left = pure 0
496+ , _dynRegion_top = pure 0
497+ , _dynRegion_width = sizeFunD <*> dw
498+ , _dynRegion_height = dh
499+ }
500+ regB = DynRegion
501+ { _dynRegion_left = _dynRegion_width regA
502+ , _dynRegion_top = pure 0
503+ , _dynRegion_width = liftA2 (-) dw (_dynRegion_width regA)
504+ , _dynRegion_height = dh
505+ }
506+ liftA2 (,) (pane regA (fmap fst focD) wA) (pane regB (fmap snd focD) wB)
507+
478508-- | A split of the available space into two parts with a draggable separator.
479509-- Starts with half the space allocated to each, and the first pane has focus.
480510-- Clicking in a pane switches focus.