<commit_before>module Events.ChannelScroll where

import Prelude ()
import Prelude.Compat

import Brick
import qualified Graphics.Vty as Vty
import Lens.Micro.Platform

import Types
import State

onEventChannelScroll :: Vty.Event -> MH ()
onEventChannelScroll (Vty.EvResize _ _) =
    mh invalidateCache
onEventChannelScroll (Vty.EvKey Vty.KPageUp []) =
    channelPageUp
onEventChannelScroll (Vty.EvKey (Vty.KChar 'b') [Vty.MCtrl]) =
    loadMoreMessages
onEventChannelScroll (Vty.EvKey Vty.KPageDown []) =
    channelPageDown
onEventChannelScroll (Vty.EvKey Vty.KEsc []) = do
    csMode .= Main<commit_msg>Replaced scroll mode event handling with keybinding list<commit_after>module Events.ChannelScroll where

import Prelude ()
import Prelude.Compat

import Brick
import qualified Graphics.Vty as Vty
import Lens.Micro.Platform

import Types
import State

channelScrollKeybindings :: [Keybinding]
channelScrollKeybindings =
  [ KB "Load more messages in the current channel"
    (Vty.EvKey (Vty.KChar 'b') [Vty.MCtrl])
    loadMoreMessages
  , KB "Scroll up" (Vty.EvKey Vty.KPageUp [])
    channelPageUp
  , KB "Scroll down" (Vty.EvKey Vty.KPageDown [])
    channelPageDown
  , KB "Cancel scrolling and return to channel view"
    (Vty.EvKey Vty.KEsc []) $
    csMode .= Main
  ]

onEventChannelScroll :: Vty.Event -> MH ()
onEventChannelScroll (Vty.EvResize _ _) =
    mh invalidateCache
onEventChannelScroll e
  | Just kb <- lookupKeybinding e channelScrollKeybindings = kbAction kb
{'fraction_non_alphanumeric': 0.08809683927370544, 'fraction_numerical': 0.0, 'mean_word_length': 4.470588235294118, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777907', 'n_tokens_mistral': 501, 'n_tokens_neox': 484, 'n_words': 129}