summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-07-14 13:15:59 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-07-14 13:15:59 (GMT)
commit9441aee9dfb31332ffbfa64204b5e4466249d563 (patch)
treec7e2b826dada2e39127a1f85536de71063f9be0f /src/gtkext
parent078b2ffd38da040ab87a9686bcc2e796841cccb7 (diff)
Deleted a few more references to concrete locations in buffer displays.
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/gtkbufferdisplay-int.h3
-rw-r--r--src/gtkext/gtkbufferdisplay.c48
2 files changed, 26 insertions, 25 deletions
diff --git a/src/gtkext/gtkbufferdisplay-int.h b/src/gtkext/gtkbufferdisplay-int.h
index 2d1dbe3..9a5980f 100644
--- a/src/gtkext/gtkbufferdisplay-int.h
+++ b/src/gtkext/gtkbufferdisplay-int.h
@@ -43,8 +43,9 @@ struct _GtkBufferDisplay
GBufferView *view; /* Vue sur le contenu affiché */
- cairo_rectangle_int_t caret; /* Emplacement du curseur */
+ cairo_rectangle_int_t caret; /* Emplacement du curseur #1 */
vmpa2t caret_addr; /* Position mémoire du curseur */
+ GLineCursor *cursor; /* Emplacement du curseur #2 */
guint caret_timer; /* Identifiant du chronomètre */
bool show_caret; /* Bascule entre les affichages*/
diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c
index 49167e8..c09a1fe 100644
--- a/src/gtkext/gtkbufferdisplay.c
+++ b/src/gtkext/gtkbufferdisplay.c
@@ -92,7 +92,7 @@ static void gtk_buffer_display_cache_glance(GtkBufferDisplay *, cairo_t *, const
static bool _gtk_buffer_display_move_caret_to(GtkBufferDisplay *, gint, gint);
/* Déplace le curseur en effaçant son éventuelle position. */
-static void gtk_buffer_display_relocate_caret(GtkBufferDisplay *, const cairo_rectangle_int_t *, const vmpa2t *);
+static void gtk_buffer_display_relocate_caret(GtkBufferDisplay *, const cairo_rectangle_int_t *, GLineCursor *);
/* Assure le clignotement du curseur à l'emplacement courant. */
static gboolean gtk_buffer_display_refresh_caret(GtkBufferDisplay *);
@@ -186,7 +186,7 @@ static void gtk_buffer_display_class_init(GtkBufferDisplayClass *class)
static void gtk_buffer_display_init(GtkBufferDisplay *display)
{
- init_vmpa(&display->caret_addr, VMPA_NO_PHYSICAL, VMPA_NO_VIRTUAL);
+ display->cursor = NULL;
}
@@ -427,7 +427,7 @@ static gboolean gtk_buffer_display_draw(GtkWidget *widget, cairo_t *cr)
g_generic_config_get_value(get_main_configuration(), MPK_SELECTION_LINE, &sel_line);
sel_line &= gtk_widget_has_focus(widget);
- if (!sel_line || is_invalid_vmpa(&display->caret_addr))
+ if (!sel_line || display->cursor == NULL || !g_line_cursor_is_valid(display->cursor))
selected = NULL;
else
{
@@ -523,10 +523,10 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve
{
////////////////////////
g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &addr);
- g_object_unref(G_OBJECT(cursor));
+ //g_object_unref(G_OBJECT(cursor));
////////////////////////
- gtk_buffer_display_relocate_caret(display, &area, &addr);
+ gtk_buffer_display_relocate_caret(display, &area, cursor);
_gtk_display_panel_scroll_to_address(panel, &addr, SPT_RAW, false);
}
else
@@ -747,7 +747,7 @@ GObject *gtk_buffer_display_get_active_object(const GtkBufferDisplay *display)
GObject *result; /* Trouvaille à retourner */
/* Si aucune position n'est définie... */
- if (is_invalid_vmpa(&display->caret_addr))
+ if (display->cursor == NULL || !g_line_cursor_is_valid(display->cursor))
result = NULL;
else
@@ -862,22 +862,13 @@ static bool _gtk_buffer_display_move_caret_to(GtkBufferDisplay *display, gint x,
GtkDisplayPanel *panel; /* Autre version du composant */
cairo_rectangle_int_t new; /* Nouvel emplacement calculé */
GLineCursor *cursor; /* Emplacement de curseur */
- vmpa2t addr; /* Position mémoire associée */
panel = GTK_DISPLAY_PANEL(display);
result = g_buffer_view_compute_caret_full(display->view, x, y, panel->display_options, &new, &cursor);
- ////////////////////////
if (result)
- {
- g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &addr);
- g_object_unref(G_OBJECT(cursor));
- }
- ////////////////////////
-
- if (result)
- gtk_buffer_display_relocate_caret(display, &new, &addr);
+ gtk_buffer_display_relocate_caret(display, &new, cursor);
return result;
@@ -941,7 +932,7 @@ bool gtk_buffer_display_move_caret_to(GtkBufferDisplay *display, bool beginning,
* *
* Paramètres : display = composant GTK à manipuler. *
* area = emplacement pour le dessin d'un curseur. *
-* addr = position dans la mémoire représentée du curseur. *
+* cursor = emplacement représenté dans un tampon interne. *
* *
* Description : Déplace le curseur en effaçant son éventuelle position. *
* *
@@ -951,13 +942,13 @@ bool gtk_buffer_display_move_caret_to(GtkBufferDisplay *display, bool beginning,
* *
******************************************************************************/
-static void gtk_buffer_display_relocate_caret(GtkBufferDisplay *display, const cairo_rectangle_int_t *area, const vmpa2t *addr)
+static void gtk_buffer_display_relocate_caret(GtkBufferDisplay *display, const cairo_rectangle_int_t *area, GLineCursor *cursor)
{
bool clear_old; /* Effacement chirurgical */
cairo_rectangle_int_t old_area; /* Mémorisation de l'ancien */
bool need_redraw; /* Besoin de rafraîchissement ?*/
- if (!is_invalid_vmpa(&display->caret_addr))
+ if (display->cursor != NULL && g_line_cursor_is_valid(display->cursor))
{
clear_old = true;
old_area = display->caret;
@@ -965,15 +956,24 @@ static void gtk_buffer_display_relocate_caret(GtkBufferDisplay *display, const c
else
clear_old = false;
+ if (display->cursor != NULL)
+ g_object_unref(G_OBJECT(display->cursor));
+
display->caret = *area;
- copy_vmpa(&display->caret_addr, addr);
+ display->cursor = cursor;
+
+ /////////////////
+ if (cursor != NULL)
+ g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &display->caret_addr);
+ /////////////////
+
if (GTK_BUFFER_DISPLAY_GET_CLASS(display)->notify_caret != NULL)
need_redraw = GTK_BUFFER_DISPLAY_GET_CLASS(display)->notify_caret(display, area);
else
need_redraw = false;
- if (!is_invalid_vmpa(&display->caret_addr))
+ if (display->cursor != NULL && g_line_cursor_is_valid(display->cursor))
gtk_buffer_display_restart_caret_blinking(display);
if (need_redraw)
@@ -1002,7 +1002,7 @@ static gboolean gtk_buffer_display_refresh_caret(GtkBufferDisplay *display)
/* Bascule l'affichage */
display->show_caret = !display->show_caret;
- assert(!is_invalid_vmpa(&display->caret_addr));
+ assert(display->cursor != NULL && g_line_cursor_is_valid(display->cursor));
if (!display->show_caret)
gtk_buffer_display_queue_draw_caret(display, &display->caret);
@@ -1038,7 +1038,7 @@ static void gtk_buffer_display_restart_caret_blinking(GtkBufferDisplay *display)
display->caret_timer = 0;
}
- if (!is_invalid_vmpa(&display->caret_addr))
+ if (display->cursor != NULL && g_line_cursor_is_valid(display->cursor))
{
settings = gtk_settings_get_default();
@@ -1127,7 +1127,7 @@ static void gtk_buffer_display_draw_caret(GtkBufferDisplay *display, cairo_t *cr
GtkWidget *widget; /* Autre version du composant */
GdkRGBA *color; /* Couleur du curseur */
- if (!is_invalid_vmpa(&display->caret_addr) && display->show_caret)
+ if (display->cursor != NULL && g_line_cursor_is_valid(display->cursor) && display->show_caret)
{
area = display->caret;
gtk_display_panel_compute_relative_coords(GTK_DISPLAY_PANEL(display), &area.x, &area.y);