Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inputMap (issue #474) #503

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/Echidna/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Data.Has (Has(..))
import Data.Maybe (fromMaybe)
import Data.IORef
import EVM (VM)
import Graphics.Vty (Event(..), Key(..), Modifier(..), defaultConfig, mkVty)
import Graphics.Vty (Config, Event(..), Key(..), Modifier(..), defaultConfig, inputMap, mkVty)
import System.Posix.Terminal (queryTerminal)
import System.Posix.Types (Fd(..))
import UnliftIO (MonadUnliftIO)
Expand Down Expand Up @@ -55,6 +55,12 @@ makeLenses ''UIConf

data CampaignEvent = CampaignUpdated Campaign | CampaignTimedout Campaign

vtyConfig :: Config
vtyConfig = defaultConfig { inputMap = (Nothing, "\ESC[6;2~", EvKey KPageDown [MShift]) :
(Nothing, "\ESC[5;2~", EvKey KPageUp [MShift]) :
inputMap defaultConfig
}

-- | Check if we should stop drawing (or updating) the dashboard, then do the right thing.
monitor :: (MonadReader x m, Has CampaignConf x, Has Names x, Has TxConf x)
=> m (App (Campaign, UIState) CampaignEvent ())
Expand Down Expand Up @@ -105,7 +111,7 @@ ui v w ts d txs = do
Just _ -> liftIO $ updateUI CampaignUpdated
)
(const $ liftIO $ killThread ticker)
app <- customMain (mkVty defaultConfig) (Just bc) <$> monitor
app <- customMain (mkVty vtyConfig) (Just bc) <$> monitor
liftIO $ void $ app (defaultCampaign, Uninitialized)
final <- liftIO $ readIORef ref
liftIO . putStrLn =<< ppCampaign final
Expand Down