data TuiState = TuiState { lines :: V.Vector BC.ByteString , topLine :: Int } deriving (Show, Eq)
drawTui :: TuiState -> [Widget Name]
drawTui (TuiState lines topLine) = [viewport Viewport1 Vertical $ str $ BC.unpack $ BC.unlines $ V.toList $ V.drop topLine lines] handleTuiEvent :: TuiState -> BrickEvent Name e -> EventM Name (Next TuiState) handleTuiEvent s@(TuiState lines topLine) e = case e of VtyEvent vtye -> case vtye of EvKey (KChar 'q') [] -> halt s EvKey (KChar 'j') [] -> do let vp = viewportScroll Viewport1 vScrollBy vp 1 continue s EvKey (KChar 'k') [] -> do let vp = viewportScroll Viewport1 vScrollBy vp (-1) continue s EvKey (KChar 'g') [] -> do c <- getEnv "LINES" continue $ TuiState lines (topLine + (read c)) _ -> continue s _ -> continue s
9 Dec |