summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkbufferdisplay.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-12-20 22:12:28 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-12-20 22:12:28 (GMT)
commitcffbe4839da452af215f05dfb7cc6c9304c1285e (patch)
treed2ea78b67592e868ed94ab189722670379cd2b67 /src/gtkext/gtkbufferdisplay.c
parent0f58e137ff493ab38d2a7e6e2d5e5bc85951be3d (diff)
Kept the current location when switching views.
Diffstat (limited to 'src/gtkext/gtkbufferdisplay.c')
-rw-r--r--src/gtkext/gtkbufferdisplay.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c
index 1989b1c..a748cf2 100644
--- a/src/gtkext/gtkbufferdisplay.c
+++ b/src/gtkext/gtkbufferdisplay.c
@@ -212,6 +212,12 @@ static void gtk_buffer_display_init(GtkBufferDisplay *display)
static void gtk_buffer_display_dispose(GtkBufferDisplay *display)
{
+ if (display->caret_timer != 0)
+ {
+ g_source_remove(display->caret_timer);
+ display->caret_timer = 0;
+ }
+
g_clear_object(&display->view);
g_clear_object(&display->cursor);
@@ -814,6 +820,56 @@ GBufferView *gtk_buffer_display_get_view(const GtkBufferDisplay *display)
/******************************************************************************
* *
+* Paramètres : display = composant GTK à consulter. *
+* cursor = définition générique d'une localisation à l'écran. *
+* *
+* Description : Détermine si une position est comprise dans l'affichage. *
+* *
+* Retour : true si le composant comprend bien la localisation fournie. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool gtk_buffer_display_contains_cursor(const GtkBufferDisplay *display, const GLineCursor *cursor)
+{
+ bool result; /* Bilan à retourner */
+ GLineCursor *start; /* Position initiale du tampon */
+ GLineCursor *end; /* Position finale du tampon */
+ int status; /* Bilan d'une comparaison */
+
+ g_buffer_view_get_restrictions(display->view, &start, &end);
+
+ if (start == NULL && end == NULL)
+ result = NULL;
+
+ else
+ {
+ status = g_line_cursor_compare(start, cursor);
+
+ if (status > 0)
+ result = false;
+
+ else
+ {
+ status = g_line_cursor_compare(cursor, end);
+
+ result = (status < 0);
+
+ }
+
+ g_object_unref(G_OBJECT(start));
+ g_object_unref(G_OBJECT(end));
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : display = composant GTK à manipuler. *
* x = abscisse proposée pour le nouvel emplacement. *
* y = ordonnée proposée pour le nouvel emplacement. *