Skip to content
This repository was archived by the owner on Dec 12, 2022. It is now read-only.

Use buffer caches to save rendered pages and prevent unnecessary re-rendering #21

@Frewacom

Description

@Frewacom

Most of the code for saving and restoring ncurses buffers has already been added, but they are currently not being used. The idea is that once a page has been rendered using the page tokens, we want to quickly be able to show it again without going through each token again.

The buffer cache array can store a maximum of MAX_PAGE_COLLECTION_SIZE as defined by:

#define MAX_PAGE_COLLECTION_SIZE 10

TTT/src/ui.c

Lines 11 to 27 in 2c833c4

static void save_view_buffer() {
assert(current_page_index >= 0);
assert(current_page_index < MAX_PAGE_COLLECTION_SIZE);
mvwinstr(content_win, PAGE_LINES, PAGE_COLS, page_cache[current_page_index]);
}
static void restore_page_buffer(int index) {
assert(index >= 0);
assert(index < MAX_PAGE_COLLECTION_SIZE);
if (page_cache[index][0] == '\0') {
return;
}
mvwaddstr(content_win, PAGE_LINES, PAGE_COLS, page_cache[index]);
page_cache[index][0] = '\0';
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    uiUser interface

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions