import Brick import qualified Brick.Widgets.Edit as E import qualified Graphics.Vty as V data Name = Text deriving (Ord, Show, Eq) type St = E.Editor Name initialState :: St initialState = E.editor Text (str . unlines) Nothing "" drawUI :: St -> [Widget Name] drawUI st = [E.renderEditor True st] appCursor :: St -> [CursorLocation Name] -> Maybe (CursorLocation Name) appCursor st c = Just (head c) appEvent :: St -> V.Event -> EventM Name (Next St) appEvent st ev = case ev of V.EvKey V.KEsc [] -> halt st _ -> continue =<< E.handleEditorEvent ev st theApp :: App St V.Event Name theApp = App { appDraw = drawUI , appChooseCursor = appCursor , appHandleEvent = appEvent , appStartEvent = return , appAttrMap = const (attrMap V.defAttr [ ]) , appLiftVtyEvent = id } main = do st <- defaultMain theApp initialState putStrLn $ unlines $ E.getEditContents $ st