Add TerminalLocation instance for CursorLocation

This commit is contained in:
Jonathan Daugherty 2015-07-01 00:05:27 -07:00
parent 3e422dd8df
commit e1a1f90a98
3 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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