Skip to content

Commit c374029

Browse files
committed
Add scrolling with arrow keys, do full PgUp/PgDown pages
1 parent 450657b commit c374029

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/Echidna/UI.hs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,11 @@ monitor = do
283283
(state.focusedPane == LogPane && not state.displayLogPane)
284284
then toggleFocus state else state
285285

286+
focusedViewportScroll :: UIState -> ViewportScroll Name
287+
focusedViewportScroll state = case state.focusedPane of
288+
TestsPane -> viewportScroll TestsViewPort
289+
LogPane -> viewportScroll LogViewPort
290+
286291
onEvent env = \case
287292
AppEvent (CampaignUpdated now tests c') -> do
288293
state <- get
@@ -324,10 +329,12 @@ monitor = do
324329
refocusIfNeeded $ state { displayTestsPane = not state.displayTestsPane }
325330
VtyEvent (EvKey direction _) | direction == KPageUp || direction == KPageDown -> do
326331
state <- get
327-
let vp = case state.focusedPane of
328-
TestsPane -> viewportScroll TestsViewPort
329-
LogPane -> viewportScroll LogViewPort
330-
vScrollBy vp (if direction == KPageDown then 10 else -10)
332+
let vp = focusedViewportScroll state
333+
vScrollPage vp (if direction == KPageDown then Down else Up)
334+
VtyEvent (EvKey direction _) | direction == KUp || direction == KDown -> do
335+
state <- get
336+
let vp = focusedViewportScroll state
337+
vScrollBy vp (if direction == KDown then 1 else -1)
331338
VtyEvent (EvKey k []) | k == KChar '\t' || k == KBackTab ->
332339
-- just two panes, so both keybindings just toggle the active one
333340
modify' toggleFocus

0 commit comments

Comments
 (0)