From e7117322149fdc0196acb49c2ae0ff32e2c299c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Tom=C3=A1s?= Date: Mon, 6 Apr 2020 00:07:32 -0300 Subject: Fix text not rendering until first key press --- test/page.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/page.c b/test/page.c index 322adf2..8dd2c90 100644 --- a/test/page.c +++ b/test/page.c @@ -14,6 +14,18 @@ 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]); + } + int input = getch(); clear(); switch (input) { @@ -29,17 +41,6 @@ int main() { default: insert_into_page(p, input); } - 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]); - } } endwin(); -- cgit v1.2.3