summaryrefslogtreecommitdiff
path: root/src/glibext/gcodebuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/glibext/gcodebuffer.c')
-rw-r--r--src/glibext/gcodebuffer.c120
1 files changed, 119 insertions, 1 deletions
diff --git a/src/glibext/gcodebuffer.c b/src/glibext/gcodebuffer.c
index ac63a87..573d07d 100644
--- a/src/glibext/gcodebuffer.c
+++ b/src/glibext/gcodebuffer.c
@@ -28,7 +28,8 @@
#include <string.h>
-#include "../glibext/delayed-int.h"
+#include "delayed-int.h"
+#include "../gtkext/iodamarshal.h"
@@ -143,6 +144,7 @@ struct _GBufferView
buffer_line_draw_fc drawing_extra; /* Fonction d'accompagnement */
void *drawing_data; /* Donnée utilisateur */
+ GSList *highlighted; /* Segments mis en évidence */
};
@@ -151,6 +153,10 @@ struct _GBufferViewClass
{
GObjectClass parent; /* A laisser en premier */
+ /* Signaux */
+
+ void (* need_redraw) (GBufferView *);
+
};
@@ -567,6 +573,13 @@ G_DEFINE_TYPE(GBufferView, g_buffer_view, G_TYPE_OBJECT);
static void g_buffer_view_class_init(GBufferViewClass *class)
{
+ g_signal_new("need-redraw",
+ G_TYPE_BUFFER_VIEW,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GBufferViewClass, need_redraw),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 0);
}
@@ -815,6 +828,111 @@ void g_buffer_view_get_size(GBufferView *view, gint *width, gint *height, bool a
/******************************************************************************
* *
+* Paramètres : view = vue de tampon à mettre à jour. *
+* *
+* Description : Supprime toute mise en évidence de segments. *
+* *
+* Retour : true si un besoin d'actualisation d'affichage se fait sentir.*
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool g_buffer_view_unhighlight_segments(GBufferView *view)
+{
+ GSList *iter; /* Boucle de parcours */
+ GBufferSegment *segment; /* Segment visé par le pointeur*/
+
+ if (g_slist_length(view->highlighted) == 0)
+ return false;
+
+ for (iter = view->highlighted; iter != NULL; iter = view->highlighted)
+ {
+ segment = G_BUFFER_SEGMENT(iter->data);
+ g_buffer_segment_set_style(segment, SRS_CLASSIC);
+
+ g_object_unref(G_OBJECT(segment));
+
+ view->highlighted = g_slist_remove_link(view->highlighted, iter);
+
+ }
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = vue de tampon à mettre à jour. *
+* x = abscisse de la zone principale à traiter. *
+* y = ordonnée de la zone principale à traiter. *
+* *
+* Description : Surligne tous les segments similaires à celui sous la souris.*
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_buffer_view_highlight_segments(GBufferView *view, gint x, gint y)
+{
+ GBufferLine *line; /* Ligne sous le pointeur */
+ GBufferSegment *segment; /* Segment visé par le pointeur*/
+ bool need_redraw; /* Besoin d'actualisation ? */
+ size_t first; /* Première ligne intégrée */
+ size_t last; /* Dernière ligne intégrée */
+ size_t i; /* Boucle de parcours */
+
+ line = g_buffer_view_find_line_at(view, y);
+ if (line == NULL) return;
+
+
+ do
+ {
+ vmpa_t addr;
+ addr = g_buffer_line_get_address(line);
+
+ printf(" ... x2 clic at 0x%08lx\n", addr);
+
+ }
+ while (0);
+
+ x -= view->left_text;
+ if (x < 0) return;
+
+ segment = g_buffer_line_get_segment_at(line, view->max_widths, x);
+ printf(" ... seg @%d ? %p\n", x, segment);
+ if (segment == NULL) return;
+
+
+ printf("text :: '%s'\n", g_buffer_segment_get_text(segment));
+
+
+ if (view->highlighted != NULL)
+ need_redraw = g_buffer_view_unhighlight_segments(view);
+ else
+ need_redraw = false;
+
+ first = g_code_buffer_get_index_from_address(view->buffer, view->start);
+ last = g_code_buffer_get_index_from_address(view->buffer, view->end);
+
+ for (i = first; i < last; i++)
+ view->highlighted = g_buffer_line_highlight_all_same_segments(view->buffer->lines[i],
+ view->highlighted, segment);
+
+ if (g_slist_length(view->highlighted) > 0)
+ need_redraw = true;
+
+ if (need_redraw)
+ g_signal_emit_by_name(view, "need-redraw");
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : view = visualisation à mettre à jour. *
* method = procédure à appeler à chaque dessin de ligne. *
* data = donnée utilisateur à passer lors des appels. *