From 3b604fd5af8b37e0f84f368e1d42a72e584a88cc Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Fri, 27 May 2016 11:20:34 -0700 Subject: [PATCH] EditDemo: remove list widget --- programs/EditDemo.hs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/programs/EditDemo.hs b/programs/EditDemo.hs index 99a83a7..51c1505 100644 --- a/programs/EditDemo.hs +++ b/programs/EditDemo.hs @@ -5,7 +5,6 @@ module Main where import Lens.Micro import Lens.Micro.TH -import qualified Data.Vector as DV import qualified Graphics.Vty as V import qualified Brick.Main as M @@ -19,7 +18,6 @@ import Brick.Widgets.Core , str ) import qualified Brick.Widgets.Center as C -import qualified Brick.Widgets.List as L import qualified Brick.Widgets.Edit as E import qualified Brick.AttrMap as A import qualified Brick.Focus as F @@ -27,14 +25,12 @@ import Brick.Util (on) data Name = Edit1 | Edit2 - | List1 deriving (Ord, Show, Eq) data St = St { _focusRing :: F.FocusRing Name , _edit1 :: E.Editor Name , _edit2 :: E.Editor Name - , _list1 :: L.List Name Int } makeLenses ''St @@ -42,18 +38,14 @@ makeLenses ''St drawUI :: St -> [T.Widget Name] drawUI st = [ui] where - theList = F.withFocusRing (st^.focusRing) (L.renderList drawElem) (st^.list1) e1 = F.withFocusRing (st^.focusRing) E.renderEditor (st^.edit1) e2 = F.withFocusRing (st^.focusRing) E.renderEditor (st^.edit2) - drawElem _ i = (str $ show i) <+> (vLimit 1 $ fill ' ') ui = C.center $ (str "Input 1 (unlimited): " <+> (hLimit 30 $ vLimit 5 e1)) <=> str " " <=> (str "Input 2 (limited to 2 lines): " <+> (hLimit 30 e2)) <=> str " " <=> - (str "Input 3: " <+> (hLimit 30 $ vLimit 3 theList)) <=> - str " " <=> str "Press Tab to switch between editors, Esc to quit." appEvent :: St -> V.Event -> T.EventM Name (T.Next St) @@ -66,23 +58,18 @@ appEvent st ev = _ -> M.continue =<< case F.focusGetCurrent (st^.focusRing) of Just Edit1 -> T.handleEventLensed st edit1 E.handleEditorEvent ev Just Edit2 -> T.handleEventLensed st edit2 E.handleEditorEvent ev - Just List1 -> T.handleEventLensed st list1 L.handleListEvent ev Nothing -> return st initialState :: St initialState = - St (F.focusRing [Edit1, Edit2, List1]) + St (F.focusRing [Edit1, Edit2]) (E.editor Edit1 (str . unlines) Nothing "") (E.editor Edit2 (str . unlines) (Just 2) "") - (L.list List1 (DV.fromList [1, 2, 3, 4, 5]) 1) theMap :: A.AttrMap theMap = A.attrMap V.defAttr [ (E.editAttr, V.white `on` V.blue) - , (L.listSelectedAttr, V.white `on` V.blue) - , (E.editFocusedAttr, V.black `on` V.yellow) - , (L.listSelectedFocusedAttr, V.black `on` V.yellow) ] appCursor :: St -> [T.CursorLocation Name] -> Maybe (T.CursorLocation Name)