Shuffling through a text buffer to display in a textarea


On hardware the textarea starts to cause a significant drop in framerate while trying to scroll when having a large amount of text to display.

What MCU/Processor/Board and compiler are you using?

LVGL simulator for Visual Studios

What LVGL version are you using?

9.0.0 dev

What do you want to achieve?

I want to be able to limit the amount of characters to display in a textarea. When that limit is reached start removing the characters at the top of the textarea. If scrolling back up start adding back in the removed characters at the top and start removing the new characters from the bottom, so as to always stay below the set character limit.

What have you tried so far?


Unfortunately this didn’t help with the issue. So I must think of a work around, at about 15,000 characters scrolling on the textarea drops frames below 13fps and it no longer feels fluid.

My initial idea is in the lv_textarea_add_text check if the text you want to add would bring you over the preset textarea max length (set by lv_textarea_set_max_length). If true have two loops, an inner loop that just counts how many characters until you reached a new line '\n' and the outer checks if the current textarea’s text length + new text to add’s length - counter is less than the max length. Essentially loops through until it finds how many lines to remove until you new text can fit in without going over the max length.

The also make an event callback set for LV_EVENT_SCROLL on the textarea, use the indev to find the direction of the scroll. If scrolling up add characters in at the top (line by line) while remove characters at the bottom (line by line).

Code to reproduce

No, code at the moment. The idea (or my implementation of it) I had is failing utterly.