Scroll lots of lines in a performant way #304
-
Hello, I am attempting to simply read in some large log files and merge them. Then show the merged log lines with the ability to scroll. I have plans to colorize certain parts of the log entry etc. There is more than 150,000 lines merged and parsed. I am using the However, right now I am getting poor performance. The highlight and scroll has a large delay making the app unusable when going through the lines. int main(int argc, const char *argv[]) {
if (argc != 3) {
LOG_ERROR("Incorrect arguments provided");
return EXIT_FAILURE;
}
std::vector<std::string> lines;
readLogFiles(argv[1], argv[2], lines);
int selected {0};
auto menu {Menu(&lines, &selected)};
auto scroller {Renderer(menu, [&]() {
return menu->Render() | frame | border;
})};
auto screen = ScreenInteractive::Fullscreen();
screen.Loop(scroller);
return EXIT_SUCCESS; Any tips or suggestions on how to make the refresh faster for hundred thousands of lines? Thank you kindly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Yes, you can reimplement the menu yourself and draw only a shorter range? Here, I am rewriting the Render() method from the normal Menu. For instance: int selected_line = 0;
std::vector<std::string> lines;
auto menu = Menu(&selected_line, &lines);
auto my_custom_menu = Renderer(menu, [&] {
int begin = std::max(0, selected_lines - 10);
int end = std::min(lines.size(), selected_lines + 10)
Elements elements;
for(int i = begin; i<end; ++i) {
Element element = text(lines[i]);
if (i == selected_line)
element = element | inverted | selected;
element.push_back(element);
}
return vbox(std::move(elements)) | vscroll_indicator | frame | border;
}); You may also want to create your own Component by deriving from ComponentBase. |
Beta Was this translation helpful? Give feedback.
Hi @matthesoundman
Yes, you can reimplement the menu yourself and draw only a shorter range?
Here, I am rewriting the Render() method from the normal Menu.
For instance:
Y…