2014-04-17 03:44:44 +04:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
module Main where
|
|
|
|
|
|
|
|
import Graphics.Vty.Config
|
2014-04-24 06:07:19 +04:00
|
|
|
import Graphics.Vty.Input.Events
|
2014-04-17 03:44:44 +04:00
|
|
|
|
|
|
|
import Control.Applicative
|
|
|
|
import Control.Exception
|
|
|
|
import Control.Lens ((^.))
|
|
|
|
import Control.Monad
|
|
|
|
|
|
|
|
import Data.Default
|
|
|
|
import Data.String.QQ
|
|
|
|
|
|
|
|
import Test.Framework
|
|
|
|
import Test.Framework.Providers.HUnit
|
|
|
|
import Test.HUnit hiding (Test)
|
|
|
|
|
|
|
|
import Text.Printf
|
|
|
|
|
|
|
|
exampleConfig :: String
|
|
|
|
exampleConfig = [s|
|
2014-04-24 06:07:19 +04:00
|
|
|
-- comments should be ignored.
|
2014-06-03 10:06:43 +04:00
|
|
|
map _ "\ESC[B" KUp []
|
2014-04-24 06:07:19 +04:00
|
|
|
askfjla dfasjdflk jasdlkfj asdfj -- lines failing parse should be ignored
|
2014-06-03 10:06:43 +04:00
|
|
|
map _ "\ESC[1;3B" KDown [MAlt]
|
|
|
|
map "xterm" "\ESC[1;3B" KDown [MAlt]
|
|
|
|
map "xterm-256-color" "\ESC[1;3B" KDown [MAlt]
|
2014-05-26 10:28:15 +04:00
|
|
|
debugLog "/tmp/vty-debug.txt"
|
2014-04-17 03:44:44 +04:00
|
|
|
|]
|
|
|
|
|
2014-04-24 06:07:19 +04:00
|
|
|
exampleConfigConfig :: Config
|
2014-06-06 20:09:10 +04:00
|
|
|
exampleConfigConfig = def
|
|
|
|
{ debugLog = Just "/tmp/vty-debug.txt"
|
2014-06-05 10:26:41 +04:00
|
|
|
, inputMap = [ (Nothing, "\ESC[B", EvKey KUp [])
|
|
|
|
, (Nothing, "\ESC[1;3B", EvKey KDown [MAlt])
|
|
|
|
, (Just "xterm", "\ESC[1;3B", EvKey KDown [MAlt])
|
|
|
|
, (Just "xterm-256-color", "\ESC[1;3B", EvKey KDown [MAlt])
|
|
|
|
]
|
2014-04-24 06:07:19 +04:00
|
|
|
}
|
|
|
|
|
2014-04-17 03:44:44 +04:00
|
|
|
exampleConfigParses :: IO ()
|
2014-04-24 06:07:19 +04:00
|
|
|
exampleConfigParses = assertEqual "example config parses as expected"
|
|
|
|
exampleConfigConfig
|
|
|
|
(runParseConfig "exampleConfig" exampleConfig)
|
2014-04-17 03:44:44 +04:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain
|
|
|
|
[ testCase "example config parses" $ exampleConfigParses
|
|
|
|
]
|
|
|
|
|