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

Support cross platform vty 6.x with vty-crossplatform #1290

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
13 changes: 7 additions & 6 deletions lib/Echidna/UI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import Brick
import Brick.BChan
import Brick.Widgets.Dialog qualified as B
import Data.Sequence ((|>))
import Graphics.Vty (Config, Event(..), Key(..), Modifier(..), defaultConfig, inputMap, mkVty)
import Graphics.Vty (VtyUserConfig (..), Event(..), Key(..), Modifier(..))
import Graphics.Vty.CrossPlatform (mkVty)
import Graphics.Vty qualified as Vty
import System.Posix
import Echidna.UI.Widgets
Expand Down Expand Up @@ -243,12 +244,12 @@ stopWorkers :: MonadIO m => [(ThreadId, a)] -> m ()
stopWorkers workers =
forM_ workers $ \(threadId, _) -> liftIO $ killThread threadId

vtyConfig :: IO Config
vtyConfig :: IO VtyUserConfig
vtyConfig = do
config <- Vty.standardIOConfig
pure config { inputMap = (Nothing, "\ESC[6;2~", EvKey KPageDown [MShift]) :
(Nothing, "\ESC[5;2~", EvKey KPageUp [MShift]) :
inputMap defaultConfig }
config <- Vty.userConfig
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

The standardIOConfig has some unix specific configurations. From 6.x, it is gone. The closest is a function from vty-unix package.

pure config { configInputMap = (Nothing, "\ESC[6;2~", EvKey KPageDown [MShift]) :
(Nothing, "\ESC[5;2~", EvKey KPageUp [MShift]) :
configInputMap Vty.defaultConfig }

-- | Check if we should stop drawing (or updating) the dashboard, then do the right thing.
monitor :: MonadReader Env m => m (App UIState UIEvent Name)
Expand Down
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ when:
- brick
- unix
- vty
- vty-crossplatform

executables:
echidna:
Expand Down