Cursor: add PositionOnly constructor for cursor placement without visibility

This commit is contained in:
Jonathan Daugherty 2020-12-06 17:17:20 -08:00
parent 6fead08444
commit fd90f7dc85
2 changed files with 14 additions and 0 deletions

View File

@ -207,6 +207,12 @@ outputPicture dc pic = do
AbsoluteCursor x y ->
writeShowCursor dc `mappend`
writeMoveCursor dc (clampX x) (clampY y)
PositionOnly isAbs x y ->
if isAbs
then writeMoveCursor dc (clampX x) (clampY y)
else let (ox, oy) = charToOutputPos m (clampX x, clampY y)
m = cursorOutputMap ops $ picCursor pic
in writeMoveCursor dc (clampX ox) (clampY oy)
Cursor x y ->
let m = cursorOutputMap ops $ picCursor pic
(ox, oy) = charToOutputPos m (clampX x, clampY y)

View File

@ -82,6 +82,14 @@ data Cursor =
NoCursor
-- | Show the cursor at the given logical column accounting for
-- character width in the presence of multi-column characters.
| PositionOnly !Bool !Int !Int
-- | Set the terminal's cursor position without displaying a cursor
-- character. This is important for accessibility with screen
-- readers where a cursor position needs to be reported but we may
-- not want to show a block cursor in that location for cosmetic
-- reasons. The boolean argument indicates whether the positioning
-- should be absolute as with 'AbsoluteCursor' ('True') or logical
-- as with 'Cursor' ('False').
| Cursor !Int !Int
-- | Show the cursor at the given absolute terminal column and row
| AbsoluteCursor !Int !Int