2018-02-27 06:47:07 +03:00
|
|
|
{-# LANGUAGE FlexibleContexts #-}
|
|
|
|
{-# LANGUAGE GADTs #-}
|
|
|
|
{-# LANGUAGE LambdaCase #-}
|
2018-09-01 19:02:15 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2018-02-27 06:47:07 +03:00
|
|
|
{-# LANGUAGE RankNTypes #-}
|
2018-09-01 19:02:15 +03:00
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
2018-10-14 03:28:02 +03:00
|
|
|
{-# OPTIONS_GHC -threaded #-}
|
2018-02-27 06:47:07 +03:00
|
|
|
|
2018-10-14 03:28:02 +03:00
|
|
|
import Control.Monad
|
2018-10-25 01:13:47 +03:00
|
|
|
import Control.Monad.Fix
|
2018-02-27 06:47:07 +03:00
|
|
|
import Control.Monad.IO.Class
|
2018-09-01 19:02:15 +03:00
|
|
|
import Control.Monad.Trans.Reader
|
2018-02-27 06:47:07 +03:00
|
|
|
import Data.Time
|
2018-10-14 03:28:02 +03:00
|
|
|
import qualified Graphics.Vty as V
|
2018-02-27 06:47:07 +03:00
|
|
|
import Reflex
|
|
|
|
import Reflex.Vty
|
2018-10-28 17:54:05 +03:00
|
|
|
import Reflex.Vty.Widget
|
2018-02-27 06:47:07 +03:00
|
|
|
|
|
|
|
main :: IO ()
|
2018-10-14 03:28:02 +03:00
|
|
|
main =
|
2018-10-28 17:54:05 +03:00
|
|
|
mainWidget $ do
|
2018-10-14 03:28:02 +03:00
|
|
|
inp <- input
|
|
|
|
tellShutdown . fforMaybe inp $ \case
|
|
|
|
V.EvKey V.KEsc _ -> Just ()
|
|
|
|
_ -> Nothing
|
|
|
|
|
2018-10-25 01:13:47 +03:00
|
|
|
debugInput
|
|
|
|
testBoxes
|
|
|
|
return ()
|
2018-10-14 03:28:02 +03:00
|
|
|
|
2018-10-25 01:13:47 +03:00
|
|
|
testBoxes :: (Reflex t, MonadHold t m, MonadFix m) => VtyWidget t m ()
|
|
|
|
testBoxes = do
|
|
|
|
size <- displaySize
|
|
|
|
let region1 = fmap (\(w,h) -> Region (w `div` 6) (h `div` 6) (w `div` 2) (h `div` 2)) size
|
|
|
|
region2 = fmap (\(w,h) -> Region (w `div` 4) (h `div` 4) (2 * (w `div` 3)) (2*(h `div` 3))) size
|
2018-10-28 23:37:26 +03:00
|
|
|
pane region1 (constDyn False) . box singleBoxStyle $ debugInput
|
|
|
|
pane region2 (constDyn True) . box singleBoxStyle $
|
|
|
|
splitVDrag (hRule doubleBoxStyle) (box roundedBoxStyle debugInput) (box roundedBoxStyle dragTest)
|
2018-10-25 01:13:47 +03:00
|
|
|
return ()
|
|
|
|
|
2018-10-28 17:54:05 +03:00
|
|
|
debugFocus :: (Reflex t, Monad m) => VtyWidget t m ()
|
|
|
|
debugFocus = do
|
|
|
|
f <- focus
|
|
|
|
string $ show <$> current f
|
|
|
|
|
2018-10-25 01:13:47 +03:00
|
|
|
debugInput :: (Reflex t, MonadHold t m) => VtyWidget t m ()
|
|
|
|
debugInput = do
|
|
|
|
lastEvent <- hold "No event yet" . fmap show =<< input
|
|
|
|
string lastEvent
|
2018-10-14 03:28:02 +03:00
|
|
|
|
2018-10-25 01:13:47 +03:00
|
|
|
dragTest :: (Reflex t, MonadHold t m, MonadFix m) => VtyWidget t m ()
|
|
|
|
dragTest = do
|
|
|
|
lastEvent <- hold "No event yet" . fmap show =<< drag V.BLeft
|
|
|
|
string lastEvent
|
2018-10-14 03:28:02 +03:00
|
|
|
|
|
|
|
testStringBox :: (Reflex t, Monad m) => VtyWidget t m ()
|
2018-10-28 23:37:26 +03:00
|
|
|
testStringBox = box singleBoxStyle .
|
2018-10-28 17:54:05 +03:00
|
|
|
string . pure . take 500 $ cycle ('\n' : ['a'..'z'])
|