X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fwindow.c;h=7bef6d0b2fd5bbc922f615cd6352bc65ec7fe429;hb=7f5205d4bee2fbc2ca2b9e26b961d37b2d656c55;hp=25c06bc89b2f35d0547cc1c0f43d26c3358df88f;hpb=e61fa4c92aff9cfcf486308b95610d00754408cf;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/window.c b/libchimara/window.c index 25c06bc..7bef6d0 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -34,6 +34,9 @@ window_new_common(glui32 rock) win->line_input_buffer_unicode = NULL; win->history = NULL; win->echo_line_input = TRUE; + win->echo_current_line_input = TRUE; + win->extra_line_terminators = NULL; + win->current_extra_line_terminators = NULL; /* Initialise the buffer */ win->buffer = g_string_sized_new(1024); @@ -64,6 +67,8 @@ window_close_common(winid_t win, gboolean destroy_node) g_list_foreach(win->history, (GFunc)g_free, NULL); g_list_free(win->history); + g_slist_free(win->extra_line_terminators); + g_slist_free(win->current_extra_line_terminators); g_string_free(win->buffer, TRUE); g_hash_table_destroy(win->hyperlinks); @@ -197,8 +202,8 @@ glk_window_get_sibling(winid_t win) if(G_NODE_IS_ROOT(win->window_node)) return NULL; if(win->window_node->next) - return (winid_t)win->window_node->next; - return (winid_t)win->window_node->prev; + return (winid_t)win->window_node->next->data; + return (winid_t)win->window_node->prev->data; } /** @@ -411,16 +416,16 @@ glk_window_get_root() * A C * * - * After the first split, the new pair window (O1, which covers the whole - * screen) knows that its first child (A) is above the second, and gets 50% of - * its own area. (A is the key window for this split, but a proportional split - * doesn't care about key windows.) + * The initial window is A. After the first split, the new pair window (O1, + * which covers the whole screen) knows that its new child (B) is below A, and + * gets 50% of its own area. (B is the key window for this split, but a + * proportional split doesn't care about key windows.) * - * After the second split, all this remains true; O1 knows that its first child - * gets 50% of its space, and A is O1's key window. But now O1's first child is - * O2 instead of A. The newer pair window (O2) knows that its first child (C) - * is above the second, and gets a fixed size of two rows. (As measured in C's - * font, because C is O2's key window.) + * After the second split, all this remains true; O1 knows + * that its first child gets 50% of its space, and B is O1's key window. But + * now O1's first child is O2 instead of A. The newer pair window (O2) knows + * that its first child (C) is above the second, and gets a fixed size of two + * rows. (As measured in C's font, because C is O2's key window.) * * If we split C, now, the resulting pair will still be two C-font rows high * — that is, tall enough for two lines of whatever font C displays. For @@ -457,8 +462,9 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, glui32 rock) { VALID_WINDOW_OR_NULL(split, return NULL); - g_return_val_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask)), NULL); - g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100), NULL); + g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100), NULL); + if(method != (method & (winmethod_DirMask | winmethod_DivisionMask | winmethod_BorderMask))) + WARNING("Unrecognized bits in method constant"); ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); @@ -559,8 +565,8 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, /* Connect signal handlers */ /* Pager */ - g_signal_connect_after( textview, "size-request", G_CALLBACK(pager_after_size_request), win ); - win->pager_expose_handler = g_signal_connect_after( textview, "expose-event", G_CALLBACK(pager_on_expose), win ); + g_signal_connect_after( textview, "size-allocate", G_CALLBACK(pager_after_size_allocate), win ); + win->pager_expose_handler = g_signal_connect_after( textview, "draw", G_CALLBACK(pager_on_draw), win ); g_signal_handler_block(textview, win->pager_expose_handler); win->pager_keypress_handler = g_signal_connect( textview, "key-press-event", G_CALLBACK(pager_on_key_press_event), win ); g_signal_handler_block(textview, win->pager_keypress_handler); @@ -1002,13 +1008,19 @@ glk_window_clear(winid_t win) case wintype_Graphics: { + GtkAllocation allocation; + /* Wait for the window's size to be updated */ g_mutex_lock(glk_data->arrange_lock); if(glk_data->needs_rearrange) g_cond_wait(glk_data->rearranged, glk_data->arrange_lock); g_mutex_unlock(glk_data->arrange_lock); - glk_window_erase_rect(win, 0, 0, win->widget->allocation.width, win->widget->allocation.height); + gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); + gdk_threads_leave(); + + glk_window_erase_rect(win, 0, 0, allocation.width, allocation.height); } break; @@ -1128,6 +1140,7 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) { VALID_WINDOW(win, return); + GtkAllocation allocation; ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); switch(win->type) @@ -1148,9 +1161,10 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); /* Cache the width and height */ - win->width = (glui32)(win->widget->allocation.width / win->unit_width); - win->height = (glui32)(win->widget->allocation.height / win->unit_height); + win->width = (glui32)(allocation.width / win->unit_width); + win->height = (glui32)(allocation.height / win->unit_height); gdk_threads_leave(); if(widthptr != NULL) @@ -1167,10 +1181,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) - *widthptr = (glui32)(win->widget->allocation.width / win->unit_width); + *widthptr = (glui32)(allocation.width / win->unit_width); if(heightptr != NULL) - *heightptr = (glui32)(win->widget->allocation.height / win->unit_height); + *heightptr = (glui32)(allocation.height / win->unit_height); gdk_threads_leave(); break; @@ -1182,10 +1197,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) - *widthptr = (glui32)(win->widget->allocation.width); + *widthptr = (glui32)(allocation.width); if(heightptr != NULL) - *heightptr = (glui32)(win->widget->allocation.height); + *heightptr = (glui32)(allocation.height); gdk_threads_leave(); break;