on master help sign in
Cursor: add PositionOnly constructor for cursor placement without visibility
commitfd90f7dc852702962080b26c550c68544214d21a authorJonathan Daugherty <cygnus@foobox.com> dateSun 6 Dec 2020, 17:17 (6 years ago) parent6fead08
2 files changed+14
src/Graphics/Vty/Output/Interface.hs+6 src/Graphics/Vty/Picture.hs+8
src/Graphics/Vty/Output/Interface.hs+6
@@ -207,6 +207,12 @@ outputPicture dc pic = do
207207 AbsoluteCursor x y ->
208208 writeShowCursor dc `mappend`
209209 writeMoveCursor dc (clampX x) (clampY y)
210+ PositionOnly isAbs x y ->
211+ if isAbs
212+ then writeMoveCursor dc (clampX x) (clampY y)
213+ else let (ox, oy) = charToOutputPos m (clampX x, clampY y)
214+ m = cursorOutputMap ops $ picCursor pic
215+ in writeMoveCursor dc (clampX ox) (clampY oy)
210216 Cursor x y ->
211217 let m = cursorOutputMap ops $ picCursor pic
212218 (ox, oy) = charToOutputPos m (clampX x, clampY y)
src/Graphics/Vty/Picture.hs+8
@@ -82,6 +82,14 @@ data Cursor =
8282 NoCursor
8383 -- | Show the cursor at the given logical column accounting for
8484 -- character width in the presence of multi-column characters.
85+ | PositionOnly !Bool !Int !Int
86+ -- | Set the terminal's cursor position without displaying a cursor
87+ -- character. This is important for accessibility with screen
88+ -- readers where a cursor position needs to be reported but we may
89+ -- not want to show a block cursor in that location for cosmetic
90+ -- reasons. The boolean argument indicates whether the positioning
91+ -- should be absolute as with 'AbsoluteCursor' ('True') or logical
92+ -- as with 'Cursor' ('False').
8593 | Cursor !Int !Int
8694 -- | Show the cursor at the given absolute terminal column and row
8795 | AbsoluteCursor !Int !Int