From 6fadb5234d9e294dbc65cde416a288616f37b400 Mon Sep 17 00:00:00 2001 From: rodin Date: Sat, 16 Jan 2010 20:48:24 +0000 Subject: [PATCH] Hyperlinks now fully supported, also on textgrids. Try it with styletest.so --- libchimara/hyperlink.c | 6 +++--- tests/styletest.c | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/libchimara/hyperlink.c b/libchimara/hyperlink.c index a2795bd..6a0426a 100644 --- a/libchimara/hyperlink.c +++ b/libchimara/hyperlink.c @@ -56,7 +56,7 @@ glk_set_hyperlink_stream(strid_t str, glui32 linkval) g_return_if_fail(str != NULL); g_return_if_fail(str->type == STREAM_TYPE_WINDOW); g_return_if_fail(str->window != NULL); - g_return_if_fail(str->window->type == wintype_TextBuffer); + g_return_if_fail(str->window->type == wintype_TextBuffer || str->window->type == wintype_TextGrid); flush_window_buffer(str->window); @@ -138,7 +138,7 @@ glk_request_hyperlink_event(winid_t win) { VALID_WINDOW(win, return); g_return_if_fail(win != NULL); - g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid); + g_return_if_fail(win->type == wintype_TextBuffer || win->type == wintype_TextGrid); g_hash_table_foreach(win->hyperlinks, hyperlink_unblock_event_handler, NULL); @@ -156,7 +156,7 @@ glk_cancel_hyperlink_event(winid_t win) { VALID_WINDOW(win, return); g_return_if_fail(win != NULL); - g_return_if_fail(win->type != wintype_TextBuffer || win->type != wintype_TextGrid); + g_return_if_fail(win->type == wintype_TextBuffer || win->type == wintype_TextGrid); g_hash_table_foreach(win->hyperlinks, hyperlink_block_event_handler, NULL); } diff --git a/tests/styletest.c b/tests/styletest.c index 3cfd15e..33d7ce4 100644 --- a/tests/styletest.c +++ b/tests/styletest.c @@ -9,6 +9,7 @@ void do_style_test(); void do_link_test(); winid_t mainwin; +winid_t statuswin; void glk_main(void) { @@ -16,6 +17,8 @@ void glk_main(void) mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); if(!mainwin) return; + + statuswin = glk_window_open(mainwin, winmethod_Above | winmethod_Fixed, 3, wintype_TextGrid, 1); glk_set_window(mainwin); @@ -51,6 +54,11 @@ void glk_main(void) glk_put_string("Link 1 was clicked\n"); if(ev.val1 == 2) glk_put_string("Link 2 was clicked\n"); + if(ev.val1 == 3) + glk_put_string("Link 3 was clicked\n"); + if(ev.val1 == 4) + glk_put_string("Link 4 was clicked\n"); + glk_request_line_event(mainwin, buffer, 255, 0); } } @@ -100,12 +108,26 @@ do_style_test() { void do_link_test() { + glk_set_window(mainwin); glk_set_hyperlink(1); glk_put_string("This is link 1\n"); glk_set_hyperlink(2); glk_put_string("This is link 2\n"); glk_set_hyperlink(0); + + glk_set_window(statuswin); + glk_set_hyperlink(3); + glk_window_move_cursor(statuswin, 0, 0); + glk_put_string("This is link 3\n"); + glk_set_hyperlink(4); + glk_window_move_cursor(statuswin, 0, 1); + glk_put_string("This is link 4\n"); + glk_set_hyperlink(0); + glk_request_hyperlink_event(mainwin); + glk_request_hyperlink_event(statuswin); + + glk_set_window(mainwin); } void -- 2.30.2