add proper scroll

This commit is contained in:
2024-06-02 06:33:54 +02:00
parent e8e0babfaa
commit 9bd8817797

9
main.c
View File

@@ -159,7 +159,7 @@ void input_string(int terminal_width, int terminal_height, char *buffer, int buf
void display_todos(int width, int height, int current_line) { void display_todos(int width, int height, int current_line) {
int current_y = 1; int current_y = 1;
int current_index = current_line; int current_index = 0;
const char *padding = "..."; const char *padding = "...";
unsigned long title_length = 0; unsigned long title_length = 0;
unsigned long padding_length = strlen(padding); unsigned long padding_length = strlen(padding);
@@ -168,8 +168,13 @@ void display_todos(int width, int height, int current_line) {
attron(COLOR_PAIR(DEFAULT_PAIR)); attron(COLOR_PAIR(DEFAULT_PAIR));
// TODO: Use an offset or something // calculate the offset
if (height - 4 <= current_line) {
// ignore the first n todos
current_index = current_line - (height - 4);
}
// while we have space to print todos
while (current_y < height - 2) { while (current_y < height - 2) {
// check if we're out of bounds // check if we're out of bounds
if (current_index >= arrlen(todos)) { if (current_index >= arrlen(todos)) {