summaryrefslogtreecommitdiff
path: root/src/glibext/gbufferline.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-01-16 21:12:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-01-16 21:12:08 (GMT)
commit52ac5b1b340335f56ceb599dba63164a26f10b10 (patch)
tree275104896dffa65e7887284857fa8fed831e9ea8 /src/glibext/gbufferline.c
parent2ddb5c26af896b10517a89abf0c9498c598b7697 (diff)
Changed the display of a segment containing the value of an immediate.
Diffstat (limited to 'src/glibext/gbufferline.c')
-rw-r--r--src/glibext/gbufferline.c115
1 files changed, 108 insertions, 7 deletions
diff --git a/src/glibext/gbufferline.c b/src/glibext/gbufferline.c
index 2680dae..1a17a9c 100644
--- a/src/glibext/gbufferline.c
+++ b/src/glibext/gbufferline.c
@@ -74,6 +74,9 @@ static GBufferSegment *get_segment_at(const buffer_line_column *, gint *, GdkScr
/* Fournit le segment voisin d'un autre segment identifié. */
static GBufferSegment *find_near_segment(const buffer_line_column *, GBufferSegment *, GdkScrollDirection);
+/* Fournit le segment créé par un objet particulier. */
+static GBufferSegment *find_segment_from_creator(const buffer_line_column *, GObject *);
+
/* Imprime le contenu d'une colonne de ligne de texte. */
static void draw_segments_of_column(buffer_line_column *, cairo_t *, gint, gint, const segcnt_list *);
@@ -121,6 +124,8 @@ struct _GBufferLineClass
/* Signaux */
+ void (* content_changed) (GBufferLine *, GBufferSegment *);
+
void (* flip_flag) (GBufferLine *, BufferLineFlags, BufferLineFlags);
};
@@ -138,6 +143,9 @@ static void g_buffer_line_dispose(GBufferLine *);
/* Procède à la libération totale de la mémoire. */
static void g_buffer_line_finalize(GBufferLine *);
+/* Réagit au changement de contenu d'un segment encapsulé. */
+static void on_line_segment_changed(GBufferSegment *, GBufferLine *);
+
/* ---------------------------------------------------------------------------------- */
@@ -145,9 +153,6 @@ static void g_buffer_line_finalize(GBufferLine *);
/* ---------------------------------------------------------------------------------- */
-
-
-
/******************************************************************************
* *
* Paramètres : column = colonne de ligne à mettre à jour. *
@@ -333,13 +338,14 @@ static GBufferSegment *get_segment_at(const buffer_line_column *column, gint *x,
static GBufferSegment *find_near_segment(const buffer_line_column *column, GBufferSegment *target, GdkScrollDirection dir)
{
GBufferSegment *result; /* Trouvaille à retourner */
+ bool found; /* Le segment est bien présent */
size_t i; /* Boucle de parcours */
result = NULL;
- column_has_segment(column, target, &i);
+ found = column_has_segment(column, target, &i);
- if (i < column->count)
+ if (found)
switch (dir)
{
case GDK_SCROLL_LEFT:
@@ -364,6 +370,41 @@ static GBufferSegment *find_near_segment(const buffer_line_column *column, GBuff
/******************************************************************************
* *
+* Paramètres : column = colonne de ligne de texte à consulter. *
+* creator = créateur à l'origine du segment recherché. *
+* *
+* Description : Fournit le segment créé par un objet particulier. *
+* *
+* Retour : Segment trouvé ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBufferSegment *find_segment_from_creator(const buffer_line_column *column, GObject *creator)
+{
+ GBufferSegment *result; /* Trouvaille à retourner */
+ size_t i; /* Boucle de parcours #1 */
+ GBufferSegment *iter; /* Boucle de parcours #2 */
+
+ result = NULL;
+
+ for (i = 0; i < column->count && result == NULL; i++)
+ {
+ iter = column->segments[i];
+
+ if (g_buffer_segment_get_creator(iter) == creator)
+ result = iter;
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : column = colonne de ligne de texte à manipuler. *
* cairo = contexte graphique à utiliser pour les pinceaux. *
* x_init = abscisse du point d'impression de départ. *
@@ -491,6 +532,14 @@ static void g_buffer_line_class_init(GBufferLineClass *class)
g_free(filename);
+ g_signal_new("content-changed",
+ G_TYPE_BUFFER_LINE,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(GBufferLineClass, content_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, G_TYPE_OBJECT);
+
g_signal_new("flip-flag",
G_TYPE_BUFFER_LINE,
G_SIGNAL_RUN_LAST,
@@ -1097,6 +1146,57 @@ GBufferSegment *g_buffer_line_find_near_segment(const GBufferLine *line, GBuffer
/******************************************************************************
* *
+* Paramètres : line = ligne à venir consulter. *
+* creator = créateur à l'origine du segment recherché. *
+* *
+* Description : Fournit le segment créé par un objet particulier. *
+* *
+* Retour : Segment trouvé dans la ligne ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GBufferSegment *g_buffer_line_find_segment_from_creator(const GBufferLine *line, GObject *creator)
+{
+ GBufferSegment *result; /* Trouvaille à retourner */
+ BufferLineColumn i; /* Boucle de parcours */
+
+ result = NULL;
+
+ for (i = 0; i < BLC_COUNT && result == NULL; i++)
+ result = find_segment_from_creator(&line->columns[i], creator);
+
+ if (result != NULL)
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : segment = segment de texte dont le contenu vient de changer. *
+* line = ligne contenant ce segment. *
+* *
+* Description : Réagit au changement de contenu d'un segment encapsulé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void on_line_segment_changed(GBufferSegment *segment, GBufferLine *line)
+{
+ g_signal_emit_by_name(line, "content-changed");
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : line = ligne à venir compléter. *
* column = colonne de la ligne visée par l'insertion. *
* text = texte à insérer dans l'existant. *
@@ -1115,8 +1215,7 @@ GBufferSegment *g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn co
{
GBufferSegment *result; /* Portion de texte à renvoyer */
- if (length == 0)
- return;
+ assert(length > 0);
if (column == BLC_MAIN)
column = line->main_column;
@@ -1129,6 +1228,8 @@ GBufferSegment *g_buffer_line_insert_text(GBufferLine *line, BufferLineColumn co
result = g_buffer_segment_new(type, text, length);
g_buffer_line_add_segment(line, column, result);
+ g_signal_connect(result, "content-changed", G_CALLBACK(on_line_segment_changed), line);
+
return result;
}