Compare commits
No commits in common. "980a7c890194390ff39de9fa7e12ce801361ccb5" and "9bb42bd7c9428c48153a86544cb67013036256a0" have entirely different histories.
980a7c8901
...
9bb42bd7c9
1 changed files with 8 additions and 24 deletions
|
@ -3,10 +3,11 @@
|
|||
module Zenith.CLI where
|
||||
|
||||
import Control.Monad (void)
|
||||
import Control.Monad.State (modify)
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Text as T
|
||||
import qualified Graphics.Vty as V
|
||||
import Lens.Micro ((&), (.~), (^.), set)
|
||||
import Lens.Micro ((^.))
|
||||
import Lens.Micro.Mtl
|
||||
import Lens.Micro.TH
|
||||
|
||||
|
@ -19,12 +20,9 @@ import qualified Brick.Widgets.Border as B
|
|||
import Brick.Widgets.Border.Style (unicode)
|
||||
import qualified Brick.Widgets.Center as C
|
||||
import Brick.Widgets.Core
|
||||
( Padding(..)
|
||||
, (<+>)
|
||||
, (<=>)
|
||||
( (<+>)
|
||||
, hLimit
|
||||
, joinBorders
|
||||
, padRight
|
||||
, str
|
||||
, vBox
|
||||
, vLimit
|
||||
|
@ -42,11 +40,10 @@ data Name
|
|||
deriving (Eq, Show, Ord)
|
||||
|
||||
data State = State
|
||||
{ _network :: !String
|
||||
, _wallets :: !(L.List Name String)
|
||||
, _addresses :: !(L.List Name String)
|
||||
, _transactions :: !(L.List Name String)
|
||||
, _msg :: !String
|
||||
{ _network :: String
|
||||
, _wallets :: L.List Name String
|
||||
, _addresses :: L.List Name String
|
||||
, _transactions :: L.List Name String
|
||||
} deriving (Show)
|
||||
|
||||
makeLenses ''State
|
||||
|
@ -60,8 +57,7 @@ drawUI s = [ui s]
|
|||
withBorderStyle unicode $
|
||||
B.borderWithLabel (str $ "Zenith - " <> s ^. network) $
|
||||
(C.center (listBox "Addresses" (s ^. addresses)) <+>
|
||||
B.vBorder <+> C.center (listBox "Transactions" (s ^. transactions))) <=>
|
||||
msgBox (s ^. msg)
|
||||
B.vBorder <+> C.center (listBox "Transactions" (s ^. transactions)))
|
||||
listBox :: String -> L.List Name String -> Widget Name
|
||||
listBox titleLabel l =
|
||||
C.vCenter $
|
||||
|
@ -72,10 +68,6 @@ drawUI s = [ui s]
|
|||
, str " "
|
||||
, C.hCenter $ str "Select "
|
||||
]
|
||||
msgBox :: String -> Widget Name
|
||||
msgBox m =
|
||||
vBox
|
||||
[B.hBorderWithLabel (str "Messages"), hLimit 70 $ padRight Max $ str m]
|
||||
|
||||
listDrawElement :: (Show a) => Bool -> a -> Widget Name
|
||||
listDrawElement sel a =
|
||||
|
@ -92,7 +84,6 @@ initialState =
|
|||
(L.list WList (Vec.fromList ["wall1"]) 1)
|
||||
(L.list AList (Vec.fromList ["addr1", "addr2"]) 1)
|
||||
(L.list TList (Vec.fromList ["tx1", "tx2", "tx3"]) 1)
|
||||
"Start up Ok!"
|
||||
|
||||
customAttr :: A.AttrName
|
||||
customAttr = L.listSelectedAttr <> A.attrName "custom"
|
||||
|
@ -101,14 +92,7 @@ appEvent :: BT.BrickEvent Name e -> BT.EventM Name State ()
|
|||
appEvent (BT.VtyEvent e) =
|
||||
case e of
|
||||
V.EvKey V.KEsc [] -> M.halt
|
||||
V.EvKey (V.KChar 'c') [] -> printMsg "You pressed C!"
|
||||
V.EvKey (V.KChar 's') [] -> printMsg "You pressed S!"
|
||||
ev -> BT.zoom addresses $ L.handleListEvent ev
|
||||
where
|
||||
printMsg :: String -> BT.EventM Name State ()
|
||||
printMsg s = BT.modify $ updateMsg s
|
||||
updateMsg :: String -> State -> State
|
||||
updateMsg = set msg
|
||||
|
||||
theMap :: A.AttrMap
|
||||
theMap =
|
||||
|
|
Loading…
Reference in a new issue