From e1a1f90a9837ae238cf20971cd51d215a35fc268 Mon Sep 17 00:00:00 2001 From: Jonathan Daugherty Date: Wed, 1 Jul 2015 00:05:27 -0700 Subject: [PATCH] Add TerminalLocation instance for CursorLocation --- src/Brick/Core.hs | 4 ++++ src/Brick/Main.hs | 2 +- src/Brick/Widgets/Internal.hs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Brick/Core.hs b/src/Brick/Core.hs index 4750407..a5e031e 100644 --- a/src/Brick/Core.hs +++ b/src/Brick/Core.hs @@ -60,6 +60,10 @@ data CursorLocation = makeLenses ''CursorLocation +instance TerminalLocation CursorLocation where + column = cursorLocation._1 + row = cursorLocation._2 + class HandleEvent a where handleEvent :: Event -> a -> a diff --git a/src/Brick/Main.hs b/src/Brick/Main.hs index 8323015..9e888c5 100644 --- a/src/Brick/Main.hs +++ b/src/Brick/Main.hs @@ -211,7 +211,7 @@ renderApp vty app appState rs = do rs picWithCursor = case theCursor of Nothing -> pic { picCursor = NoCursor } - Just (CursorLocation loc _) -> pic { picCursor = Cursor (loc^.column) (loc^.row) } + Just loc -> pic { picCursor = Cursor (loc^.column) (loc^.row) } update vty picWithCursor diff --git a/src/Brick/Widgets/Internal.hs b/src/Brick/Widgets/Internal.hs index 5d7c429..892d995 100644 --- a/src/Brick/Widgets/Internal.hs +++ b/src/Brick/Widgets/Internal.hs @@ -188,7 +188,7 @@ addVisibilityOffset off r = r & visibilityRequests.each.vrPosition %~ (off <>) addCursorOffset :: Location -> Result -> Result addCursorOffset off r = let onlyVisible = filter isVisible - isVisible (CursorLocation loc _) = loc^.column >= 0 && loc^.row >= 0 + isVisible loc = loc^.column >= 0 && loc^.row >= 0 in r & cursors %~ (\cs -> onlyVisible $ (`clOffset` off) <$> cs) unrestricted :: Int