Skip to content
This repository has been 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

Open
Frewacom opened this issue Feb 4, 2021 · 0 comments
Labels
ui User interface

Comments

@Frewacom
Copy link
Collaborator

Frewacom commented Feb 4, 2021

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';
}

@Frewacom Frewacom added the api Implementation of the API label Feb 4, 2021
@Frewacom Frewacom added this to To do in TTT - Terminal Text Tv via automation Feb 4, 2021
@Frewacom Frewacom added ui User interface and removed api Implementation of the API labels Feb 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ui User interface
Projects
Development

No branches or pull requests

1 participant