X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=src%2Fgridtest.c;h=4c59f1dda068aa9ac7cbb02ee62a3fc23b17e674;hb=3c678195610789166e1133575789f25da8f1a291;hp=252d5d0e5e8a72bcca51ca3afdf6ddcc30f4cd50;hpb=352f99218b90bc9a3e5386afc3f12c36c3ebec60;p=rodin%2Fchimara.git diff --git a/src/gridtest.c b/src/gridtest.c index 252d5d0..4c59f1d 100644 --- a/src/gridtest.c +++ b/src/gridtest.c @@ -1,10 +1,11 @@ -#include "stdio.h" +#include +#include #include "glk.h" void glk_main(void) { event_t ev; - winid_t mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); + winid_t mainwin = glk_window_open(0, 0, 0, wintype_TextGrid, 0); if(!mainwin) return; @@ -12,16 +13,66 @@ void glk_main(void) glk_put_string("Philip en Marijn zijn vet goed.\n"); glk_put_string("A veeeeeeeeeeeeeeeeeeeeeeeeeeeery looooooooooooooooooooooooong striiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiing.\n"); + int count; + for(count = 0; count < 30; count++) + glk_put_string("I want to write past the end of this text buffer! "); + guint32 width, height; glk_window_get_size(mainwin, &width, &height); - fprintf(stderr, "\nWidth: %d\nHeight: %d\n", width, height); + fprintf(stderr, "\nWidth: %d\nHeight: %d\nPress a key in the window, not in the terminal.\n", width, height); + glk_request_char_event(mainwin); + while(1) { + glk_select(&ev); + if(ev.type == evtype_CharInput) + break; + } + + glk_window_move_cursor(mainwin, 15, 15); + glk_put_string(". . "); + glk_window_move_cursor(mainwin, 15, 16); + glk_put_string(" . ."); + glk_window_move_cursor(mainwin, 15, 17); + glk_put_string(". . "); + glk_window_move_cursor(mainwin, 15, 18); + glk_put_string(" . ."); + fprintf(stderr, "Cursor location test.\nPress another key.\n"); + glk_request_char_event(mainwin); + while(1) { + glk_select(&ev); + if(ev.type == evtype_CharInput) + break; + } + gchar *buffer = g_malloc0(256); + + fprintf(stderr, "Line input field until end of line\n"); + glk_window_move_cursor(mainwin, 10, 20); + glk_request_line_event(mainwin, buffer, 256, 0); + while(1) { + glk_select(&ev); + if(ev.type == evtype_LineInput) + break; + } + + fprintf(stderr, "Now edit your previous line input\n"); + glk_window_move_cursor(mainwin, 10, 22); + glk_request_line_event(mainwin, buffer, 256, strlen(buffer)); + while(1) { + glk_select(&ev); + if(ev.type == evtype_LineInput) + break; + } + + gchar *text = g_strndup(buffer, ev.val1); + fprintf(stderr, "Your string was: '%s'.\nPress another key to clear the window and exit.\n", text); + g_free(text); glk_request_char_event(mainwin); while(1) { glk_select(&ev); - if(ev.type == evtype_CharInput) { - glk_window_get_size(mainwin, &width, &height); - fprintf(stderr, "\nWidth: %d\nHeight: %d\n", width, height); - } + if(ev.type == evtype_CharInput) + break; } -} \ No newline at end of file + + glk_window_clear(mainwin); + g_free(buffer); +}