Skip to content

Commit

Permalink
Add way to set text from the TextArea widget API
Browse files Browse the repository at this point in the history
  • Loading branch information
wiktor-obrebski committed Oct 9, 2024
1 parent e237387 commit 509a0c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/lua/gui/widgets/text_area.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ function TextArea:getText()
return self.subviews.text_area.text
end

function TextArea:setText(text)
return self.subviews.text_area:setText(text)
end

function TextArea:getCursor()
return self.subviews.text_area.cursor
end
Expand Down
17 changes: 17 additions & 0 deletions test/library/gui/widgets.TextArea.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2600,3 +2600,20 @@ function test.fast_rewind_reset_selection()

screen:dismiss()
end

function test.render_text_set_by_api()
local text_area, screen, window = arrange_textarea({w=80})

local text = table.concat({
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Pellentesque dignissim volutpat orci, sed molestie metus elementum vel.',
'Donec sit amet mattis ligula, ac vestibulum lorem.',
}, '\n')

text_area:setText(text)
text_area:setCursor(#text + 1)

expect.eq(read_rendered_text(text_area), text .. '_')

-- screen:dismiss()
end

0 comments on commit 509a0c1

Please sign in to comment.