summaryrefslogtreecommitdiff
path: root/test/page.c
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-23 06:34:01 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2020-04-23 06:34:01 -0300
commit6947a5feb7c21c454eb1f297cc0b792e21b564c6 (patch)
tree3dbe0210e327def6f824b2ed9ea4254a9d4585fc /test/page.c
parentf0ac81b432384b8763ec737e88d6675228e13c33 (diff)
downloadjet-6947a5feb7c21c454eb1f297cc0b792e21b564c6.tar.gz
jet-6947a5feb7c21c454eb1f297cc0b792e21b564c6.zip
Update tests
Testing pages and points are now separate.
Diffstat (limited to 'test/page.c')
-rw-r--r--test/page.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/page.c b/test/page.c
new file mode 100644
index 0000000..f558fc6
--- /dev/null
+++ b/test/page.c
@@ -0,0 +1,48 @@
+#include <curses.h>
+
+#define PAGE_SIZE 32
+#include "../page.c"
+
+int main() {
+ int exit = 0;
+ struct page *page = new_page();
+
+ initscr();
+ cbreak();
+ noecho();
+ nonl();
+ intrflush(stdscr, FALSE);
+ keypad(stdscr, TRUE);
+
+ while (!exit) {
+ clear();
+
+ for (int i = 0; i < page->gap_start; i++) {
+ addch(page->elements[i]);
+ }
+ for (int i = page->gap_start; i < page->gap_end; i++) {
+ addch('.');
+ }
+ for (int i = page->gap_end; i < PAGE_SIZE; i++) {
+ addch(page->elements[i]);
+ }
+
+ int input = getch();
+ switch (input) {
+ case KEY_LEFT:
+ move_gap_backward(page);
+ break;
+ case KEY_RIGHT:
+ move_gap_forward(page);
+ break;
+ case KEY_BACKSPACE:
+ delete_at_gap(page);
+ break;
+ default:
+ insert_at_gap(page, input);
+ }
+ }
+
+ endwin();
+ return 0;
+}