Hyperlinks now fully supported, also on textgrids.
authorrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Sat, 16 Jan 2010 20:48:24 +0000 (20:48 +0000)
committerrodin <rodin@ddfedd41-794f-dd11-ae45-00112f111e67>
Sat, 16 Jan 2010 20:48:24 +0000 (20:48 +0000)
Try it with styletest.so

libchimara/hyperlink.c
tests/styletest.c

index a2795bdc83fb0861e598a3adaa626d1fcb04c884..6a0426a4ffd9c043f5ef9c2b7e3dedc9caec73d4 100644 (file)
@@ -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);
 }
index 3cfd15ea63051fa542a1142599149cc8f15b19f4..33d7ce440f918e0e4632a888fbf994c154654273 100644 (file)
@@ -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