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
|
makeLenses ''CursorLocation
|
||||||
|
|
||||||
|
instance TerminalLocation CursorLocation where
|
||||||
|
column = cursorLocation._1
|
||||||
|
row = cursorLocation._2
|
||||||
|
|
||||||
class HandleEvent a where
|
class HandleEvent a where
|
||||||
handleEvent :: Event -> a -> a
|
handleEvent :: Event -> a -> a
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ renderApp vty app appState rs = do
|
|||||||
rs
|
rs
|
||||||
picWithCursor = case theCursor of
|
picWithCursor = case theCursor of
|
||||||
Nothing -> pic { picCursor = NoCursor }
|
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
|
update vty picWithCursor
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ addVisibilityOffset off r = r & visibilityRequests.each.vrPosition %~ (off <>)
|
|||||||
addCursorOffset :: Location -> Result -> Result
|
addCursorOffset :: Location -> Result -> Result
|
||||||
addCursorOffset off r =
|
addCursorOffset off r =
|
||||||
let onlyVisible = filter isVisible
|
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)
|
in r & cursors %~ (\cs -> onlyVisible $ (`clOffset` off) <$> cs)
|
||||||
|
|
||||||
unrestricted :: Int
|
unrestricted :: Int
|
||||||
|
Loading…
Reference in New Issue
Block a user