@@ -39,15 +39,15 @@ textInput
3939textInput cfg = do
4040 i <- input
4141 f <- focus
42+ dh <- displayHeight
43+ dw <- displayWidth
4244 rec v <- foldDyn ($) (_textInputConfig_initialValue cfg) $ mergeWith (.)
43− [ updateTextZipper (_textInputConfig_tabWidth cfg) <$> i
45+ [ uncurry (updateTextZipper (_textInputConfig_tabWidth cfg)) <$> attach (current dh) i
4446 , _textInputConfig_modify cfg
4547 , let displayInfo = (,) <$> rows <*> scrollTop
4648 in ffor (attach (current displayInfo) click) $ \((dl, st), MouseDown _ (mx, my) _) ->
4749 goToDisplayLinePosition mx (st + my) dl
4850 ]
49− dw <- displayWidth
50− dh <- displayHeight
5151 click <- mouseDown V.BLeft
5252 let cursorAttrs = ffor f $ \x -> if x then cursorAttributes else V.defAttr
5353 let rows = (\w s c -> displayLines w V.defAttr c s) <$> dw <*> v <*> cursorAttrs
@@ -96,10 +96,16 @@ spanToImage :: Span V.Attr -> V.Image
9696spanToImage (Span attrs t) = V.text' attrs t
9797
9898-- | Default vty event handler for text inputs
99−updateTextZipper :: Int -> V.Event -> TextZipper -> TextZipper
100−updateTextZipper tabWidth ev = case ev of
101− -- Regular characters
99+updateTextZipper
100+ :: Int -- ^ Tab width
101+ -> Int -- ^ Page size
102+ -> V.Event -- ^ The vty event to handle
103+ -> TextZipper -- ^ The zipper to modify
104+ -> TextZipper
105+updateTextZipper tabWidth pageSize ev = case ev of
106+ -- Special characters
102107 V.EvKey (V.KChar '\t') [] -> tab tabWidth
108+ -- Regular characters
103109 V.EvKey (V.KChar k) [] -> insertChar k
104110 -- Deletion buttons
105111 V.EvKey V.KBS [] -> deleteLeft
@@ -114,4 +120,6 @@ updateTextZipper tabWidth ev = case ev of
114120 V.EvKey V.KDown [] -> down
115121 V.EvKey V.KHome [] -> home
116122 V.EvKey V.KEnd [] -> end
123+ V.EvKey V.KPageUp [] -> pageUp pageSize
124+ V.EvKey V.KPageDown [] -> pageDown pageSize
117125 _ -> id