/*
g_printerr("View height = %d\n", visiblerect.height);
- g_printerr("End - Pager = %d\n", endpos.y - pagerpos.y);
+ g_printerr("End - Pager = %d - %d = %d\n", endpos.y, pagerpos.y, endpos.y - pagerpos.y);
*/
*view_height = visiblerect.height;
pager_on_key_press_event(GtkTextView *textview, GdkEventKey *event, winid_t win)
{
GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(win->frame) );
- gdouble step_increment, page_size, upper, lower, value;
+ gdouble page_size, upper, lower, value;
g_object_get(adj,
"page-size", &page_size,
- "step-increment", &step_increment,
"upper", &upper,
"lower", &lower,
"value", &value,
NULL);
switch (event->keyval) {
- case GDK_space: case GDK_KP_Space: case GDK_Page_Down: case GDK_KP_Page_Down:
+ case GDK_KEY_space: case GDK_KEY_KP_Space:
+ case GDK_KEY_Page_Down: case GDK_KEY_KP_Page_Down:
+ case GDK_KEY_Return: case GDK_KEY_KP_Enter:
gtk_adjustment_set_value(adj, CLAMP(value + page_size, lower, upper - page_size));
return TRUE;
- case GDK_Page_Up: case GDK_KP_Page_Up:
+ case GDK_KEY_Page_Up: case GDK_KEY_KP_Page_Up:
gtk_adjustment_set_value(adj, CLAMP(value - page_size, lower, upper - page_size));
return TRUE;
- case GDK_Return: case GDK_KP_Enter:
- gtk_adjustment_set_value(adj, CLAMP(value + step_increment, lower, upper - page_size));
- return TRUE;
/* don't handle "up" and "down", they're used for input history */
}
return FALSE; /* if the key wasn't handled here, pass it to other handlers */
}
-/* Draw the "more" prompt on top of the buffer, after the regular expose event has run */
+/* Draw the "more" prompt on top of the buffer, after the regular draw event has run */
gboolean
-pager_on_expose(GtkTextView *textview, GdkEventExpose *event, winid_t win)
+pager_on_draw(GtkTextView *textview, cairo_t *cr, winid_t win)
{
/* Calculate the position of the 'more' tag */
gint promptwidth, promptheight;
pango_layout_get_pixel_size(win->pager_layout, &promptwidth, &promptheight);
- gint winx, winy, winwidth, winheight;
- gdk_window_get_position(event->window, &winx, &winy);
- gdk_drawable_get_size(GDK_DRAWABLE(event->window), &winwidth, &winheight);
+ int winwidth = gtk_widget_get_allocated_width( GTK_WIDGET(textview) );
+ int winheight = gtk_widget_get_allocated_height( GTK_WIDGET(textview) );
/* Draw the 'more' tag */
- GdkGC *context = gdk_gc_new(GDK_DRAWABLE(event->window));
- gdk_draw_layout(event->window, context,
- winx + winwidth - promptwidth,
- winy + winheight - promptheight,
- win->pager_layout);
+ cairo_move_to(cr, winwidth - promptwidth, winheight - promptheight);
+ pango_cairo_show_layout(cr, win->pager_layout);
return FALSE; /* Propagate event further */
}
/* Check whether paging should be done. This function is called after the
* textview has finished validating text positions. */
-void pager_after_size_request(GtkTextView *textview, GtkRequisition
- *requisition, winid_t win) {
+void
+pager_after_size_allocate(GtkTextView *textview, GdkRectangle *allocation, winid_t win)
+{
/* Move the pager to the last visible character in the buffer */
- gint view_height, scroll_distance; move_pager_and_get_scroll_distance(
- GTK_TEXT_VIEW(win->widget), &view_height, &scroll_distance, FALSE
- );
+ gint view_height, scroll_distance;
+ move_pager_and_get_scroll_distance(GTK_TEXT_VIEW(win->widget), &view_height, &scroll_distance, FALSE);
if(view_height <= 1)
/* Paging is unusable when window is too small */
return;
+
+ /* If not in interactive mode, then just scroll to the bottom. */
+ ChimaraGlk *glk = CHIMARA_GLK(gtk_widget_get_ancestor(GTK_WIDGET(textview), CHIMARA_TYPE_GLK));
+ g_assert(glk);
+ if(!chimara_glk_get_interactive(glk)) {
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter(gtk_text_view_get_buffer(textview), &end);
+ gtk_text_view_scroll_to_iter(textview, &end, 0.0, TRUE, 0.0, 0.0);
+ return;
+ }
/* Scroll past text already read by user. This is automatic scrolling, so disable the pager_ajustment_handler
* first, that acts on the belief the scolling is performed by the user. */