In a windows console application I want to add a TUI (Terminal User Interface). I want to create some tabs. In a tab I want to show the logs of the application, so there must be many lines, I can append new lines and I should be able to scroll the area, in order to see the older logs. My problem is that I'm not able to create a scrolling area, even if I see the scrollbar.
This is the sample code:
#include
#include
#include
using namespace ftxui;
int main() {
auto screen = ScreenInteractive::Fullscreen();
// Create a scrollable area with many lines
Elements scroll_content;
for (int i = 0; i < 50; ++i) {
scroll_content.push_back(text("Line " + std::to_string(i)));
}
auto scrollable = Renderer([&] {
return vbox({
text("Top Widget"),
separator(),
vbox(scroll_content) | vscroll_indicator | frame | size(HEIGHT, LESS_THAN, 20),
separator(),
text("Bottom Widget"),
}) | border;
});
screen.Loop(scrollable);
}
And this is the result on my windows machine:

As you can see I've the scrollbar to the right side, but it does not work.
I'd like to achieve two results:
The area must be scrollable with arrow keys and/or mouse
When I add a new log line I want the panel to scrolls automatically to the end in order to see it.
How can I achieve those results?