mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-12 12:23:21 +03:00
Add TerminalLocation instance for CursorLocation
This commit is contained in:
parent
3e422dd8df
commit
e1a1f90a98
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user