mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-12-02 01:45:50 +03:00
Implement support for the new PositionOnly constructor
The API putCursor will request positioning but keep cursor invisible.
This commit is contained in:
parent
d95cc7f839
commit
ca8b1bae67
@ -115,7 +115,7 @@ library
|
||||
Brick.Widgets.Internal
|
||||
|
||||
build-depends: base < 4.16.0.0,
|
||||
vty >= 5.31,
|
||||
vty >= 5.33,
|
||||
transformers,
|
||||
data-clist >= 0.1,
|
||||
directory >= 1.2.5.0,
|
||||
|
@ -441,7 +441,10 @@ renderApp vty app appState rs = do
|
||||
rs
|
||||
picWithCursor = case theCursor of
|
||||
Nothing -> pic { picCursor = NoCursor }
|
||||
Just cloc -> pic { picCursor = AbsoluteCursor (cloc^.locationColumnL)
|
||||
Just cloc -> pic { picCursor = (if cursorLocationVisible cloc
|
||||
then AbsoluteCursor
|
||||
else PositionOnly True)
|
||||
(cloc^.locationColumnL)
|
||||
(cloc^.locationRowL)
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ module Brick.Types.Internal
|
||||
, CursorLocation(..)
|
||||
, cursorLocationL
|
||||
, cursorLocationNameL
|
||||
, cursorLocationVisibleL
|
||||
, Context(..)
|
||||
, EventState(..)
|
||||
, EventRO(..)
|
||||
@ -164,6 +165,8 @@ data CursorLocation n =
|
||||
-- ^ The location
|
||||
, cursorLocationName :: !(Maybe n)
|
||||
-- ^ The name of the widget associated with the location
|
||||
, cursorLocationVisible :: !Bool
|
||||
-- ^ Weather the cursor should actually be visible
|
||||
}
|
||||
deriving (Read, Show, Generic, NFData)
|
||||
|
||||
|
@ -59,6 +59,7 @@ module Brick.Widgets.Core
|
||||
|
||||
-- * Cursor placement
|
||||
, showCursor
|
||||
, putCursor
|
||||
|
||||
-- * Naming
|
||||
, Named(..)
|
||||
@ -994,7 +995,16 @@ showCursor :: n -> Location -> Widget n -> Widget n
|
||||
showCursor n cloc p =
|
||||
Widget (hSize p) (vSize p) $ do
|
||||
result <- render p
|
||||
return $ result & cursorsL %~ (CursorLocation cloc (Just n):)
|
||||
return $ result & cursorsL %~ (CursorLocation cloc (Just n) True:)
|
||||
|
||||
-- | When rendering the specified widget, also register a cursor
|
||||
-- positioning request using the specified name and location.
|
||||
-- The cursor will only be positioned but not made visible.
|
||||
putCursor :: n -> Location -> Widget n -> Widget n
|
||||
putCursor n cloc p =
|
||||
Widget (hSize p) (vSize p) $ do
|
||||
result <- render p
|
||||
return $ result & cursorsL %~ (CursorLocation cloc (Just n) False:)
|
||||
|
||||
hRelease :: Widget n -> Maybe (Widget n)
|
||||
hRelease p =
|
||||
|
@ -798,7 +798,7 @@ renderFileInfo foc maxLen selFiles n listSel info =
|
||||
addAttr = maybe id (withDefAttr . attrForFileType) (fileInfoFileType info)
|
||||
body = addAttr (hLimit (maxLen + 1) $
|
||||
padRight Max $
|
||||
(if foc && listSel then showCursor n (Location (0,0)) else id) $
|
||||
(if foc && listSel then putCursor n (Location (0,0)) else id) $
|
||||
str $ fileInfoSanitizedFilename info <> suffix)
|
||||
suffix = (if fileInfoFileType info == Just Directory then "/" else "") <>
|
||||
(if sel then "*" else "")
|
||||
|
Loading…
Reference in New Issue
Block a user