From f0040bf3398763010a9f6e10f0b281b9ada1616a Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Tue, 11 Feb 2020 18:51:43 +0700 Subject: [PATCH] UI improvements --- src/Main.hs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index 9c6fb3c..6ac9e46 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -13,6 +13,7 @@ import Control.Exception import Control.Monad import Data.Aeson import qualified Data.ByteString.Lazy as B +import qualified Data.List as L import qualified Data.Map.Strict as M import qualified Graphics.Vty as Vty import Lens.Micro.Platform @@ -67,13 +68,10 @@ main = do where initialState = AppState M.empty draw :: AppState -> [Widget Name] - draw s = [hBox [vBox (txt <$> tickers s), - vBorder, - vBox (str <$> fmap (printEntry s qteLastPrice) (tickers s)), - vBorder, - vBox (str <$> fmap (printEntry s qteBid) (tickers s)), - vBorder, - vBox (str <$> fmap (printEntry s qteAsk) (tickers s))] ] + draw s = [hBox . L.intersperse vBorder $ hLimit 15 . padLeftRight 3 <$> [vBox ([str "Ticker", hBorder] ++ (txt <$> tickers s)), + vBox ([str "Last", hBorder] ++ (str <$> fmap (printEntry s qteLastPrice) (tickers s))), + vBox ([str "Bid", hBorder] ++ (str <$> fmap (printEntry s qteBid) (tickers s))), + vBox ([str "Ask", hBorder] ++ (str <$> fmap (printEntry s qteAsk) (tickers s)))] ] printEntry s l tickerId = case s ^. quotes . at tickerId of Just qte -> show $ qte ^. l Nothing -> "-"