summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkbufferview.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/gtkbufferview.c')
-rw-r--r--src/gtkext/gtkbufferview.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c
index f179845..30cf075 100644
--- a/src/gtkext/gtkbufferview.c
+++ b/src/gtkext/gtkbufferview.c
@@ -59,7 +59,7 @@ static void gtk_buffer_view_compute_requested_size(GtkBufferView *, gint *, gint
static void gtk_buffer_view_compute_scroll_inc(GtkBufferView *, gint, GtkOrientation, gdouble *, gdouble *);
/* Indique la position d'affichage d'une adresse donnée. */
-static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *, const vmpa2t *, gint *, gint *);
+static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *, const vmpa2t *, gint *, gint *, ScrollPositionTweak);
/* Place en cache un rendu destiné à l'aperçu graphique rapide. */
static void gtk_buffer_view_cache_glance(GtkBufferView *, cairo_t *, const GtkAllocation *, double);
@@ -474,7 +474,7 @@ static gboolean gtk_buffer_view_key_press(GtkWidget *widget, GdkEventKey *event)
printf("ctrl ? %d -- keyval = %d -->> %d\n", ctrl, event->keyval, result);
- if (addr != NULL) gtk_view_panel_scroll_to_address(pview, addr);
+ if (addr != NULL) gtk_view_panel_scroll_to_address(pview, addr, SPT_RAW);
printf("\n");
@@ -552,10 +552,11 @@ static void gtk_buffer_view_compute_scroll_inc(GtkBufferView *view, gint size, G
/******************************************************************************
* *
-* Paramètres : view = composant GTK à consulter. *
-* addr = adresse à présenter à l'écran. *
-* x = position horizontale au sein du composant. [OUT] *
-* y = position verticale au sein du composant. [OUT] *
+* Paramètres : view = composant GTK à consulter. *
+* addr = adresse à présenter à l'écran. *
+* x = position horizontale au sein du composant. [OUT] *
+* y = position verticale au sein du composant. [OUT] *
+* tweak = adaptation finale à effectuer. *
* *
* Description : Indique la position d'affichage d'une adresse donnée. *
* *
@@ -565,9 +566,42 @@ static void gtk_buffer_view_compute_scroll_inc(GtkBufferView *view, gint size, G
* *
******************************************************************************/
-static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *view, const vmpa2t *addr, gint *x, gint *y)
+static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *view, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak)
{
- return g_buffer_view_get_address_coordinates(view->buffer_view, addr, x, y);
+ bool result; /* Bilan à remonter */
+ bool need_code; /* Recherche plus raffinée */
+ int height; /* Hauteur allouée */
+
+ need_code = (tweak == SPT_BOTTOM);
+
+ result = g_buffer_view_get_address_coordinates(view->buffer_view, addr, x, y, need_code);
+
+ if (result)
+ {
+ height = gtk_widget_get_allocated_height(GTK_WIDGET(view));
+
+ switch (tweak)
+ {
+ case SPT_RAW:
+ break;
+
+ case SPT_TOP:
+ break;
+
+ case SPT_CENTER:
+ *y -= (height / 2);
+ break;
+
+ case SPT_BOTTOM:
+ *y -= height;
+ *y += g_buffer_view_get_line_height(view->buffer_view);
+ break;
+
+ }
+
+ }
+
+ return result;
}