mirror of
https://github.com/jtdaugherty/brick.git
synced 2024-11-26 17:13:57 +03:00
Merge pull request #376 from TristanCacqueray/edit-cursor-pos
Add Brick.Widgets.Edit.getCursorPosition
This commit is contained in:
commit
40a39b92d1
@ -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
|
||||
----
|
||||
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user