From b53f79ce5440246ff0f2e6002f13cfbee1df6226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Tue, 21 Apr 2020 11:32:57 -0300 Subject: Update page test --- test/page.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'test/page.c') diff --git a/test/page.c b/test/page.c index 8dd2c90..0d4dd33 100644 --- a/test/page.c +++ b/test/page.c @@ -4,7 +4,9 @@ int main() { int exit = 0; - struct page *p = new_page(); + struct page *page = new_page(); + struct point point = {0}; + point.current_page = page; initscr(); cbreak(); @@ -14,32 +16,36 @@ int main() { keypad(stdscr, TRUE); while (!exit) { - int gap_start = p->gap_start - p->buffer; - int gap_end = p->gap_end - p->buffer; - for (int i = 0; i < gap_start; i++) { - addch(p->buffer[i]); - } - for (int i = gap_start; i < gap_end; i++) { - addch('_'); - } - for (int i = gap_end; i < PAGE_SIZE; i++) { - addch(p->buffer[i]); + clear(); + + struct page *iter = page; + while (iter) { + addch('|'); + for (int i = 0; i < iter->gap_start; i++) { + addch(iter->buffer[i]); + } + for (int i = iter->gap_start; i < iter->gap_end; i++) { + addch('_'); + } + for (int i = iter->gap_end; i < PAGE_SIZE; i++) { + addch(iter->buffer[i]); + } + iter = iter->next; } int input = getch(); - clear(); switch (input) { case KEY_LEFT: - move_gap(p, -1); + move_point_backward(&point); break; case KEY_RIGHT: - move_gap(p, 1); + move_point_forward(&point); break; case KEY_BACKSPACE: - delete_from_page(p); + delete_at_point(&point); break; default: - insert_into_page(p, input); + insert_at_point(&point, input); } } -- cgit v1.2.3