Merge pull request #376 from TristanCacqueray/edit-cursor-pos

Add Brick.Widgets.Edit.getCursorPosition
This commit is contained in:
Jonathan Daugherty 2022-07-09 09:22:13 -07:00 committed by GitHub
commit 40a39b92d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,9 @@ Bug fixes:
* Fixed an issue where `tests/Render.hs` did not gracefully exit in the
presence of an unknown terminal.
API changes:
* Added `Brick.Widgets.Edit.getCursorPosition` helper function.
0.71
----

View File

@ -25,6 +25,7 @@ module Brick.Widgets.Edit
, editorText
-- * Reading editor contents
, getEditContents
, getCursorPosition
-- * Handling events
, handleEditorEvent
-- * Editing text
@ -202,6 +203,10 @@ editFocusedAttr = editAttr <> "focused"
getEditContents :: Monoid t => Editor t n -> [t]
getEditContents e = Z.getText $ e^.editContentsL
-- | Get the cursor position of the editor (row, column)
getCursorPosition :: Editor t n -> (Int, Int)
getCursorPosition e = Z.cursorPosition $ e^.editContentsL
-- | Turn an editor state value into a widget. This uses the editor's
-- name for its scrollable viewport handle and the name is also used to
-- report mouse events.